diff options
author | jiangzhengwenjz <jiangzhengwenjzw@qq.com> | 2019-08-25 13:09:46 +0800 |
---|---|---|
committer | jiangzhengwenjz <jiangzhengwenjzw@qq.com> | 2019-08-26 04:01:55 +0800 |
commit | 1d8232b919a973b8e58d6431b0fb66ae6459f17a (patch) | |
tree | 6e24d64ebea1a3e9bd70c0c483d6403d6233ed59 | |
parent | 8b14f4e90abf8010e83d6b38a26034458ce36d5d (diff) |
thru atk23
-rw-r--r-- | asm/battle_2.s | 6 | ||||
-rw-r--r-- | asm/battle_script_commands.s | 4466 | ||||
-rw-r--r-- | include/battle.h | 16 | ||||
-rw-r--r-- | src/battle_script_commands.c | 1226 |
4 files changed, 1235 insertions, 4479 deletions
diff --git a/asm/battle_2.s b/asm/battle_2.s index a019e4969..344325ff4 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -5766,8 +5766,8 @@ _08012BC0: .4byte gLastHitBy _08012BC4: .4byte gBattleResources thumb_func_end SwitchInClearSetData - thumb_func_start sub_8012BC8 -sub_8012BC8: @ 8012BC8 + thumb_func_start FaintClearSetData +FaintClearSetData: @ 8012BC8 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -6257,7 +6257,7 @@ _08012F9C: .4byte gLastPrintedMoves _08012FA0: .4byte gLastHitBy _08012FA4: .4byte gBattleResources _08012FA8: .4byte gBaseStats - thumb_func_end sub_8012BC8 + thumb_func_end FaintClearSetData thumb_func_start BattleIntroGetMonsData BattleIntroGetMonsData: @ 8012FAC diff --git a/asm/battle_script_commands.s b/asm/battle_script_commands.s index 8c70f5d8a..1d0282835 100644 --- a/asm/battle_script_commands.s +++ b/asm/battle_script_commands.s @@ -5,4472 +5,6 @@ .text - thumb_func_start SetMoveEffect -SetMoveEffect: @ 801FF20 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - movs r0, 0 - mov r10, r0 - movs r7, 0 - movs r1, 0x1 - str r1, [sp, 0x4] - ldr r1, _0801FF64 @ =gBattleCommunication - ldrb r3, [r1, 0x3] - movs r0, 0x40 - ands r0, r3 - adds r6, r1, 0 - cmp r0, 0 - beq _0801FF78 - ldr r2, _0801FF68 @ =gEffectBattler - ldr r0, _0801FF6C @ =gBattlerAttacker - ldrb r0, [r0] - strb r0, [r2] - movs r0, 0xBF - ands r0, r3 - strb r0, [r6, 0x3] - movs r7, 0x40 - ldr r1, _0801FF70 @ =gBattleScripting - ldr r0, _0801FF74 @ =gBattlerTarget - b _0801FF84 - .align 2, 0 -_0801FF64: .4byte gBattleCommunication -_0801FF68: .4byte gEffectBattler -_0801FF6C: .4byte gBattlerAttacker -_0801FF70: .4byte gBattleScripting -_0801FF74: .4byte gBattlerTarget -_0801FF78: - ldr r2, _08020094 @ =gEffectBattler - ldr r0, _08020098 @ =gBattlerTarget - ldrb r0, [r0] - strb r0, [r2] - ldr r1, _0802009C @ =gBattleScripting - ldr r0, _080200A0 @ =gBattlerAttacker -_0801FF84: - ldrb r0, [r0] - strb r0, [r1, 0x17] - mov r9, r2 - ldr r0, _080200A4 @ =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 9 - ands r0, r1 - cmp r0, 0 - beq _0801FFB2 - ldrb r0, [r6, 0x3] - cmp r0, 0x1 - beq _0801FFB2 - mov r2, r9 - ldrb r0, [r2] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0801FFB2 - bl _080210EC -_0801FFB2: - ldr r3, _080200A8 @ =gBattleMons - ldr r2, _08020094 @ =gEffectBattler - ldrb r1, [r2] - movs r0, 0x58 - muls r0, r1 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - mov r9, r2 - cmp r0, 0x13 - bne _0801FFE6 - ldr r0, _080200AC @ =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - bne _0801FFE6 - cmp r4, 0 - bne _0801FFE6 - ldr r0, _080200B0 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - cmp r0, 0x9 - bhi _0801FFE6 - bl _080210EC -_0801FFE6: - mov r3, r9 - ldrb r0, [r3] - bl GetBattlerPosition - ldr r2, _080200B4 @ =gSideStatuses - movs r1, 0x1 - ands r1, r0 - lsls r1, 1 - adds r1, r2 - ldrh r1, [r1] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08020020 - ldr r0, _080200AC @ =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - bne _08020020 - cmp r4, 0 - bne _08020020 - ldr r0, _080200B0 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - cmp r0, 0x7 - bhi _08020020 - bl _080210EC -_08020020: - ldr r3, _080200A8 @ =gBattleMons - ldr r2, _08020094 @ =gEffectBattler - ldrb r1, [r2] - movs r0, 0x58 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0, 0x28] - mov r9, r2 - mov r8, r3 - cmp r0, 0 - bne _08020046 - ldr r0, _080200B0 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - cmp r0, 0xB - beq _08020046 - cmp r0, 0x1F - beq _08020046 - bl _080210EC -_08020046: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - mov r1, r8 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _08020068 - cmp r7, 0x40 - beq _08020068 - bl _080210EC -_08020068: - ldr r0, _080200B0 @ =gBattleCommunication - ldrb r1, [r0, 0x3] - adds r6, r0, 0 - cmp r1, 0x6 - bls _08020074 - b _080206A2 -_08020074: - ldr r1, _080200B8 @ =sStatusFlagsForMoveEffects - ldrb r0, [r6, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0x10 - bne _08020084 - b _08020270 -_08020084: - cmp r0, 0x10 - bhi _080200BC - cmp r0, 0x7 - beq _080200D6 - cmp r0, 0x8 - bne _08020092 - b _0802018C -_08020092: - b _08020570 - .align 2, 0 -_08020094: .4byte gEffectBattler -_08020098: .4byte gBattlerTarget -_0802009C: .4byte gBattleScripting -_080200A0: .4byte gBattlerAttacker -_080200A4: .4byte gBattleTypeFlags -_080200A8: .4byte gBattleMons -_080200AC: .4byte gHitMarker -_080200B0: .4byte gBattleCommunication -_080200B4: .4byte gSideStatuses -_080200B8: .4byte sStatusFlagsForMoveEffects -_080200BC: - cmp r0, 0x40 - bne _080200C2 - b _080203E4 -_080200C2: - cmp r0, 0x40 - bhi _080200CE - cmp r0, 0x20 - bne _080200CC - b _08020346 -_080200CC: - b _08020570 -_080200CE: - cmp r0, 0x80 - bne _080200D4 - b _08020440 -_080200D4: - b _08020570 -_080200D6: - mov r2, r9 - ldrb r1, [r2] - movs r0, 0x58 - muls r0, r1 - add r0, r8 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x2B - beq _08020138 - ldr r0, _08020130 @ =gActiveBattler - movs r1, 0 - strb r1, [r0] - ldr r1, _08020134 @ =gBattlersCount - ldrb r3, [r1] - adds r7, r0, 0 - mov r12, r1 - cmp r3, 0 - beq _08020144 - mov r4, r8 - ldr r0, [r4, 0x50] - movs r1, 0x70 - ands r0, r1 - cmp r0, 0 - bne _08020144 - adds r1, r7, 0 - mov r6, r8 - adds r6, 0x50 - movs r5, 0x58 - movs r4, 0x70 -_08020110: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r3 - bcs _08020144 - ldrb r0, [r7] - muls r0, r5 - adds r0, r6 - ldr r0, [r0] - ands r0, r4 - cmp r0, 0 - beq _08020110 - b _08020144 - .align 2, 0 -_08020130: .4byte gActiveBattler -_08020134: .4byte gBattlersCount -_08020138: - ldr r0, _08020184 @ =gActiveBattler - ldr r2, _08020188 @ =gBattlersCount - ldrb r1, [r2] - strb r1, [r0] - adds r7, r0, 0 - mov r12, r2 -_08020144: - mov r0, r9 - ldrb r2, [r0] - movs r0, 0x58 - adds r1, r2, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x4C - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - beq _0802015C - b _08020570 -_0802015C: - ldrb r0, [r7] - mov r3, r12 - ldrb r3, [r3] - cmp r0, r3 - beq _08020168 - b _08020570 -_08020168: - mov r4, r8 - adds r0, r1, r4 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x48 - bne _08020176 - b _08020570 -_08020176: - cmp r0, 0xF - bne _0802017C - b _08020570 -_0802017C: - adds r0, r2, 0 - bl CancelMultiTurnMoves - b _08020560 - .align 2, 0 -_08020184: .4byte gActiveBattler -_08020188: .4byte gBattlersCount -_0802018C: - mov r2, r9 - ldrb r1, [r2] - movs r0, 0x58 - muls r0, r1 - add r0, r8 - adds r0, 0x20 - ldrb r1, [r0] - cmp r1, 0x11 - bne _080201E4 - cmp r4, 0x1 - beq _080201A6 - cmp r5, 0x80 - bne _080201E4 -_080201A6: - ldr r0, _080201D4 @ =gLastUsedAbility - strb r1, [r0] - mov r3, r9 - ldrb r0, [r3] - movs r1, 0x11 - bl RecordAbilityBattle - ldr r4, _080201D8 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _080201DC @ =BattleScript_PSNPrevention -_080201C0: - str r0, [r4] - ldr r2, _080201E0 @ =gHitMarker - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 6 - ands r0, r1 - cmp r0, 0 - beq _080201D2 - b _08020484 -_080201D2: - b _080204A8 - .align 2, 0 -_080201D4: .4byte gLastUsedAbility -_080201D8: .4byte gBattlescriptCurrInstr -_080201DC: .4byte BattleScript_PSNPrevention -_080201E0: .4byte gHitMarker -_080201E4: - mov r1, r9 - ldrb r0, [r1] - movs r1, 0x58 - muls r0, r1 - add r0, r8 - adds r1, r0, 0 - adds r1, 0x21 - ldrb r1, [r1] - cmp r1, 0x3 - beq _08020208 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x3 - beq _08020208 - cmp r1, 0x8 - beq _08020208 - cmp r0, 0x8 - bne _08020222 -_08020208: - ldr r0, _0802026C @ =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - beq _08020222 - cmp r4, 0x1 - bne _0802021C - b _080204E8 -_0802021C: - cmp r5, 0x80 - bne _08020222 - b _080204E8 -_08020222: - mov r2, r9 - ldrb r1, [r2] - movs r0, 0x58 - muls r1, r0 - mov r4, r8 - adds r3, r1, r4 - adds r0, r3, 0 - adds r0, 0x21 - ldrb r4, [r0] - cmp r4, 0x3 - bne _0802023A - b _08020570 -_0802023A: - adds r0, 0x1 - ldrb r0, [r0] - cmp r0, 0x3 - bne _08020244 - b _08020570 -_08020244: - cmp r4, 0x8 - bne _0802024A - b _08020570 -_0802024A: - cmp r0, 0x8 - bne _08020250 - b _08020570 -_08020250: - mov r0, r8 - adds r0, 0x4C - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - beq _0802025E - b _08020570 -_0802025E: - adds r0, r3, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x11 - bne _0802026A - b _08020570 -_0802026A: - b _08020560 - .align 2, 0 -_0802026C: .4byte gHitMarker -_08020270: - mov r2, r9 - ldrb r1, [r2] - movs r0, 0x58 - muls r0, r1 - add r0, r8 - adds r0, 0x20 - ldrb r1, [r0] - cmp r1, 0x29 - bne _080202B4 - cmp r4, 0x1 - beq _0802028A - cmp r5, 0x80 - bne _080202B4 -_0802028A: - ldr r0, _080202A8 @ =gLastUsedAbility - strb r1, [r0] - mov r3, r9 - ldrb r0, [r3] - movs r1, 0x29 - bl RecordAbilityBattle - ldr r4, _080202AC @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _080202B0 @ =BattleScript_BRNPrevention - b _080201C0 - .align 2, 0 -_080202A8: .4byte gLastUsedAbility -_080202AC: .4byte gBattlescriptCurrInstr -_080202B0: .4byte BattleScript_BRNPrevention -_080202B4: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - mov r2, r8 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0xA - beq _080202D4 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xA - bne _08020304 -_080202D4: - ldr r0, _080202F8 @ =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - beq _08020304 - cmp r4, 0x1 - beq _080202EA - cmp r5, 0x80 - bne _08020304 -_080202EA: - ldr r4, _080202FC @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020300 @ =BattleScript_BRNPrevention - b _080204F4 - .align 2, 0 -_080202F8: .4byte gHitMarker -_080202FC: .4byte gBattlescriptCurrInstr -_08020300: .4byte BattleScript_BRNPrevention -_08020304: - mov r3, r9 - ldrb r0, [r3] - movs r1, 0x58 - adds r2, r0, 0 - muls r2, r1 - mov r4, r8 - adds r1, r2, r4 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0xA - bne _0802031E - b _08020570 -_0802031E: - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xA - bne _0802032A - b _08020570 -_0802032A: - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x29 - bne _08020336 - b _08020570 -_08020336: - mov r0, r8 - adds r0, 0x4C - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - beq _08020344 - b _08020570 -_08020344: - b _08020560 -_08020346: - 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 _08020382 - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _08020382 - ldr r0, _080203D8 @ =gBattleWeather - ldrh r1, [r0] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _08020382 - movs r1, 0 - str r1, [sp, 0x4] -_08020382: - ldr r4, _080203DC @ =gBattleMons - ldr r0, _080203E0 @ =gEffectBattler - ldrb r3, [r0] - movs r0, 0x58 - adds r2, r3, 0 - muls r2, r0 - adds r1, r2, r4 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0xF - bne _0802039C - b _08020570 -_0802039C: - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xF - bne _080203A8 - b _08020570 -_080203A8: - adds r0, r4, 0 - adds r0, 0x4C - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - beq _080203B6 - b _08020570 -_080203B6: - ldr r2, [sp, 0x4] - cmp r2, 0 - bne _080203BE - b _08020570 -_080203BE: - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x28 - bne _080203CA - b _08020570 -_080203CA: - adds r0, r3, 0 - bl CancelMultiTurnMoves - movs r3, 0x1 - mov r10, r3 - b _08020570 - .align 2, 0 -_080203D8: .4byte gBattleWeather -_080203DC: .4byte gBattleMons -_080203E0: .4byte gEffectBattler -_080203E4: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - mov r2, r8 - adds r0, r1, r2 - adds r0, 0x20 - ldrb r2, [r0] - cmp r2, 0x7 - bne _0802042C - cmp r4, 0x1 - beq _08020402 - cmp r5, 0x80 - beq _08020402 - b _08020570 -_08020402: - ldr r0, _08020420 @ =gLastUsedAbility - strb r2, [r0] - mov r3, r9 - ldrb r0, [r3] - movs r1, 0x7 - bl RecordAbilityBattle - ldr r4, _08020424 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020428 @ =BattleScript_PRLZPrevention - b _080201C0 - .align 2, 0 -_08020420: .4byte gLastUsedAbility -_08020424: .4byte gBattlescriptCurrInstr -_08020428: .4byte BattleScript_PRLZPrevention -_0802042C: - mov r0, r8 - adds r0, 0x4C - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - beq _0802043A - b _08020570 -_0802043A: - movs r4, 0x1 - mov r10, r4 - b _08020570 -_08020440: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - add r0, r8 - adds r0, 0x20 - ldrb r1, [r0] - cmp r1, 0x11 - bne _080204AE - cmp r4, 0x1 - beq _0802045A - cmp r5, 0x80 - bne _080204AE -_0802045A: - ldr r0, _08020494 @ =gLastUsedAbility - strb r1, [r0] - mov r1, r9 - ldrb r0, [r1] - movs r1, 0x11 - bl RecordAbilityBattle - ldr r4, _08020498 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _0802049C @ =BattleScript_PSNPrevention - str r0, [r4] - ldr r2, _080204A0 @ =gHitMarker - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 6 - ands r0, r1 - cmp r0, 0 - beq _080204A8 -_08020484: - movs r0, 0x1 - strb r0, [r6, 0x5] - ldr r0, _080204A4 @ =0xffffdfff - ands r1, r0 - str r1, [r2] - bl _0802110A - .align 2, 0 -_08020494: .4byte gLastUsedAbility -_08020498: .4byte gBattlescriptCurrInstr -_0802049C: .4byte BattleScript_PSNPrevention -_080204A0: .4byte gHitMarker -_080204A4: .4byte 0xffffdfff -_080204A8: - strb r0, [r6, 0x5] - bl _0802110A -_080204AE: - mov r2, r9 - ldrb r0, [r2] - movs r1, 0x58 - muls r0, r1 - add r0, r8 - adds r1, r0, 0 - adds r1, 0x21 - ldrb r1, [r1] - cmp r1, 0x3 - beq _080204D2 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x3 - beq _080204D2 - cmp r1, 0x8 - beq _080204D2 - cmp r0, 0x8 - bne _08020510 -_080204D2: - ldr r0, _08020500 @ =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - beq _08020510 - cmp r4, 0x1 - beq _080204E8 - cmp r5, 0x80 - bne _08020510 -_080204E8: - ldr r4, _08020504 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020508 @ =BattleScript_PSNPrevention -_080204F4: - str r0, [r4] - ldr r1, _0802050C @ =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - bl _0802110A - .align 2, 0 -_08020500: .4byte gHitMarker -_08020504: .4byte gBattlescriptCurrInstr -_08020508: .4byte BattleScript_PSNPrevention -_0802050C: .4byte gBattleCommunication -_08020510: - mov r3, r9 - ldrb r0, [r3] - movs r6, 0x58 - muls r0, r6 - mov r2, r8 - adds r2, 0x4C - adds r5, r0, r2 - ldr r4, [r5] - cmp r4, 0 - bne _08020570 - mov r3, r8 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r3, [r0] - cmp r3, 0x3 - beq _08020566 - adds r0, 0x1 - ldrb r0, [r0] - cmp r0, 0x3 - beq _08020566 - cmp r3, 0x8 - beq _08020566 - cmp r0, 0x8 - beq _08020566 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x11 - beq _08020570 - mov r4, r9 - ldrb r0, [r4] - adds r1, r0, 0 - muls r1, r6 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x9 - negs r2, r2 - ands r0, r2 - str r0, [r1] -_08020560: - movs r0, 0x1 - mov r10, r0 - b _08020570 -_08020566: - ldr r0, _080205B4 @ =gMoveResultFlags - ldrb r1, [r0] - movs r2, 0x8 - orrs r1, r2 - strb r1, [r0] -_08020570: - mov r1, r10 - cmp r1, 0x1 - beq _08020578 - b _08020694 -_08020578: - ldr r0, _080205B8 @ =gBattlescriptCurrInstr - ldr r0, [r0] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _080205BC @ =sStatusFlagsForMoveEffects - ldr r0, _080205C0 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r3, [r0] - cmp r3, 0x7 - bne _080205CC - bl Random - ldr r2, _080205C4 @ =gBattleMons - ldr r1, _080205C8 @ =gEffectBattler - ldrb r3, [r1] - movs r1, 0x58 - muls r3, r1 - adds r2, 0x4C - adds r3, r2 - movs r1, 0x3 - ands r1, r0 - adds r1, 0x2 - ldr r0, [r3] - orrs r0, r1 - str r0, [r3] - b _080205E0 - .align 2, 0 -_080205B4: .4byte gMoveResultFlags -_080205B8: .4byte gBattlescriptCurrInstr -_080205BC: .4byte sStatusFlagsForMoveEffects -_080205C0: .4byte gBattleCommunication -_080205C4: .4byte gBattleMons -_080205C8: .4byte gEffectBattler -_080205CC: - ldr r2, _08020630 @ =gBattleMons - ldr r0, _08020634 @ =gEffectBattler - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r2, 0x4C - adds r1, r2 - ldr r0, [r1] - orrs r0, r3 - str r0, [r1] -_080205E0: - ldr r2, _08020638 @ =gBattlescriptCurrInstr - ldr r1, _0802063C @ =sMoveEffectBS_Ptrs - ldr r5, _08020640 @ =gBattleCommunication - ldrb r0, [r5, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [r2] - ldr r4, _08020644 @ =gActiveBattler - ldr r1, _08020634 @ =gEffectBattler - ldrb r0, [r1] - strb r0, [r4] - ldrb r1, [r1] - movs r0, 0x58 - muls r0, r1 - ldr r1, _08020648 @ =gUnknown_2023C30 - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl BtlController_EmitSetMonData - ldrb r0, [r4] - bl MarkBattlerForControllerExec - ldr r2, _0802064C @ =gHitMarker - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 6 - ands r0, r1 - cmp r0, 0 - beq _08020654 - movs r0, 0x1 - strb r0, [r5, 0x5] - ldr r0, _08020650 @ =0xffffdfff - ands r1, r0 - str r1, [r2] - b _08020656 - .align 2, 0 -_08020630: .4byte gBattleMons -_08020634: .4byte gEffectBattler -_08020638: .4byte gBattlescriptCurrInstr -_0802063C: .4byte sMoveEffectBS_Ptrs -_08020640: .4byte gBattleCommunication -_08020644: .4byte gActiveBattler -_08020648: .4byte gUnknown_2023C30 -_0802064C: .4byte gHitMarker -_08020650: .4byte 0xffffdfff -_08020654: - strb r0, [r5, 0x5] -_08020656: - ldr r0, _08020688 @ =gBattleCommunication - ldrb r2, [r0, 0x3] - adds r6, r0, 0 - cmp r2, 0x2 - beq _08020670 - cmp r2, 0x6 - beq _08020670 - cmp r2, 0x5 - beq _08020670 - cmp r2, 0x3 - beq _08020670 - bl _0802110A -_08020670: - ldr r0, _0802068C @ =gBattleStruct - ldr r0, [r0] - adds r0, 0xB4 - ldrb r1, [r6, 0x3] - strb r1, [r0] - ldr r2, _08020690 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 7 - bl _08021008 - .align 2, 0 -_08020688: .4byte gBattleCommunication -_0802068C: .4byte gBattleStruct -_08020690: .4byte gHitMarker -_08020694: - mov r2, r10 - cmp r2, 0 - beq _0802069E - bl _0802110A -_0802069E: - bl _080210EC -_080206A2: - mov r3, r9 - ldrb r1, [r3] - movs r0, 0x58 - muls r1, r0 - mov r0, r8 - adds r0, 0x50 - adds r1, r0 - ldr r2, _080206DC @ =sStatusFlagsForMoveEffects - ldrb r3, [r6, 0x3] - lsls r0, r3, 2 - adds r0, r2 - ldr r1, [r1] - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _080206C6 - bl _080210EC -_080206C6: - subs r0, r3, 0x7 - cmp r0, 0x34 - bls _080206D0 - bl _0802110A -_080206D0: - lsls r0, 2 - ldr r1, _080206E0 @ =_080206E4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080206DC: .4byte sStatusFlagsForMoveEffects -_080206E0: .4byte _080206E4 - .align 2, 0 -_080206E4: - .4byte _080207B8 - .4byte _0802082C - .4byte _080209A0 - .4byte _080208B8 - .4byte _08020934 - .4byte _080209D8 - .4byte _08020A20 - .4byte _08020AEC - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B30 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020B74 - .4byte _08020C40 - .4byte _08020C88 - .4byte _08020CA8 - .4byte _08020E78 - .4byte _08020EB4 - .4byte _08020ED0 - .4byte _08020EE8 - .4byte _08020F00 - .4byte _08020F60 - .4byte _08020F78 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BB8 - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020BFC - .4byte _08020FBC - .4byte _08021018 - .4byte _0802110A - .4byte _0802110A - .4byte _0802110A - .4byte _0802110A - .4byte _080210FC -_080207B8: - mov r4, r9 - ldrb r0, [r4] - movs r5, 0x58 - adds r1, r0, 0 - muls r1, r5 - mov r2, r8 - adds r0, r1, r2 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x14 - bne _080207D2 - bl _080210EC -_080207D2: - mov r4, r8 - adds r4, 0x50 - adds r0, r1, r4 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _080207E6 - bl _080210EC -_080207E6: - bl Random - mov r3, r9 - ldrb r1, [r3] - adds r2, r1, 0 - muls r2, r5 - adds r2, r4 - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - lsrs r1, 16 - adds r1, 0x2 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - ldr r4, _08020820 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _08020824 @ =sMoveEffectBS_Ptrs - ldr r0, _08020828 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _08021108 - .align 2, 0 -_08020820: .4byte gBattlescriptCurrInstr -_08020824: .4byte sMoveEffectBS_Ptrs -_08020828: .4byte gBattleCommunication -_0802082C: - mov r0, r9 - ldrb r2, [r0] - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - add r0, r8 - adds r0, 0x20 - ldrb r1, [r0] - cmp r1, 0x27 - bne _08020870 - cmp r4, 0x1 - beq _0802084C - cmp r5, 0x80 - beq _0802084C - bl _080210EC -_0802084C: - ldr r0, _08020864 @ =gLastUsedAbility - strb r1, [r0] - mov r1, r9 - ldrb r0, [r1] - movs r1, 0x27 - bl RecordAbilityBattle - ldr r1, _08020868 @ =gBattlescriptCurrInstr - ldr r0, _0802086C @ =BattleScript_FlinchPrevention - str r0, [r1] - bl _0802110A - .align 2, 0 -_08020864: .4byte gLastUsedAbility -_08020868: .4byte gBattlescriptCurrInstr -_0802086C: .4byte BattleScript_FlinchPrevention -_08020870: - adds r0, r2, 0 - bl GetBattlerTurnOrderNum - ldr r1, _080208AC @ =gCurrentTurnActionNumber - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bhi _08020886 - bl _080210EC -_08020886: - mov r2, r9 - ldrb r0, [r2] - adds r2, r0, 0 - muls r2, r6 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r1, _080208B0 @ =sStatusFlagsForMoveEffects - ldr r0, _080208B4 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r1, [r2] - ldr r0, [r0] - orrs r1, r0 - str r1, [r2] - bl _080210EC - .align 2, 0 -_080208AC: .4byte gCurrentTurnActionNumber -_080208B0: .4byte sStatusFlagsForMoveEffects -_080208B4: .4byte gBattleCommunication -_080208B8: - mov r3, r9 - ldrb r0, [r3] - movs r5, 0x58 - muls r0, r5 - mov r4, r8 - adds r4, 0x50 - adds r2, r0, r4 - ldr r1, [r2] - movs r0, 0x70 - ands r0, r1 - cmp r0, 0 - beq _080208D4 - bl _080210EC -_080208D4: - movs r0, 0x80 - lsls r0, 5 - orrs r1, r0 - str r1, [r2] - ldr r1, _08020920 @ =gLockedMoves - ldrb r0, [r3] - lsls r0, 1 - adds r0, r1 - ldr r1, _08020924 @ =gCurrentMove - ldrh r1, [r1] - strh r1, [r0] - bl Random - mov r2, r9 - ldrb r1, [r2] - adds r2, r1, 0 - muls r2, r5 - adds r2, r4 - movs r1, 0x3 - ands r1, r0 - adds r1, 0x2 - lsls r1, 4 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - ldr r4, _08020928 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _0802092C @ =sMoveEffectBS_Ptrs - ldr r0, _08020930 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _08021108 - .align 2, 0 -_08020920: .4byte gLockedMoves -_08020924: .4byte gCurrentMove -_08020928: .4byte gBattlescriptCurrInstr -_0802092C: .4byte sMoveEffectBS_Ptrs -_08020930: .4byte gBattleCommunication -_08020934: - ldr r5, _08020984 @ =gBattlerAttacker - ldrb r0, [r5] - bl GetBattlerPosition - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - bne _0802096C - ldr r4, _08020988 @ =gPaydayMoney - ldrh r3, [r4] - ldr r2, _0802098C @ =gBattleMons - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2A - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - adds r0, r3, r0 - strh r0, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r3, r0 - bls _0802096C - ldr r3, _08020990 @ =0x0000ffff - adds r0, r3, 0 - strh r0, [r4] -_0802096C: - ldr r4, _08020994 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _08020998 @ =sMoveEffectBS_Ptrs - ldr r0, _0802099C @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - b _08021108 - .align 2, 0 -_08020984: .4byte gBattlerAttacker -_08020988: .4byte gPaydayMoney -_0802098C: .4byte gBattleMons -_08020990: .4byte 0x0000ffff -_08020994: .4byte gBattlescriptCurrInstr -_08020998: .4byte sMoveEffectBS_Ptrs -_0802099C: .4byte gBattleCommunication -_080209A0: - mov r4, r9 - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - mov r1, r8 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - cmp r0, 0 - beq _080209B6 - b _080210EC -_080209B6: - bl Random - ldr r4, _080209D4 @ =gBattleCommunication - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - adds r0, 0x3 - strb r0, [r4, 0x3] - movs r0, 0 - movs r1, 0 - bl SetMoveEffect - b _0802110A - .align 2, 0 -_080209D4: .4byte gBattleCommunication -_080209D8: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 5 - orrs r0, r1 - str r0, [r2] - ldr r1, _08020A14 @ =gLockedMoves - mov r2, r9 - ldrb r0, [r2] - lsls r0, 1 - adds r0, r1 - ldr r1, _08020A18 @ =gCurrentMove - ldrh r1, [r1] - strh r1, [r0] - ldr r0, _08020A1C @ =gProtectStructs - ldrb r1, [r2] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1, 0x1] - b _080210EC - .align 2, 0 -_08020A14: .4byte gLockedMoves -_08020A18: .4byte gCurrentMove -_08020A1C: .4byte gProtectStructs -_08020A20: - mov r3, r9 - ldrb r0, [r3] - movs r6, 0x58 - muls r0, r6 - mov r4, r8 - adds r4, 0x50 - adds r0, r4 - ldr r5, [r0] - movs r0, 0xE0 - lsls r0, 8 - ands r5, r0 - cmp r5, 0 - beq _08020A3C - b _080210EC -_08020A3C: - bl Random - mov r2, r9 - ldrb r1, [r2] - adds r2, r1, 0 - muls r2, r6 - adds r2, r4 - movs r1, 0x3 - ands r1, r0 - adds r1, 0x3 - lsls r1, 13 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - mov r3, r9 - ldrb r1, [r3] - ldr r2, _08020AD0 @ =gBattleStruct - ldr r0, [r2] - lsls r1, 1 - adds r1, r0 - ldr r6, _08020AD4 @ =gCurrentMove - ldrh r0, [r6] - strb r0, [r1, 0x4] - ldrb r1, [r3] - ldr r0, [r2] - lsls r1, 1 - adds r1, r0 - ldrh r0, [r6] - lsrs r0, 8 - strb r0, [r1, 0x5] - ldrb r1, [r3] - ldr r0, [r2] - adds r1, r0 - ldr r0, _08020AD8 @ =gBattlerAttacker - ldrb r0, [r0] - strb r0, [r1, 0x14] - ldr r4, _08020ADC @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _08020AE0 @ =sMoveEffectBS_Ptrs - ldr r2, _08020AE4 @ =gBattleCommunication - ldrb r0, [r2, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - str r0, [r4] - strb r5, [r2, 0x5] - ldr r3, _08020AE8 @ =gTrappingMoves - ldrh r0, [r3] - ldrh r4, [r6] - cmp r0, r4 - bne _08020AAA - b _0802110A -_08020AAA: - adds r1, r2, 0 - adds r2, r6, 0 -_08020AAE: - ldrb r0, [r1, 0x5] - adds r0, 0x1 - strb r0, [r1, 0x5] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bls _08020ABE - b _0802110A -_08020ABE: - ldrb r0, [r1, 0x5] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - ldrh r4, [r2] - cmp r0, r4 - bne _08020AAE - b _0802110A - .align 2, 0 -_08020AD0: .4byte gBattleStruct -_08020AD4: .4byte gCurrentMove -_08020AD8: .4byte gBattlerAttacker -_08020ADC: .4byte gBattlescriptCurrInstr -_08020AE0: .4byte sMoveEffectBS_Ptrs -_08020AE4: .4byte gBattleCommunication -_08020AE8: .4byte gTrappingMoves -_08020AEC: - ldr r1, _08020B1C @ =gBattleMoveDamage - ldr r0, _08020B20 @ =gHpDealt - ldr r0, [r0] - cmp r0, 0 - bge _08020AF8 - adds r0, 0x3 -_08020AF8: - asrs r0, 2 - str r0, [r1] - cmp r0, 0 - bne _08020B04 - movs r0, 0x1 - str r0, [r1] -_08020B04: - ldr r4, _08020B24 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _08020B28 @ =sMoveEffectBS_Ptrs - ldr r0, _08020B2C @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - b _08021108 - .align 2, 0 -_08020B1C: .4byte gBattleMoveDamage -_08020B20: .4byte gHpDealt -_08020B24: .4byte gBattlescriptCurrInstr -_08020B28: .4byte sMoveEffectBS_Ptrs -_08020B2C: .4byte gBattleCommunication -_08020B30: - ldrb r1, [r6, 0x3] - adds r1, 0xF2 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x10 - adds r2, r7, 0 - movs r3, 0 - bl ChangeStatBuffs - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _08020B4C - b _080210EC -_08020B4C: - ldr r2, _08020B68 @ =gBattleScripting - ldrb r1, [r6, 0x3] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2, 0x10] - strb r3, [r2, 0x11] - ldr r4, _08020B6C @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020B70 @ =BattleScript_StatUp - b _08021108 - .align 2, 0 -_08020B68: .4byte gBattleScripting -_08020B6C: .4byte gBattlescriptCurrInstr -_08020B70: .4byte BattleScript_StatUp -_08020B74: - movs r0, 0x70 - negs r0, r0 - ldrb r1, [r6, 0x3] - adds r1, 0xEB - lsls r1, 24 - lsrs r1, 24 - adds r2, r7, 0 - movs r3, 0 - bl ChangeStatBuffs - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _08020B92 - b _080210EC -_08020B92: - ldr r2, _08020BAC @ =gBattleScripting - ldrb r1, [r6, 0x3] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2, 0x10] - strb r3, [r2, 0x11] - ldr r4, _08020BB0 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020BB4 @ =BattleScript_StatDown - b _08021108 - .align 2, 0 -_08020BAC: .4byte gBattleScripting -_08020BB0: .4byte gBattlescriptCurrInstr -_08020BB4: .4byte BattleScript_StatDown -_08020BB8: - ldrb r1, [r6, 0x3] - adds r1, 0xDA - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x20 - adds r2, r7, 0 - movs r3, 0 - bl ChangeStatBuffs - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _08020BD4 - b _080210EC -_08020BD4: - ldr r2, _08020BF0 @ =gBattleScripting - ldrb r1, [r6, 0x3] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2, 0x10] - strb r3, [r2, 0x11] - ldr r4, _08020BF4 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020BF8 @ =BattleScript_StatUp - b _08021108 - .align 2, 0 -_08020BF0: .4byte gBattleScripting -_08020BF4: .4byte gBattlescriptCurrInstr -_08020BF8: .4byte BattleScript_StatUp -_08020BFC: - movs r0, 0x60 - negs r0, r0 - ldrb r1, [r6, 0x3] - adds r1, 0xD3 - lsls r1, 24 - lsrs r1, 24 - adds r2, r7, 0 - movs r3, 0 - bl ChangeStatBuffs - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _08020C1A - b _080210EC -_08020C1A: - ldr r2, _08020C34 @ =gBattleScripting - ldrb r1, [r6, 0x3] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2, 0x10] - strb r3, [r2, 0x11] - ldr r4, _08020C38 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020C3C @ =BattleScript_StatDown - b _08021108 - .align 2, 0 -_08020C34: .4byte gBattleScripting -_08020C38: .4byte gBattlescriptCurrInstr -_08020C3C: .4byte BattleScript_StatDown -_08020C40: - mov r0, r9 - ldrb r1, [r0] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 15 - orrs r0, r1 - str r0, [r2] - ldr r2, _08020C7C @ =gDisableStructs - mov r3, r9 - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x2 - strb r1, [r0, 0x19] - ldr r1, _08020C80 @ =gLockedMoves - ldrb r0, [r3] - lsls r0, 1 - adds r0, r1 - ldr r1, _08020C84 @ =gCurrentMove - ldrh r1, [r1] - strh r1, [r0] - b _080210EC - .align 2, 0 -_08020C7C: .4byte gDisableStructs -_08020C80: .4byte gLockedMoves -_08020C84: .4byte gCurrentMove -_08020C88: - ldr r0, _08020CA4 @ =gBattlerAttacker - ldrb r1, [r0] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 16 -_08020C9E: - orrs r0, r1 - str r0, [r2] - b _080210EC - .align 2, 0 -_08020CA4: .4byte gBattlerAttacker -_08020CA8: - ldr r5, _08020D64 @ =gBattleTypeFlags - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 12 - ands r0, r1 - cmp r0, 0 - beq _08020CB8 - b _080210EC -_08020CB8: - ldr r4, _08020D68 @ =gBattlerAttacker - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - lsrs r6, r0, 24 - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08020CEA - ldr r0, [r5] - ldr r1, _08020D6C @ =0x00000902 - ands r0, r1 - cmp r0, 0 - bne _08020D26 - ldr r0, _08020D70 @ =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - beq _08020CEA - b _080210EC -_08020CEA: - ldr r0, _08020D64 @ =gBattleTypeFlags - ldr r0, [r0] - ldr r1, _08020D6C @ =0x00000902 - ands r0, r1 - cmp r0, 0 - bne _08020D26 - ldr r0, _08020D70 @ =gTrainerBattleOpponent_A - ldrh r1, [r0] - movs r0, 0x80 - lsls r0, 3 - cmp r1, r0 - beq _08020D26 - ldr r0, _08020D74 @ =gWishFutureKnock - adds r0, 0x29 - adds r0, r6, r0 - ldrb r1, [r0] - ldr r3, _08020D78 @ =gBitTable - ldr r2, _08020D7C @ =gBattlerPartyIndexes - ldr r0, _08020D68 @ =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _08020D26 - b _080210EC -_08020D26: - ldr r2, _08020D80 @ =gBattleMons - ldr r1, _08020D84 @ =gBattlerTarget - ldrb r0, [r1] - movs r3, 0x58 - muls r0, r3 - adds r4, r0, r2 - ldrh r0, [r4, 0x2E] - adds r7, r1, 0 - mov r8, r2 - cmp r0, 0 - beq _08020D94 - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x3C - bne _08020D94 - ldr r1, _08020D88 @ =gBattlescriptCurrInstr - ldr r0, _08020D8C @ =BattleScript_StickyHoldActivates - str r0, [r1] - ldr r1, _08020D90 @ =gLastUsedAbility - ldrb r0, [r7] - muls r0, r3 - add r0, r8 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r7] - ldrb r1, [r1] - bl RecordAbilityBattle - b _0802110A - .align 2, 0 -_08020D64: .4byte gBattleTypeFlags -_08020D68: .4byte gBattlerAttacker -_08020D6C: .4byte 0x00000902 -_08020D70: .4byte gTrainerBattleOpponent_A -_08020D74: .4byte gWishFutureKnock -_08020D78: .4byte gBitTable -_08020D7C: .4byte gBattlerPartyIndexes -_08020D80: .4byte gBattleMons -_08020D84: .4byte gBattlerTarget -_08020D88: .4byte gBattlescriptCurrInstr -_08020D8C: .4byte BattleScript_StickyHoldActivates -_08020D90: .4byte gLastUsedAbility -_08020D94: - ldr r4, _08020E60 @ =gBattlerAttacker - mov r10, r4 - ldrb r2, [r4] - movs r0, 0x58 - mov r9, r0 - mov r0, r9 - muls r0, r2 - add r0, r8 - ldrh r4, [r0, 0x2E] - cmp r4, 0 - beq _08020DAC - b _080210EC -_08020DAC: - ldrb r0, [r7] - mov r1, r9 - muls r1, r0 - adds r0, r1, 0 - add r0, r8 - ldrh r3, [r0, 0x2E] - adds r1, r3, 0 - cmp r1, 0xAF - bne _08020DC0 - b _080210EC -_08020DC0: - adds r0, r3, 0 - subs r0, 0x79 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xB - bhi _08020DCE - b _080210EC -_08020DCE: - cmp r1, 0 - bne _08020DD4 - b _080210EC -_08020DD4: - ldr r5, _08020E64 @ =gBattleStruct - lsls r0, r2, 1 - adds r0, 0xD0 - ldr r1, [r5] - adds r1, r0 - ldr r2, _08020E68 @ =gLastUsedItem - strh r3, [r1] - strh r3, [r2] - ldrb r0, [r7] - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - add r0, r8 - movs r6, 0 - strh r4, [r0, 0x2E] - ldr r4, _08020E6C @ =gActiveBattler - mov r1, r10 - ldrb r0, [r1] - strb r0, [r4] - str r2, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - movs r3, 0x2 - bl BtlController_EmitSetMonData - mov r2, r10 - ldrb r0, [r2] - bl MarkBattlerForControllerExec - ldrb r0, [r7] - strb r0, [r4] - ldrb r0, [r7] - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - 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 BtlController_EmitSetMonData - ldrb r0, [r7] - bl MarkBattlerForControllerExec - ldr r4, _08020E70 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020E74 @ =BattleScript_ItemSteal - str r0, [r4] - ldrb r0, [r7] - ldr r1, [r5] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - strb r6, [r0] - ldrb r0, [r7] - ldr r1, [r5] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - strb r6, [r0] - b _0802110A - .align 2, 0 -_08020E60: .4byte gBattlerAttacker -_08020E64: .4byte gBattleStruct -_08020E68: .4byte gLastUsedItem -_08020E6C: .4byte gActiveBattler -_08020E70: .4byte gBattlescriptCurrInstr -_08020E74: .4byte BattleScript_ItemSteal -_08020E78: - ldr r3, _08020EA8 @ =gBattlerTarget - ldrb r1, [r3] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 19 - orrs r0, r1 - str r0, [r2] - ldr r2, _08020EAC @ =gDisableStructs - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, _08020EB0 @ =gBattlerAttacker - ldrb r1, [r1] - strb r1, [r0, 0x14] - b _080210EC - .align 2, 0 -_08020EA8: .4byte gBattlerTarget -_08020EAC: .4byte gDisableStructs -_08020EB0: .4byte gBattlerAttacker -_08020EB4: - ldr r0, _08020ECC @ =gBattlerTarget - ldrb r1, [r0] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - mov r0, r8 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 20 - b _08020C9E - .align 2, 0 -_08020ECC: .4byte gBattlerTarget -_08020ED0: - ldr r4, _08020EE0 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020EE4 @ =BattleScript_AllStatsUp - b _08021108 - .align 2, 0 -_08020EE0: .4byte gBattlescriptCurrInstr -_08020EE4: .4byte BattleScript_AllStatsUp -_08020EE8: - ldr r4, _08020EF8 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020EFC @ =BattleScript_RapidSpinAway - b _08021108 - .align 2, 0 -_08020EF8: .4byte gBattlescriptCurrInstr -_08020EFC: .4byte BattleScript_RapidSpinAway -_08020F00: - ldr r6, _08020F50 @ =gBattlerTarget - ldrb r0, [r6] - movs r2, 0x58 - muls r0, r2 - mov r1, r8 - adds r1, 0x4C - adds r5, r0, r1 - ldr r4, [r5] - movs r0, 0x40 - ands r0, r4 - cmp r0, 0 - bne _08020F1A - b _080210EC -_08020F1A: - movs r0, 0x41 - negs r0, r0 - ands r4, r0 - str r4, [r5] - ldr r4, _08020F54 @ =gActiveBattler - ldrb r0, [r6] - strb r0, [r4] - ldrb r0, [r4] - muls r0, r2 - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl BtlController_EmitSetMonData - ldrb r0, [r4] - bl MarkBattlerForControllerExec - ldr r4, _08020F58 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020F5C @ =BattleScript_TargetPRLZHeal - b _08021108 - .align 2, 0 -_08020F50: .4byte gBattlerTarget -_08020F54: .4byte gActiveBattler -_08020F58: .4byte gBattlescriptCurrInstr -_08020F5C: .4byte BattleScript_TargetPRLZHeal -_08020F60: - ldr r4, _08020F70 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08020F74 @ =BattleScript_AtkDefDown - b _08021108 - .align 2, 0 -_08020F70: .4byte gBattlescriptCurrInstr -_08020F74: .4byte BattleScript_AtkDefDown -_08020F78: - ldr r4, _08020FA8 @ =gBattleMoveDamage - ldr r0, _08020FAC @ =gHpDealt - ldr r0, [r0] - movs r1, 0x3 - bl __divsi3 - str r0, [r4] - cmp r0, 0 - bne _08020F8E - movs r0, 0x1 - str r0, [r4] -_08020F8E: - ldr r4, _08020FB0 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r1, _08020FB4 @ =sMoveEffectBS_Ptrs - ldr r0, _08020FB8 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - b _08021108 - .align 2, 0 -_08020FA8: .4byte gBattleMoveDamage -_08020FAC: .4byte gHpDealt -_08020FB0: .4byte gBattlescriptCurrInstr -_08020FB4: .4byte sMoveEffectBS_Ptrs -_08020FB8: .4byte gBattleCommunication -_08020FBC: - mov r4, r9 - ldrb r0, [r4] - movs r5, 0x58 - muls r0, r5 - mov r4, r8 - adds r4, 0x50 - adds r2, r0, r4 - ldr r1, [r2] - movs r0, 0xC0 - lsls r0, 4 - ands r0, r1 - cmp r0, 0 - beq _08020FD8 - b _080210EC -_08020FD8: - movs r0, 0x80 - lsls r0, 5 - orrs r1, r0 - str r1, [r2] - ldr r1, _08021010 @ =gLockedMoves - mov r2, r9 - ldrb r0, [r2] - lsls r0, 1 - adds r0, r1 - ldr r1, _08021014 @ =gCurrentMove - ldrh r1, [r1] - strh r1, [r0] - bl Random - mov r3, r9 - ldrb r1, [r3] - adds r2, r1, 0 - muls r2, r5 - adds r2, r4 - movs r1, 0x1 - ands r1, r0 - adds r1, 0x2 - lsls r1, 10 - ldr r0, [r2] -_08021008: - orrs r0, r1 - str r0, [r2] - b _0802110A - .align 2, 0 -_08021010: .4byte gLockedMoves -_08021014: .4byte gCurrentMove -_08021018: - mov r5, r9 - ldrb r3, [r5] - movs r4, 0x58 - adds r0, r3, 0 - muls r0, r4 - mov r2, r8 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r2, [r0] - cmp r2, 0x3C - bne _08021058 - ldrh r0, [r1, 0x2E] - cmp r0, 0 - beq _080210EC - ldr r0, _0802104C @ =gLastUsedAbility - strb r2, [r0] - ldr r1, _08021050 @ =gBattlescriptCurrInstr - ldr r0, _08021054 @ =BattleScript_StickyHoldActivates - str r0, [r1] - ldrb r0, [r5] - movs r1, 0x3C - bl RecordAbilityBattle - b _0802110A - .align 2, 0 -_0802104C: .4byte gLastUsedAbility -_08021050: .4byte gBattlescriptCurrInstr -_08021054: .4byte BattleScript_StickyHoldActivates -_08021058: - ldrh r0, [r1, 0x2E] - cmp r0, 0 - beq _080210EC - adds r0, r3, 0 - bl GetBattlerSide - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, _080210D0 @ =gLastUsedItem - mov r3, r9 - ldrb r0, [r3] - muls r0, r4 - add r0, r8 - ldrh r0, [r0, 0x2E] - strh r0, [r1] - ldrb r0, [r3] - muls r0, r4 - add r0, r8 - movs r5, 0 - movs r1, 0 - strh r1, [r0, 0x2E] - ldr r2, _080210D4 @ =gWishFutureKnock - adds r2, 0x29 - adds r2, r6, r2 - ldr r3, _080210D8 @ =gBitTable - ldr r1, _080210DC @ =gBattlerPartyIndexes - mov r4, r9 - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r4, _080210E0 @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _080210E4 @ =BattleScript_KnockedOff - str r0, [r4] - mov r1, r9 - ldrb r0, [r1] - ldr r2, _080210E8 @ =gBattleStruct - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - strb r5, [r0] - mov r3, r9 - ldrb r0, [r3] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - strb r5, [r0] - b _0802110A - .align 2, 0 -_080210D0: .4byte gLastUsedItem -_080210D4: .4byte gWishFutureKnock -_080210D8: .4byte gBitTable -_080210DC: .4byte gBattlerPartyIndexes -_080210E0: .4byte gBattlescriptCurrInstr -_080210E4: .4byte BattleScript_KnockedOff -_080210E8: .4byte gBattleStruct -_080210EC: - ldr r1, _080210F8 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - b _0802110A - .align 2, 0 -_080210F8: .4byte gBattlescriptCurrInstr -_080210FC: - ldr r4, _0802111C @ =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, _08021120 @ =BattleScript_SAtkDown2 -_08021108: - str r0, [r4] -_0802110A: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_0802111C: .4byte gBattlescriptCurrInstr -_08021120: .4byte BattleScript_SAtkDown2 - thumb_func_end SetMoveEffect - - thumb_func_start atk15_seteffectwithchance -atk15_seteffectwithchance: @ 8021124 - push {r4,lr} - ldr r2, _08021150 @ =gBattleMons - ldr r0, _08021154 @ =gBattlerAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x20 - bne _08021160 - ldr r2, _08021158 @ =gBattleMoves - ldr r0, _0802115C @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x5] - lsls r4, r0, 1 - b _08021170 - .align 2, 0 -_08021150: .4byte gBattleMons -_08021154: .4byte gBattlerAttacker -_08021158: .4byte gBattleMoves -_0802115C: .4byte gCurrentMove -_08021160: - ldr r2, _08021190 @ =gBattleMoves - ldr r0, _08021194 @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r4, [r0, 0x5] -_08021170: - ldr r3, _08021198 @ =gBattleCommunication - ldrb r2, [r3, 0x3] - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - beq _080211A0 - ldr r0, _0802119C @ =gMoveResultFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - bne _080211A0 - movs r0, 0x7F - ands r0, r2 - strb r0, [r3, 0x3] - b _080211CE - .align 2, 0 -_08021190: .4byte gBattleMoves -_08021194: .4byte gCurrentMove -_08021198: .4byte gBattleCommunication -_0802119C: .4byte gMoveResultFlags -_080211A0: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r4 - bhi _080211EA - ldr r0, _080211D8 @ =gBattleCommunication - ldrb r0, [r0, 0x3] - cmp r0, 0 - beq _080211EA - ldr r0, _080211DC @ =gMoveResultFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - bne _080211EA - cmp r4, 0x63 - bls _080211E0 -_080211CE: - movs r0, 0 - movs r1, 0x80 - bl SetMoveEffect - b _080211F2 - .align 2, 0 -_080211D8: .4byte gBattleCommunication -_080211DC: .4byte gMoveResultFlags -_080211E0: - movs r0, 0 - movs r1, 0 - bl SetMoveEffect - b _080211F2 -_080211EA: - ldr r1, _08021204 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_080211F2: - ldr r0, _08021208 @ =gBattleCommunication - movs r1, 0 - strb r1, [r0, 0x3] - ldr r0, _0802120C @ =gBattleScripting - strb r1, [r0, 0x16] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08021204: .4byte gBattlescriptCurrInstr -_08021208: .4byte gBattleCommunication -_0802120C: .4byte gBattleScripting - thumb_func_end atk15_seteffectwithchance - - thumb_func_start atk16_seteffectprimary -atk16_seteffectprimary: @ 8021210 - push {lr} - movs r0, 0x1 - movs r1, 0 - bl SetMoveEffect - pop {r0} - bx r0 - thumb_func_end atk16_seteffectprimary - - thumb_func_start atk17_seteffectsecondary -atk17_seteffectsecondary: @ 8021220 - push {lr} - movs r0, 0 - movs r1, 0 - bl SetMoveEffect - pop {r0} - bx r0 - thumb_func_end atk17_seteffectsecondary - - thumb_func_start atk18_clearstatusfromeffect -atk18_clearstatusfromeffect: @ 8021230 - push {lr} - ldr r0, _08021254 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - ldr r2, _08021258 @ =gActiveBattler - strb r0, [r2] - ldr r3, _0802125C @ =gBattleCommunication - ldrb r0, [r3, 0x3] - cmp r0, 0x6 - bhi _08021264 - ldr r1, _08021260 @ =gBattleMons - ldrb r2, [r2] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x4C - b _0802126E - .align 2, 0 -_08021254: .4byte gBattlescriptCurrInstr -_08021258: .4byte gActiveBattler -_0802125C: .4byte gBattleCommunication -_08021260: .4byte gBattleMons -_08021264: - ldr r1, _08021298 @ =gBattleMons - ldrb r2, [r2] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x50 -_0802126E: - adds r2, r1 - ldr r1, _0802129C @ =sStatusFlagsForMoveEffects - ldrb r0, [r3, 0x3] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - ldr r0, _080212A0 @ =gBattleCommunication - movs r2, 0 - strb r2, [r0, 0x3] - ldr r1, _080212A4 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - ldr r0, _080212A8 @ =gBattleScripting - strb r2, [r0, 0x16] - pop {r0} - bx r0 - .align 2, 0 -_08021298: .4byte gBattleMons -_0802129C: .4byte sStatusFlagsForMoveEffects -_080212A0: .4byte gBattleCommunication -_080212A4: .4byte gBattlescriptCurrInstr -_080212A8: .4byte gBattleScripting - thumb_func_end atk18_clearstatusfromeffect - - thumb_func_start atk19_tryfaintmon -atk19_tryfaintmon: @ 80212AC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - ldr r0, _08021318 @ =gBattlescriptCurrInstr - ldr r2, [r0] - ldrb r1, [r2, 0x2] - adds r6, r0, 0 - cmp r1, 0 - beq _08021330 - ldrb r0, [r2, 0x1] - bl GetBattlerForBattleScript - ldr r5, _0802131C @ =gActiveBattler - strb r0, [r5] - ldr r2, _08021320 @ =gHitMarker - ldr r1, _08021324 @ =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - ands r0, r1 - cmp r0, 0 - bne _080212E4 - b _0802158C -_080212E4: - ldr r1, [r6] - ldrb r4, [r1, 0x3] - ldrb r0, [r1, 0x4] - lsls r0, 8 - orrs r4, r0 - ldrb r0, [r1, 0x5] - lsls r0, 16 - orrs r4, r0 - ldrb r0, [r1, 0x6] - lsls r0, 24 - orrs r4, r0 - bl BattleScriptPop - str r4, [r6] - ldrb r0, [r5] - bl GetBattlerSide - ldr r1, _08021328 @ =gSideStatuses - lsls r0, 24 - lsrs r0, 23 - adds r0, r1 - ldrh r2, [r0] - ldr r1, _0802132C @ =0x0000fdff - ands r1, r2 - strh r1, [r0] - b _08021592 - .align 2, 0 -_08021318: .4byte gBattlescriptCurrInstr -_0802131C: .4byte gActiveBattler -_08021320: .4byte gHitMarker -_08021324: .4byte gBitTable -_08021328: .4byte gSideStatuses -_0802132C: .4byte 0x0000fdff -_08021330: - ldrb r0, [r2, 0x1] - cmp r0, 0x1 - bne _08021358 - ldr r1, _08021348 @ =gActiveBattler - ldr r0, _0802134C @ =gBattlerAttacker - ldrb r0, [r0] - strb r0, [r1] - ldr r0, _08021350 @ =gBattlerTarget - ldrb r0, [r0] - mov r9, r0 - ldr r4, _08021354 @ =BattleScript_FaintAttacker - b _08021368 - .align 2, 0 -_08021348: .4byte gActiveBattler -_0802134C: .4byte gBattlerAttacker -_08021350: .4byte gBattlerTarget -_08021354: .4byte BattleScript_FaintAttacker -_08021358: - ldr r1, _080213D0 @ =gActiveBattler - ldr r0, _080213D4 @ =gBattlerTarget - ldrb r0, [r0] - strb r0, [r1] - ldr r0, _080213D8 @ =gBattlerAttacker - ldrb r0, [r0] - mov r9, r0 - ldr r4, _080213DC @ =BattleScript_FaintTarget -_08021368: - mov r8, r1 - ldr r0, _080213E0 @ =gAbsentBattlerFlags - ldrb r1, [r0] - ldr r2, _080213E4 @ =gBitTable - mov r7, r8 - ldrb r3, [r7] - lsls r0, r3, 2 - adds r0, r2 - ldr r2, [r0] - ands r1, r2 - cmp r1, 0 - beq _08021382 - b _0802158C -_08021382: - ldr r1, _080213E8 @ =gBattleMons - movs r0, 0x58 - muls r0, r3 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08021392 - b _0802158C -_08021392: - ldr r5, _080213EC @ =gHitMarker - lsls r1, r2, 28 - ldr r0, [r5] - orrs r0, r1 - str r0, [r5] - ldr r0, [r6] - adds r0, 0x7 - bl BattleScriptPush - str r4, [r6] - ldrb r0, [r7] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _080213F4 - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 15 - orrs r0, r1 - str r0, [r5] - ldr r1, _080213F0 @ =gBattleResults - ldrb r0, [r1] - cmp r0, 0xFE - bhi _080213C8 - adds r0, 0x1 - strb r0, [r1] -_080213C8: - ldrb r0, [r7] - bl AdjustFriendshipOnBattleFaint - b _0802142C - .align 2, 0 -_080213D0: .4byte gActiveBattler -_080213D4: .4byte gBattlerTarget -_080213D8: .4byte gBattlerAttacker -_080213DC: .4byte BattleScript_FaintTarget -_080213E0: .4byte gAbsentBattlerFlags -_080213E4: .4byte gBitTable -_080213E8: .4byte gBattleMons -_080213EC: .4byte gHitMarker -_080213F0: .4byte gBattleResults -_080213F4: - ldr r4, _0802154C @ =gBattleResults - ldrb r0, [r4, 0x1] - cmp r0, 0xFE - bhi _08021400 - adds r0, 0x1 - strb r0, [r4, 0x1] -_08021400: - ldr r1, _08021550 @ =gBattlerPartyIndexes - mov r2, r8 - ldrb r0, [r2] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021554 @ =gEnemyParty - adds r0, r1 - movs r1, 0xB - bl GetMonData - strh r0, [r4, 0x20] - ldr r0, _08021558 @ =gBattleStruct - ldr r0, [r0] - movs r3, 0xC1 - lsls r3, 1 - adds r1, r0, r3 - ldr r0, _0802155C @ =gBattlerAttacker - ldrb r0, [r0] - strb r0, [r1] -_0802142C: - ldr r2, _08021560 @ =gHitMarker - ldr r1, [r2] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0802146A - ldr r6, _08021564 @ =gBattleMons - ldr r0, _0802155C @ =gBattlerAttacker - ldrb r0, [r0] - movs r5, 0x58 - muls r0, r5 - adds r0, r6 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0802146A - movs r0, 0x41 - negs r0, r0 - ands r1, r0 - str r1, [r2] - ldr r4, _08021568 @ =gBattlescriptCurrInstr - ldr r0, [r4] - bl BattleScriptPush - ldr r1, _0802156C @ =gBattleMoveDamage - mov r0, r9 - muls r0, r5 - adds r0, r6 - ldrh r0, [r0, 0x28] - str r0, [r1] - ldr r0, _08021570 @ =BattleScript_DestinyBondTakesLife - str r0, [r4] -_0802146A: - ldr r1, _08021574 @ =gStatuses3 - ldr r6, _08021578 @ =gBattlerTarget - ldrb r0, [r6] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 7 - ands r0, r1 - cmp r0, 0 - bne _08021482 - b _08021592 -_08021482: - ldr r0, _08021560 @ =gHitMarker - ldr r5, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r5, r0 - cmp r5, 0 - beq _08021492 - b _08021592 -_08021492: - ldr r0, _0802155C @ =gBattlerAttacker - mov r8, r0 - ldrb r0, [r0] - bl GetBattlerSide - adds r4, r0, 0 - ldrb r0, [r6] - bl GetBattlerSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _08021592 - ldr r1, _08021564 @ =gBattleMons - mov r9, r1 - mov r2, r8 - ldrb r1, [r2] - movs r7, 0x58 - adds r2, r1, 0 - muls r2, r7 - mov r3, r9 - adds r0, r2, r3 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08021592 - ldr r0, _0802157C @ =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xA5 - beq _08021592 - ldr r0, _08021558 @ =gBattleStruct - ldr r0, [r0] - adds r0, r1, r0 - adds r0, 0x80 - ldrb r4, [r0] - adds r0, r4, r2 - mov r6, r9 - adds r6, 0x24 - adds r0, r6 - strb r5, [r0] - ldr r5, _08021568 @ =gBattlescriptCurrInstr - ldr r0, [r5] - bl BattleScriptPush - ldr r0, _08021580 @ =BattleScript_GrudgeTakesPp - str r0, [r5] - ldr r5, _08021584 @ =gActiveBattler - mov r1, r8 - ldrb r0, [r1] - strb r0, [r5] - adds r1, r4, 0 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - ldrb r0, [r5] - muls r0, r7 - adds r0, r6 - adds r0, r4 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl BtlController_EmitSetMonData - ldrb r0, [r5] - bl MarkBattlerForControllerExec - ldr r1, _08021588 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - lsls r4, 1 - mov r2, r8 - ldrb r0, [r2] - muls r0, r7 - adds r0, r4, r0 - mov r2, r9 - adds r2, 0xC - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1, 0x2] - mov r3, r8 - ldrb r0, [r3] - muls r0, r7 - adds r4, r0 - adds r4, r2 - ldrh r0, [r4] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - b _08021592 - .align 2, 0 -_0802154C: .4byte gBattleResults -_08021550: .4byte gBattlerPartyIndexes -_08021554: .4byte gEnemyParty -_08021558: .4byte gBattleStruct -_0802155C: .4byte gBattlerAttacker -_08021560: .4byte gHitMarker -_08021564: .4byte gBattleMons -_08021568: .4byte gBattlescriptCurrInstr -_0802156C: .4byte gBattleMoveDamage -_08021570: .4byte BattleScript_DestinyBondTakesLife -_08021574: .4byte gStatuses3 -_08021578: .4byte gBattlerTarget -_0802157C: .4byte gCurrentMove -_08021580: .4byte BattleScript_GrudgeTakesPp -_08021584: .4byte gActiveBattler -_08021588: .4byte gBattleTextBuff1 -_0802158C: - ldr r0, [r6] - adds r0, 0x7 - str r0, [r6] -_08021592: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atk19_tryfaintmon - - thumb_func_start atk1A_dofaintanimation -atk1A_dofaintanimation: @ 80215A0 - push {r4,r5,lr} - ldr r0, _080215D0 @ =gBattleControllerExecFlags - ldr r0, [r0] - cmp r0, 0 - bne _080215CA - ldr r5, _080215D4 @ =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - ldr r4, _080215D8 @ =gActiveBattler - strb r0, [r4] - movs r0, 0 - bl BtlController_EmitFaintAnimation - ldrb r0, [r4] - bl MarkBattlerForControllerExec - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] -_080215CA: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080215D0: .4byte gBattleControllerExecFlags -_080215D4: .4byte gBattlescriptCurrInstr -_080215D8: .4byte gActiveBattler - thumb_func_end atk1A_dofaintanimation - - thumb_func_start atk1B_cleareffectsonfaint -atk1B_cleareffectsonfaint: @ 80215DC - push {r4-r6,lr} - sub sp, 0x4 - ldr r0, _08021630 @ =gBattleControllerExecFlags - ldr r6, [r0] - cmp r6, 0 - bne _08021628 - ldr r5, _08021634 @ =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - ldr r4, _08021638 @ =gActiveBattler - strb r0, [r4] - ldr r1, _0802163C @ =gBattleMons - ldrb r0, [r4] - movs r2, 0x58 - muls r0, r2 - adds r1, 0x4C - adds r0, r1 - str r6, [r0] - ldrb r0, [r4] - muls r0, r2 - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl BtlController_EmitSetMonData - ldrb r0, [r4] - bl MarkBattlerForControllerExec - bl sub_8012BC8 - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] -_08021628: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08021630: .4byte gBattleControllerExecFlags -_08021634: .4byte gBattlescriptCurrInstr -_08021638: .4byte gActiveBattler -_0802163C: .4byte gBattleMons - thumb_func_end atk1B_cleareffectsonfaint - - thumb_func_start atk1C_jumpifstatus -atk1C_jumpifstatus: @ 8021640 - push {r4,r5,lr} - ldr r5, _0802169C @ =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - lsls r0, 24 - lsrs r0, 24 - ldr r2, [r5] - ldrb r4, [r2, 0x2] - ldrb r1, [r2, 0x3] - lsls r1, 8 - adds r4, r1 - ldrb r1, [r2, 0x4] - lsls r1, 16 - adds r4, r1 - ldrb r1, [r2, 0x5] - lsls r1, 24 - adds r4, r1 - ldrb r3, [r2, 0x6] - ldrb r1, [r2, 0x7] - lsls r1, 8 - adds r3, r1 - ldrb r1, [r2, 0x8] - lsls r1, 16 - adds r3, r1 - ldrb r1, [r2, 0x9] - lsls r1, 24 - adds r3, r1 - ldr r2, _080216A0 @ =gBattleMons - movs r1, 0x58 - muls r1, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r1, r0 - ldr r0, [r0] - ands r0, r4 - cmp r0, 0 - beq _080216A4 - adds r0, r1, r2 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _080216A4 - str r3, [r5] - b _080216AC - .align 2, 0 -_0802169C: .4byte gBattlescriptCurrInstr -_080216A0: .4byte gBattleMons -_080216A4: - ldr r1, _080216B4 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0xA - str r0, [r1] -_080216AC: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080216B4: .4byte gBattlescriptCurrInstr - thumb_func_end atk1C_jumpifstatus - - thumb_func_start atk1D_jumpifstatus2 -atk1D_jumpifstatus2: @ 80216B8 - push {r4,r5,lr} - ldr r5, _08021714 @ =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - lsls r0, 24 - lsrs r0, 24 - ldr r2, [r5] - ldrb r4, [r2, 0x2] - ldrb r1, [r2, 0x3] - lsls r1, 8 - adds r4, r1 - ldrb r1, [r2, 0x4] - lsls r1, 16 - adds r4, r1 - ldrb r1, [r2, 0x5] - lsls r1, 24 - adds r4, r1 - ldrb r3, [r2, 0x6] - ldrb r1, [r2, 0x7] - lsls r1, 8 - adds r3, r1 - ldrb r1, [r2, 0x8] - lsls r1, 16 - adds r3, r1 - ldrb r1, [r2, 0x9] - lsls r1, 24 - adds r3, r1 - ldr r2, _08021718 @ =gBattleMons - movs r1, 0x58 - muls r1, r0 - adds r0, r2, 0 - adds r0, 0x50 - adds r0, r1, r0 - ldr r0, [r0] - ands r0, r4 - cmp r0, 0 - beq _0802171C - adds r0, r1, r2 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0802171C - str r3, [r5] - b _08021724 - .align 2, 0 -_08021714: .4byte gBattlescriptCurrInstr -_08021718: .4byte gBattleMons -_0802171C: - ldr r1, _0802172C @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0xA - str r0, [r1] -_08021724: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0802172C: .4byte gBattlescriptCurrInstr - thumb_func_end atk1D_jumpifstatus2 - - thumb_func_start atk1E_jumpifability -atk1E_jumpifability: @ 8021730 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - ldr r6, _08021784 @ =gBattlescriptCurrInstr - ldr r2, [r6] - ldrb r5, [r2, 0x2] - mov r8, r5 - ldrb r1, [r2, 0x3] - ldrb r0, [r2, 0x4] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r2, 0x6] - lsls r0, 24 - adds r7, r1, r0 - ldrb r0, [r2, 0x1] - cmp r0, 0x8 - bne _08021790 - ldr r0, _08021788 @ =gBattlerAttacker - ldrb r1, [r0] - movs r0, 0 - str r0, [sp] - movs r0, 0xD - adds r2, r5, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08021804 - ldr r1, _0802178C @ =gLastUsedAbility - strb r5, [r1] - str r7, [r6] - subs r4, 0x1 - lsls r0, r4, 24 - lsrs r0, 24 - ldrb r1, [r1] - b _080217EC - .align 2, 0 -_08021784: .4byte gBattlescriptCurrInstr -_08021788: .4byte gBattlerAttacker -_0802178C: .4byte gLastUsedAbility -_08021790: - cmp r0, 0x9 - bne _080217C8 - ldr r0, _080217C0 @ =gBattlerAttacker - ldrb r1, [r0] - movs r0, 0 - str r0, [sp] - movs r0, 0xC - adds r2, r5, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08021804 - ldr r1, _080217C4 @ =gLastUsedAbility - strb r5, [r1] - str r7, [r6] - subs r4, 0x1 - lsls r0, r4, 24 - lsrs r0, 24 - ldrb r1, [r1] - b _080217EC - .align 2, 0 -_080217C0: .4byte gBattlerAttacker -_080217C4: .4byte gLastUsedAbility -_080217C8: - ldrb r0, [r2, 0x1] - bl GetBattlerForBattleScript - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _080217F8 @ =gBattleMons - movs r0, 0x58 - muls r0, r4 - adds r0, r1 - adds r0, 0x20 - ldrb r1, [r0] - cmp r1, r8 - bne _08021804 - ldr r0, _080217FC @ =gLastUsedAbility - strb r1, [r0] - str r7, [r6] - ldrb r1, [r0] - adds r0, r4, 0 -_080217EC: - bl RecordAbilityBattle - ldr r0, _08021800 @ =gBattleScripting - strb r4, [r0, 0x15] - b _0802180A - .align 2, 0 -_080217F8: .4byte gBattleMons -_080217FC: .4byte gLastUsedAbility -_08021800: .4byte gBattleScripting -_08021804: - ldr r0, [r6] - adds r0, 0x7 - str r0, [r6] -_0802180A: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atk1E_jumpifability - - thumb_func_start atk1F_jumpifsideaffecting -atk1F_jumpifsideaffecting: @ 8021818 - push {r4-r6,lr} - ldr r0, _08021830 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r4, [r0, 0x1] - cmp r4, 0x1 - bne _08021838 - ldr r0, _08021834 @ =gBattlerAttacker - ldrb r0, [r0] - bl GetBattlerPosition - b _08021842 - .align 2, 0 -_08021830: .4byte gBattlescriptCurrInstr -_08021834: .4byte gBattlerAttacker -_08021838: - ldr r0, _08021878 @ =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerPosition - movs r4, 0x1 -_08021842: - ands r4, r0 - ldr r6, _0802187C @ =gBattlescriptCurrInstr - ldr r3, [r6] - ldrb r2, [r3, 0x2] - ldrb r0, [r3, 0x3] - lsls r0, 8 - orrs r2, r0 - ldrb r1, [r3, 0x4] - ldrb r0, [r3, 0x5] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r3, 0x6] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r3, 0x7] - lsls r0, 24 - adds r5, r1, r0 - ldr r1, _08021880 @ =gSideStatuses - lsls r0, r4, 1 - adds r0, r1 - ldrh r0, [r0] - ands r2, r0 - cmp r2, 0 - beq _08021884 - str r5, [r6] - b _0802188A - .align 2, 0 -_08021878: .4byte gBattlerTarget -_0802187C: .4byte gBattlescriptCurrInstr -_08021880: .4byte gSideStatuses -_08021884: - adds r0, r3, 0 - adds r0, 0x8 - str r0, [r6] -_0802188A: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end atk1F_jumpifsideaffecting - - thumb_func_start atk20_jumpifstat -atk20_jumpifstat: @ 8021890 - push {r4,r5,lr} - movs r5, 0 - ldr r4, _080218C4 @ =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - lsls r0, 24 - lsrs r0, 24 - ldr r2, _080218C8 @ =gBattleMons - ldr r3, [r4] - movs r1, 0x58 - muls r0, r1 - ldrb r1, [r3, 0x3] - adds r0, r1 - adds r2, 0x18 - adds r0, r2 - ldrb r2, [r0] - ldrb r0, [r3, 0x2] - cmp r0, 0x5 - bhi _0802194E - lsls r0, 2 - ldr r1, _080218CC @ =_080218D0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080218C4: .4byte gBattlescriptCurrInstr -_080218C8: .4byte gBattleMons -_080218CC: .4byte _080218D0 - .align 2, 0 -_080218D0: - .4byte _080218E8 - .4byte _080218F8 - .4byte _08021908 - .4byte _08021918 - .4byte _08021928 - .4byte _0802193C -_080218E8: - ldr r0, _080218F4 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r2, r0 - bne _0802194E - b _08021948 - .align 2, 0 -_080218F4: .4byte gBattlescriptCurrInstr -_080218F8: - ldr r0, _08021904 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r2, r0 - beq _0802194E - b _08021948 - .align 2, 0 -_08021904: .4byte gBattlescriptCurrInstr -_08021908: - ldr r0, _08021914 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r2, r0 - bls _0802194E - b _08021948 - .align 2, 0 -_08021914: .4byte gBattlescriptCurrInstr -_08021918: - ldr r0, _08021924 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r2, r0 - bcs _0802194E - b _08021948 - .align 2, 0 -_08021924: .4byte gBattlescriptCurrInstr -_08021928: - ldr r0, _08021938 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - ands r2, r0 - cmp r2, 0 - beq _0802194E - b _08021948 - .align 2, 0 -_08021938: .4byte gBattlescriptCurrInstr -_0802193C: - ldr r0, _08021970 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x4] - ands r2, r0 - cmp r2, 0 - bne _0802194E -_08021948: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 -_0802194E: - cmp r5, 0 - beq _08021974 - ldr r3, _08021970 @ =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x5] - ldrb r0, [r2, 0x6] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0x7] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r2, 0x8] - lsls r0, 24 - adds r1, r0 - str r1, [r3] - b _0802197C - .align 2, 0 -_08021970: .4byte gBattlescriptCurrInstr -_08021974: - ldr r1, _08021984 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x9 - str r0, [r1] -_0802197C: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08021984: .4byte gBattlescriptCurrInstr - thumb_func_end atk20_jumpifstat - - thumb_func_start atk21_jumpifstatus3condition -atk21_jumpifstatus3condition: @ 8021988 - push {r4-r6,lr} - ldr r4, _080219DC @ =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - ldr r5, _080219E0 @ =gActiveBattler - strb r0, [r5] - ldr r2, [r4] - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - adds r6, r1, r0 - ldrb r1, [r2, 0x7] - ldrb r0, [r2, 0x8] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0x9] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r2, 0xA] - lsls r0, 24 - adds r3, r1, r0 - ldrb r0, [r2, 0x6] - cmp r0, 0 - beq _080219E8 - ldr r0, _080219E4 @ =gStatuses3 - ldrb r1, [r5] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - ands r0, r6 - cmp r0, 0 - bne _08021A00 - b _080219F8 - .align 2, 0 -_080219DC: .4byte gBattlescriptCurrInstr -_080219E0: .4byte gActiveBattler -_080219E4: .4byte gStatuses3 -_080219E8: - ldr r0, _080219FC @ =gStatuses3 - ldrb r1, [r5] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - ands r0, r6 - cmp r0, 0 - beq _08021A00 -_080219F8: - str r3, [r4] - b _08021A06 - .align 2, 0 -_080219FC: .4byte gStatuses3 -_08021A00: - adds r0, r2, 0 - adds r0, 0xB - str r0, [r4] -_08021A06: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end atk21_jumpifstatus3condition - - thumb_func_start atk22_jumpiftype -atk22_jumpiftype: @ 8021A0C - push {r4-r6,lr} - ldr r4, _08021A54 @ =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - lsls r0, 24 - lsrs r0, 24 - ldr r3, [r4] - ldrb r5, [r3, 0x2] - ldrb r2, [r3, 0x3] - ldrb r1, [r3, 0x4] - lsls r1, 8 - adds r2, r1 - ldrb r1, [r3, 0x5] - lsls r1, 16 - adds r2, r1 - ldrb r1, [r3, 0x6] - lsls r1, 24 - adds r6, r2, r1 - ldr r2, _08021A58 @ =gBattleMons - movs r1, 0x58 - muls r0, r1 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, r5 - beq _08021A50 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, r5 - bne _08021A5C -_08021A50: - str r6, [r4] - b _08021A60 - .align 2, 0 -_08021A54: .4byte gBattlescriptCurrInstr -_08021A58: .4byte gBattleMons -_08021A5C: - adds r0, r3, 0x7 - str r0, [r4] -_08021A60: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end atk22_jumpiftype - - thumb_func_start atk23_getexp -atk23_getexp: @ 8021A68 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r6, 0 - ldr r0, _08021AB0 @ =gBattleStruct - ldr r0, [r0] - adds r0, 0x50 - mov r9, r0 - ldr r0, _08021AB4 @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattlerForBattleScript - ldr r1, _08021AB8 @ =gBattlerFainted - strb r0, [r1] - ldr r2, _08021ABC @ =gSentPokesToOpponent - movs r1, 0x2 - ands r1, r0 - lsls r1, 24 - lsrs r1, 25 - adds r1, r2 - ldrb r1, [r1] - mov r8, r1 - ldr r0, _08021AC0 @ =gBattleScripting - ldrb r0, [r0, 0x1C] - cmp r0, 0x6 - bls _08021AA4 - bl _080223DA -_08021AA4: - lsls r0, 2 - ldr r1, _08021AC4 @ =_08021AC8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08021AB0: .4byte gBattleStruct -_08021AB4: .4byte gBattlescriptCurrInstr -_08021AB8: .4byte gBattlerFainted -_08021ABC: .4byte gSentPokesToOpponent -_08021AC0: .4byte gBattleScripting -_08021AC4: .4byte _08021AC8 - .align 2, 0 -_08021AC8: - .4byte _08021AE4 - .4byte _08021B50 - .4byte _08021C6A - .4byte _08021F78 - .4byte _0802207C - .4byte _08022368 - .4byte _080223B0 -_08021AE4: - ldr r4, _08021B34 @ =gBattlerFainted - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08021AF8 - bl _080223A4 -_08021AF8: - ldr r0, _08021B38 @ =gBattleTypeFlags - ldr r0, [r0] - ldr r1, _08021B3C @ =0x00080982 - ands r0, r1 - cmp r0, 0 - beq _08021B08 - bl _080223A4 -_08021B08: - ldr r1, _08021B40 @ =gBattleScripting - ldrb r0, [r1, 0x1C] - adds r0, 0x1 - strb r0, [r1, 0x1C] - ldr r0, _08021B44 @ =gBattleStruct - ldr r2, [r0] - adds r2, 0xDF - ldr r3, _08021B48 @ =gBitTable - ldr r1, _08021B4C @ =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - bl _080223DA - .align 2, 0 -_08021B34: .4byte gBattlerFainted -_08021B38: .4byte gBattleTypeFlags -_08021B3C: .4byte 0x00080982 -_08021B40: .4byte gBattleScripting -_08021B44: .4byte gBattleStruct -_08021B48: .4byte gBitTable -_08021B4C: .4byte gBattlerPartyIndexes -_08021B50: - movs r5, 0 - movs r7, 0 -_08021B54: - movs r0, 0x64 - adds r1, r7, 0 - muls r1, r0 - ldr r0, _08021BA4 @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08021BC2 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08021BC2 - ldr r0, _08021BA8 @ =gBitTable - lsls r1, r7, 2 - adds r1, r0 - ldr r0, [r1] - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _08021B88 - adds r5, 0x1 -_08021B88: - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xAF - bne _08021BB4 - ldr r0, _08021BAC @ =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, _08021BB0 @ =0x0000311a - adds r0, r2 - ldrb r4, [r0] - b _08021BBC - .align 2, 0 -_08021BA4: .4byte gPlayerParty -_08021BA8: .4byte gBitTable -_08021BAC: .4byte gSaveBlock1Ptr -_08021BB0: .4byte 0x0000311a -_08021BB4: - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r4, r0, 24 -_08021BBC: - cmp r4, 0x19 - bne _08021BC2 - adds r6, 0x1 -_08021BC2: - adds r7, 0x1 - cmp r7, 0x5 - ble _08021B54 - ldr r3, _08021C28 @ =gBaseStats - ldr r2, _08021C2C @ =gBattleMons - ldr r0, _08021C30 @ =gBattlerFainted - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r1, r2 - ldrh r2, [r1] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r3 - ldrb r2, [r0, 0x9] - adds r1, 0x2A - ldrb r0, [r1] - muls r0, r2 - movs r1, 0x7 - bl __divsi3 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r6, 0 - beq _08021C38 - lsrs r4, r0, 17 - adds r0, r4, 0 - adds r1, r5, 0 - bl __divsi3 - mov r1, r9 - strh r0, [r1] - lsls r0, 16 - cmp r0, 0 - bne _08021C0E - movs r0, 0x1 - strh r0, [r1] -_08021C0E: - ldr r5, _08021C34 @ =gExpShareExp - adds r0, r4, 0 - adds r1, r6, 0 - bl __divsi3 - strh r0, [r5] - lsls r0, 16 - cmp r0, 0 - bne _08021C52 - movs r0, 0x1 - strh r0, [r5] - b _08021C52 - .align 2, 0 -_08021C28: .4byte gBaseStats -_08021C2C: .4byte gBattleMons -_08021C30: .4byte gBattlerFainted -_08021C34: .4byte gExpShareExp -_08021C38: - adds r0, r1, 0 - adds r1, r5, 0 - bl __divsi3 - mov r2, r9 - strh r0, [r2] - lsls r0, 16 - cmp r0, 0 - bne _08021C4E - movs r0, 0x1 - strh r0, [r2] -_08021C4E: - ldr r0, _08021C9C @ =gExpShareExp - strh r6, [r0] -_08021C52: - ldr r1, _08021CA0 @ =gBattleScripting - ldrb r0, [r1, 0x1C] - adds r0, 0x1 - movs r2, 0 - strb r0, [r1, 0x1C] - ldr r1, _08021CA4 @ =gBattleStruct - ldr r0, [r1] - strb r2, [r0, 0x10] - ldr r0, [r1] - adds r0, 0x53 - mov r4, r8 - strb r4, [r0] -_08021C6A: - ldr r0, _08021CA8 @ =gBattleControllerExecFlags - ldr r0, [r0] - cmp r0, 0 - beq _08021C74 - b _080223DA -_08021C74: - ldr r0, _08021CA4 @ =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021CAC @ =gPlayerParty - adds r0, r1 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xAF - bne _08021CB8 - ldr r0, _08021CB0 @ =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, _08021CB4 @ =0x0000311a - adds r0, r1 - ldrb r4, [r0] - b _08021CC0 - .align 2, 0 -_08021C9C: .4byte gExpShareExp -_08021CA0: .4byte gBattleScripting -_08021CA4: .4byte gBattleStruct -_08021CA8: .4byte gBattleControllerExecFlags -_08021CAC: .4byte gPlayerParty -_08021CB0: .4byte gSaveBlock1Ptr -_08021CB4: .4byte 0x0000311a -_08021CB8: - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r4, r0, 24 -_08021CC0: - ldr r5, _08021CE0 @ =gBattleStruct - cmp r4, 0x19 - beq _08021CE8 - ldr r0, [r5] - adds r1, r0, 0 - adds r1, 0x53 - ldrb r0, [r1] - movs r2, 0x1 - ands r2, r0 - cmp r2, 0 - bne _08021CE8 - lsrs r0, 1 - strb r0, [r1] - ldr r1, _08021CE4 @ =gBattleScripting - b _08021D0C - .align 2, 0 -_08021CE0: .4byte gBattleStruct -_08021CE4: .4byte gBattleScripting -_08021CE8: - ldr r0, [r5] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021D18 @ =gPlayerParty - adds r0, r1 - movs r1, 0x38 - bl GetMonData - cmp r0, 0x64 - bne _08021D24 - ldr r1, [r5] - adds r1, 0x53 - ldrb r0, [r1] - lsrs r0, 1 - strb r0, [r1] - ldr r1, _08021D1C @ =gBattleScripting - movs r2, 0 -_08021D0C: - movs r0, 0x5 - strb r0, [r1, 0x1C] - ldr r0, _08021D20 @ =gBattleMoveDamage - str r2, [r0] - b _080223DA - .align 2, 0 -_08021D18: .4byte gPlayerParty -_08021D1C: .4byte gBattleScripting -_08021D20: .4byte gBattleMoveDamage -_08021D24: - ldr r0, _08021D88 @ =gBattleTypeFlags - ldr r0, [r0] - ldr r1, _08021D8C @ =0x00010008 - ands r0, r1 - cmp r0, 0 - bne _08021D52 - ldr r0, _08021D90 @ =gBattleMons - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08021D52 - ldr r0, [r5] - ldrb r0, [r0, 0x12] - cmp r0, 0 - bne _08021D52 - bl BattleStopLowHpSound - ldr r0, _08021D94 @ =0x00000137 - bl PlayBGM - ldr r1, [r5] - ldrb r0, [r1, 0x12] - adds r0, 0x1 - strb r0, [r1, 0x12] -_08021D52: - ldr r5, _08021D98 @ =gBattleStruct - ldr r0, [r5] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021D9C @ =gPlayerParty - adds r0, r1 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - bne _08021D6C - b _08021F4C -_08021D6C: - ldr r0, [r5] - adds r0, 0x53 - ldrb r0, [r0] - movs r3, 0x1 - ands r3, r0 - cmp r3, 0 - beq _08021DA4 - ldr r1, _08021DA0 @ =gBattleMoveDamage - mov r2, r9 - ldrh r0, [r2] - str r0, [r1] - mov r9, r1 - b _08021DAA - .align 2, 0 -_08021D88: .4byte gBattleTypeFlags -_08021D8C: .4byte 0x00010008 -_08021D90: .4byte gBattleMons -_08021D94: .4byte 0x00000137 -_08021D98: .4byte gBattleStruct -_08021D9C: .4byte gPlayerParty -_08021DA0: .4byte gBattleMoveDamage -_08021DA4: - ldr r0, _08021E28 @ =gBattleMoveDamage - str r3, [r0] - mov r9, r0 -_08021DAA: - cmp r4, 0x19 - bne _08021DBA - ldr r0, _08021E2C @ =gExpShareExp - ldrh r1, [r0] - mov r2, r9 - ldr r0, [r2] - adds r0, r1 - str r0, [r2] -_08021DBA: - cmp r4, 0x28 - bne _08021DCE - mov r4, r9 - ldr r1, [r4] - movs r0, 0x96 - muls r0, r1 - movs r1, 0x64 - bl __divsi3 - str r0, [r4] -_08021DCE: - ldr r5, _08021E30 @ =gBattleTypeFlags - ldr r0, [r5] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - beq _08021DEA - ldr r4, _08021E28 @ =gBattleMoveDamage - ldr r1, [r4] - movs r0, 0x96 - muls r0, r1 - movs r1, 0x64 - bl __divsi3 - str r0, [r4] -_08021DEA: - ldr r0, _08021E34 @ =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021E38 @ =gPlayerParty - adds r0, r1 - bl IsTradedMon - lsls r0, 24 - cmp r0, 0 - beq _08021E3C - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 9 - ands r0, r1 - cmp r0, 0 - bne _08021E3C - ldr r4, _08021E28 @ =gBattleMoveDamage - ldr r1, [r4] - movs r0, 0x96 - muls r0, r1 - movs r1, 0x64 - bl __divsi3 - str r0, [r4] - movs r7, 0xA5 - lsls r7, 1 - mov r9, r4 - b _08021E42 - .align 2, 0 -_08021E28: .4byte gBattleMoveDamage -_08021E2C: .4byte gExpShareExp -_08021E30: .4byte gBattleTypeFlags -_08021E34: .4byte gBattleStruct -_08021E38: .4byte gPlayerParty -_08021E3C: - ldr r7, _08021E78 @ =0x00000149 - ldr r0, _08021E7C @ =gBattleMoveDamage - mov r9, r0 -_08021E42: - ldr r0, _08021E80 @ =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x1 - ands r1, r0 - cmp r1, 0 - beq _08021EAE - ldr r0, _08021E84 @ =gBattlerPartyIndexes - ldr r1, _08021E88 @ =gBattleStruct - ldr r4, [r1] - ldrh r0, [r0, 0x4] - adds r5, r1, 0 - ldr r3, _08021E8C @ =gBitTable - ldr r2, _08021E90 @ =gAbsentBattlerFlags - ldrb r1, [r4, 0x10] - cmp r0, r1 - bne _08021E94 - ldrb r1, [r2] - ldr r0, [r3, 0x8] - ands r1, r0 - cmp r1, 0 - bne _08021E94 - adds r1, r4, 0 - adds r1, 0x8F - movs r0, 0x2 - strb r0, [r1] - b _08021EB6 - .align 2, 0 -_08021E78: .4byte 0x00000149 -_08021E7C: .4byte gBattleMoveDamage -_08021E80: .4byte gBattleTypeFlags -_08021E84: .4byte gBattlerPartyIndexes -_08021E88: .4byte gBattleStruct -_08021E8C: .4byte gBitTable -_08021E90: .4byte gAbsentBattlerFlags -_08021E94: - ldrb r2, [r2] - ldr r0, [r3] - ands r2, r0 - cmp r2, 0 - bne _08021EA6 - ldr r0, [r5] - adds r0, 0x8F - strb r2, [r0] - b _08021EB6 -_08021EA6: - ldr r0, [r5] - adds r0, 0x8F - movs r1, 0x2 - b _08021EB4 -_08021EAE: - ldr r0, _08021F5C @ =gBattleStruct - ldr r0, [r0] - adds r0, 0x8F -_08021EB4: - strb r1, [r0] -_08021EB6: - ldr r1, _08021F60 @ =gBattleTextBuff1 - movs r2, 0 - mov r12, r2 - movs r3, 0xFD - strb r3, [r1] - movs r5, 0x4 - strb r5, [r1, 0x1] - ldr r6, _08021F5C @ =gBattleStruct - ldr r2, [r6] - movs r4, 0x8F - adds r4, r2 - mov r8, r4 - ldrb r0, [r4] - strb r0, [r1, 0x2] - ldrb r0, [r2, 0x10] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, _08021F64 @ =gBattleTextBuff2 - strb r3, [r1] - mov r0, r12 - strb r0, [r1, 0x1] - strb r7, [r1, 0x2] - movs r4, 0xFF - lsls r4, 8 - ands r7, r4 - asrs r0, r7, 8 - strb r0, [r1, 0x3] - movs r0, 0x1 - negs r0, r0 - strb r0, [r1, 0x4] - ldr r1, _08021F68 @ =gBattleTextBuff3 - strb r3, [r1] - movs r0, 0x1 - strb r0, [r1, 0x1] - strb r5, [r1, 0x2] - movs r0, 0x5 - strb r0, [r1, 0x3] - mov r0, r9 - ldr r2, [r0] - strb r2, [r1, 0x4] - adds r0, r2, 0 - ands r0, r4 - asrs r0, 8 - strb r0, [r1, 0x5] - movs r0, 0xFF - lsls r0, 16 - ands r0, r2 - asrs r0, 16 - strb r0, [r1, 0x6] - lsrs r2, 24 - strb r2, [r1, 0x7] - movs r0, 0x1 - negs r0, r0 - strb r0, [r1, 0x8] - mov r2, r8 - ldrb r1, [r2] - movs r0, 0xD - bl PrepareStringBattle - ldr r0, [r6] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, _08021F6C @ =gPlayerParty - adds r0, r1 - ldr r3, _08021F70 @ =gBattleMons - ldr r1, _08021F74 @ =gBattlerFainted - ldrb r2, [r1] - movs r1, 0x58 - muls r1, r2 - adds r1, r3 - ldrh r1, [r1] - bl MonGainEVs -_08021F4C: - ldr r0, _08021F5C @ =gBattleStruct - ldr r1, [r0] - adds r1, 0x53 - ldrb r0, [r1] - lsrs r0, 1 - strb r0, [r1] - b _08022052 - .align 2, 0 -_08021F5C: .4byte gBattleStruct -_08021F60: .4byte gBattleTextBuff1 -_08021F64: .4byte gBattleTextBuff2 -_08021F68: .4byte gBattleTextBuff3 -_08021F6C: .4byte gPlayerParty -_08021F70: .4byte gBattleMons -_08021F74: .4byte gBattlerFainted -_08021F78: - ldr r0, _0802205C @ =gBattleControllerExecFlags - ldr r2, [r0] - cmp r2, 0 - beq _08021F82 - b _080223DA -_08021F82: - ldr r1, _08022060 @ =gBattleBufferB - ldr r7, _08022064 @ =gBattleStruct - ldr r0, [r7] - adds r0, 0x8F - ldrb r0, [r0] - lsls r0, 9 - adds r0, r1 - strb r2, [r0] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - movs r6, 0x64 - muls r0, r6 - ldr r5, _08022068 @ =gPlayerParty - adds r0, r5 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08022052 - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x38 - bl GetMonData - cmp r0, 0x64 - beq _08022052 - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3A - bl GetMonData - ldr r4, _0802206C @ =gBattleResources - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3B - bl GetMonData - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1, 0x2] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3C - bl GetMonData - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1, 0x4] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3D - bl GetMonData - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1, 0x6] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3E - bl GetMonData - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1, 0x8] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0x3F - bl GetMonData - ldr r1, [r4] - ldr r1, [r1, 0x10] - strh r0, [r1, 0xA] - ldr r4, _08022070 @ =gActiveBattler - ldr r1, [r7] - adds r0, r1, 0 - adds r0, 0x8F - ldrb r0, [r0] - strb r0, [r4] - ldrb r1, [r1, 0x10] - ldr r0, _08022074 @ =gBattleMoveDamage - ldrh r2, [r0] - movs r0, 0 - bl BtlController_EmitExpUpdate - ldrb r0, [r4] - bl MarkBattlerForControllerExec -_08022052: - ldr r1, _08022078 @ =gBattleScripting - ldrb r0, [r1, 0x1C] - adds r0, 0x1 - strb r0, [r1, 0x1C] - b _080223DA - .align 2, 0 -_0802205C: .4byte gBattleControllerExecFlags -_08022060: .4byte gBattleBufferB -_08022064: .4byte gBattleStruct -_08022068: .4byte gPlayerParty -_0802206C: .4byte gBattleResources -_08022070: .4byte gActiveBattler -_08022074: .4byte gBattleMoveDamage -_08022078: .4byte gBattleScripting -_0802207C: - ldr r0, _08022314 @ =gBattleControllerExecFlags - ldr r0, [r0] - cmp r0, 0 - beq _08022086 - b _080223DA -_08022086: - ldr r1, _08022318 @ =gActiveBattler - ldr r0, _0802231C @ =gBattleStruct - ldr r4, [r0] - adds r0, r4, 0 - adds r0, 0x8F - ldrb r0, [r0] - strb r0, [r1] - ldr r3, _08022320 @ =gBattleBufferB - ldrb r2, [r1] - lsls r1, r2, 9 - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, 0x21 - beq _080220A4 - b _08022350 -_080220A4: - adds r0, r3, 0x1 - adds r0, r1, r0 - ldrb r0, [r0] - cmp r0, 0xB - beq _080220B0 - b _08022350 -_080220B0: - ldr r0, _08022324 @ =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - beq _080220DA - ldr r0, _08022328 @ =gBattlerPartyIndexes - lsls r1, r2, 1 - adds r1, r0 - ldrh r0, [r1] - ldrb r4, [r4, 0x10] - cmp r0, r4 - bne _080220DA - adds r1, r0, 0 - movs r0, 0x64 - muls r0, r1 - ldr r1, _0802232C @ =gPlayerParty - adds r0, r1 - adds r1, r2, 0 - bl HandleLowHpMusicChange -_080220DA: - ldr r1, _08022330 @ =gBattleTextBuff1 - movs r3, 0xFD - strb r3, [r1] - movs r0, 0x4 - strb r0, [r1, 0x1] - ldr r6, _08022318 @ =gActiveBattler - ldrb r0, [r6] - strb r0, [r1, 0x2] - ldr r4, _0802231C @ =gBattleStruct - mov r9, r4 - ldr r2, [r4] - ldrb r0, [r2, 0x10] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r4, _08022334 @ =gBattleTextBuff2 - strb r3, [r4] - movs r0, 0x1 - strb r0, [r4, 0x1] - strb r0, [r4, 0x2] - movs r0, 0x3 - strb r0, [r4, 0x3] - ldrb r0, [r2, 0x10] - movs r1, 0x64 - mov r8, r1 - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - ldr r7, _0802232C @ =gPlayerParty - adds r0, r7 - movs r1, 0x38 - bl GetMonData - strb r0, [r4, 0x4] - movs r0, 0x1 - negs r0, r0 - strb r0, [r4, 0x5] - bl BattleScriptPushCursor - ldr r2, _08022338 @ =gLeveledUpInBattle - ldr r1, _0802233C @ =gBitTable - mov r4, r9 - ldr r5, [r4] - ldrb r0, [r5, 0x10] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r1, _08022340 @ =gBattlescriptCurrInstr - ldr r0, _08022344 @ =BattleScript_LevelUp - str r0, [r1] - ldr r4, _08022348 @ =gBattleMoveDamage - ldr r2, _08022320 @ =gBattleBufferB - ldrb r1, [r6] - lsls r1, 9 - adds r0, r2, 0x2 - adds r0, r1, r0 - ldrb r3, [r0] - adds r2, 0x3 - adds r1, r2 - ldrb r0, [r1] - lsls r0, 8 - orrs r3, r0 - str r3, [r4] - ldrb r0, [r5, 0x10] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r7 - movs r1, 0 - bl AdjustFriendship - ldr r1, _08022328 @ =gBattlerPartyIndexes - mov r2, r9 - ldr r0, [r2] - ldrb r2, [r0, 0x10] - ldrh r0, [r1] - cmp r0, r2 - bne _08022246 - ldr r4, _0802234C @ =gBattleMons - ldrh r0, [r4, 0x28] - cmp r0, 0 - beq _08022246 - mov r0, r8 - muls r0, r2 - adds r0, r7 - movs r1, 0x38 - bl GetMonData - adds r1, r4, 0 - adds r1, 0x2A - strb r0, [r1] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x39 - bl GetMonData - strh r0, [r4, 0x28] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3A - bl GetMonData - strh r0, [r4, 0x2C] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3B - bl GetMonData - strh r0, [r4, 0x2] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3C - bl GetMonData - strh r0, [r4, 0x4] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3D - bl GetMonData - strh r0, [r4, 0x6] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3D - bl GetMonData - strh r0, [r4, 0x6] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3E - bl GetMonData - strh r0, [r4, 0x8] - mov r1, r9 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r7 - movs r1, 0x3F - bl GetMonData - strh r0, [r4, 0xA] -_08022246: - ldr r0, _08022328 @ =gBattlerPartyIndexes - ldr r7, _0802231C @ =gBattleStruct - ldr r1, [r7] - ldrb r2, [r1, 0x10] - ldrh r0, [r0, 0x4] - cmp r0, r2 - beq _08022256 - b _08022356 -_08022256: - ldr r6, _0802234C @ =gBattleMons - movs r4, 0xD8 - adds r4, r6 - mov r8, r4 - ldrh r0, [r4] - cmp r0, 0 - beq _08022356 - ldr r0, _08022324 @ =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08022356 - movs r5, 0x64 - adds r0, r2, 0 - muls r0, r5 - ldr r4, _0802232C @ =gPlayerParty - adds r0, r4 - movs r1, 0x38 - bl GetMonData - adds r1, r6, 0 - adds r1, 0xDA - strb r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x39 - bl GetMonData - mov r1, r8 - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3A - bl GetMonData - adds r1, r6, 0 - adds r1, 0xDC - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3B - bl GetMonData - adds r1, r6, 0 - adds r1, 0xB2 - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3C - bl GetMonData - adds r1, r6, 0 - adds r1, 0xB4 - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3D - bl GetMonData - movs r2, 0xB6 - adds r2, r6 - mov r8, r2 - strh r0, [r2] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3D - bl GetMonData - mov r1, r8 - strh r0, [r1] - ldr r0, [r7] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - movs r1, 0x3E - bl GetMonData - adds r1, r6, 0 - adds r1, 0xB8 - strh r0, [r1] - b _08022356 - .align 2, 0 -_08022314: .4byte gBattleControllerExecFlags -_08022318: .4byte gActiveBattler -_0802231C: .4byte gBattleStruct -_08022320: .4byte gBattleBufferB -_08022324: .4byte gBattleTypeFlags -_08022328: .4byte gBattlerPartyIndexes -_0802232C: .4byte gPlayerParty -_08022330: .4byte gBattleTextBuff1 -_08022334: .4byte gBattleTextBuff2 -_08022338: .4byte gLeveledUpInBattle -_0802233C: .4byte gBitTable -_08022340: .4byte gBattlescriptCurrInstr -_08022344: .4byte BattleScript_LevelUp -_08022348: .4byte gBattleMoveDamage -_0802234C: .4byte gBattleMons -_08022350: - ldr r1, _08022360 @ =gBattleMoveDamage - movs r0, 0 - str r0, [r1] -_08022356: - ldr r1, _08022364 @ =gBattleScripting - movs r0, 0x5 - strb r0, [r1, 0x1C] - b _080223DA - .align 2, 0 -_08022360: .4byte gBattleMoveDamage -_08022364: .4byte gBattleScripting -_08022368: - ldr r0, _08022378 @ =gBattleMoveDamage - ldr r0, [r0] - cmp r0, 0 - beq _08022380 - ldr r1, _0802237C @ =gBattleScripting - movs r0, 0x3 - strb r0, [r1, 0x1C] - b _080223DA - .align 2, 0 -_08022378: .4byte gBattleMoveDamage -_0802237C: .4byte gBattleScripting -_08022380: - ldr r2, _0802239C @ =gBattleStruct - ldr r1, [r2] - ldrb r0, [r1, 0x10] - adds r0, 0x1 - strb r0, [r1, 0x10] - ldr r0, [r2] - ldrb r0, [r0, 0x10] - cmp r0, 0x5 - bhi _080223A4 - ldr r1, _080223A0 @ =gBattleScripting - movs r0, 0x2 - strb r0, [r1, 0x1C] - b _080223DA - .align 2, 0 -_0802239C: .4byte gBattleStruct -_080223A0: .4byte gBattleScripting -_080223A4: - ldr r1, _080223AC @ =gBattleScripting - movs r0, 0x6 - strb r0, [r1, 0x1C] - b _080223DA - .align 2, 0 -_080223AC: .4byte gBattleScripting -_080223B0: - ldr r0, _080223E8 @ =gBattleControllerExecFlags - ldr r5, [r0] - cmp r5, 0 - bne _080223DA - ldr r4, _080223EC @ =gBattleMons - ldr r2, _080223F0 @ =gBattlerFainted - ldrb r0, [r2] - movs r1, 0x58 - muls r0, r1 - adds r0, r4 - movs r3, 0 - strh r5, [r0, 0x2E] - ldrb r0, [r2] - muls r0, r1 - adds r0, r4 - adds r0, 0x20 - strb r3, [r0] - ldr r1, _080223F4 @ =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_080223DA: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080223E8: .4byte gBattleControllerExecFlags -_080223EC: .4byte gBattleMons -_080223F0: .4byte gBattlerFainted -_080223F4: .4byte gBattlescriptCurrInstr - thumb_func_end atk23_getexp - thumb_func_start atk24 atk24: @ 80223F8 push {r4-r7,lr} diff --git a/include/battle.h b/include/battle.h index dc5a5ef00..fc92417da 100644 --- a/include/battle.h +++ b/include/battle.h @@ -432,12 +432,7 @@ struct BattleCallbacksStack struct StatsArray { - u16 hp; - u16 atk; - u16 def; - u16 spd; - u16 spAtk; - u16 spDef; + u16 stats[NUM_STATS]; }; struct BattleResources @@ -495,7 +490,7 @@ struct BattleStruct u8 turnCountersTracker; u8 wrappedMove[MAX_BATTLERS_COUNT * 2]; // Leftover from Ruby's ewram access. u8 moveTarget[MAX_BATTLERS_COUNT]; - u8 expGetterId; + u8 expGetterMonId; u8 field_11; u8 wildVictorySong; u8 dynamicMoveType; @@ -571,7 +566,7 @@ struct BattleStruct u16 castformPalette[MAX_BATTLERS_COUNT][16]; u8 wishPerishSongState; u8 wishPerishSongBattlerId; - u8 field_182; // overworldWeatherDone? + u8 field_182; u8 field_183; u8 field_184[124]; // currently unknown }; // size == 0x200 bytes @@ -985,5 +980,10 @@ extern u8 gNumberOfMovesToChoose; extern u16 gLastHitByType[MAX_BATTLERS_COUNT]; extern s32 gHpDealt; extern u16 gPauseCounterBattle; +extern u16 gPaydayMoney; +extern u16 gLockedMoves[MAX_BATTLERS_COUNT]; +extern u8 gCurrentTurnActionNumber; +extern u16 gExpShareExp; +extern u8 gLeveledUpInBattle; #endif // GUARD_BATTLE_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 688f9e4a2..405a4136f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -58,7 +58,7 @@ bool8 IsTwoTurnsMove(u16 move); void TrySetDestinyBondToHappen(void); u8 AttacksThisTurn(u8 battlerId, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2. void CheckWonderGuardAndLevitate(void); -u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr); +u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8 *BS_ptr); bool32 IsMonGettingExpSentOut(void); void sub_8026480(void); bool8 sub_80264D0(void); @@ -866,6 +866,7 @@ const u8 sBallCatchBonuses[] = 20, 15, 10, 15 // Ultra, Great, Poke, Safari }; +// not used const u32 gUnknown_8250898 = 0xFF7EAE60; void atk00_attackcanceler(void) @@ -1437,7 +1438,7 @@ void CheckWonderGuardAndLevitate(void) } // same as ModulateDmgByType except different arguments -void ModulateDmgByType2(u8 multiplier, u16 move, u8* flags) +void ModulateDmgByType2(u8 multiplier, u16 move, u8 *flags) { gBattleMoveDamage = gBattleMoveDamage * multiplier / 10; if (gBattleMoveDamage == 0 && multiplier != 0) @@ -2088,3 +2089,1224 @@ u8 GetBattlerTurnOrderNum(u8 battlerId) return i; } +void SetMoveEffect(bool8 primary, u8 certain) +{ + bool32 statusChanged = FALSE; + u8 affectsUser = 0; // 0x40 otherwise + bool32 noSunCanFreeze = TRUE; + + if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_AFFECTS_USER) + { + gEffectBattler = gBattlerAttacker; // battlerId that effects get applied on + gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER); + affectsUser = MOVE_EFFECT_AFFECTS_USER; + gBattleScripting.battler = gBattlerTarget; // theoretically the attacker + } + else + { + gEffectBattler = gBattlerTarget; + gBattleScripting.battler = gBattlerAttacker; + } + if (gBattleTypeFlags & BATTLE_TYPE_POKEDUDE + && gBattleCommunication[MOVE_EFFECT_BYTE] != 1 + && GetBattlerSide(gEffectBattler) == B_SIDE_OPPONENT) + { + ++gBattlescriptCurrInstr; + return; + } + if (gBattleMons[gEffectBattler].ability == ABILITY_SHIELD_DUST + && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && !primary + && gBattleCommunication[MOVE_EFFECT_BYTE] <= 9) + { + ++gBattlescriptCurrInstr; + return; + } + if (gSideStatuses[GET_BATTLER_SIDE(gEffectBattler)] & SIDE_STATUS_SAFEGUARD + && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && !primary + && gBattleCommunication[MOVE_EFFECT_BYTE] <= 7) + { + ++gBattlescriptCurrInstr; + return; + } + if (gBattleMons[gEffectBattler].hp == 0 + && gBattleCommunication[MOVE_EFFECT_BYTE] != MOVE_EFFECT_PAYDAY + && gBattleCommunication[MOVE_EFFECT_BYTE] != MOVE_EFFECT_STEAL_ITEM) + { + ++gBattlescriptCurrInstr; + return; + } + if (gBattleMons[gEffectBattler].status2 & STATUS2_SUBSTITUTE + && affectsUser != MOVE_EFFECT_AFFECTS_USER) + { + ++gBattlescriptCurrInstr; + return; + } + if (gBattleCommunication[MOVE_EFFECT_BYTE] <= 6) // status change + { + switch (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]) + { + case STATUS1_SLEEP: + // check active uproar + if (gBattleMons[gEffectBattler].ability != ABILITY_SOUNDPROOF) + for (gActiveBattler = 0; + gActiveBattler < gBattlersCount && !(gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR); + ++gActiveBattler); + else + gActiveBattler = gBattlersCount; + if (gBattleMons[gEffectBattler].status1) + break; + if (gActiveBattler != gBattlersCount) + break; + if (gBattleMons[gEffectBattler].ability == ABILITY_VITAL_SPIRIT) + break; + if (gBattleMons[gEffectBattler].ability == ABILITY_INSOMNIA) + break; + CancelMultiTurnMoves(gEffectBattler); + statusChanged = TRUE; + break; + case STATUS1_POISON: + if (gBattleMons[gEffectBattler].ability == ABILITY_IMMUNITY + && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + gLastUsedAbility = ABILITY_IMMUNITY; + RecordAbilityBattle(gEffectBattler, ABILITY_IMMUNITY); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PSNPrevention; + if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + return; + } + if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) + && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PSNPrevention; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return; + } + if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON)) + break; + if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) + break; + if (gBattleMons[gEffectBattler].status1) + break; + if (gBattleMons[gEffectBattler].ability == ABILITY_IMMUNITY) + break; + statusChanged = TRUE; + break; + case STATUS1_BURN: + if (gBattleMons[gEffectBattler].ability == ABILITY_WATER_VEIL + && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + gLastUsedAbility = ABILITY_WATER_VEIL; + RecordAbilityBattle(gEffectBattler, ABILITY_WATER_VEIL); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_BRNPrevention; + if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + return; + } + if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_FIRE) + && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_BRNPrevention; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return; + } + if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_FIRE)) + break; + if (gBattleMons[gEffectBattler].ability == ABILITY_WATER_VEIL) + break; + if (gBattleMons[gEffectBattler].status1) + break; + statusChanged = TRUE; + break; + case STATUS1_FREEZE: + if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY) + noSunCanFreeze = FALSE; + if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_ICE)) + break; + if (gBattleMons[gEffectBattler].status1) + break; + if (noSunCanFreeze == 0) + break; + if (gBattleMons[gEffectBattler].ability == ABILITY_MAGMA_ARMOR) + break; + CancelMultiTurnMoves(gEffectBattler); + statusChanged = TRUE; + break; + case STATUS1_PARALYSIS: + if (gBattleMons[gEffectBattler].ability == ABILITY_LIMBER) + { + if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) + { + gLastUsedAbility = ABILITY_LIMBER; + RecordAbilityBattle(gEffectBattler, ABILITY_LIMBER); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PRLZPrevention; + if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + return; + } + else + break; + } + if (gBattleMons[gEffectBattler].status1) + break; + statusChanged = TRUE; + break; + case STATUS1_TOXIC_POISON: + if (gBattleMons[gEffectBattler].ability == ABILITY_IMMUNITY && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + gLastUsedAbility = ABILITY_IMMUNITY; + RecordAbilityBattle(gEffectBattler, ABILITY_IMMUNITY); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PSNPrevention; + if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + return; + } + if ((IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) || IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) + && (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PSNPrevention; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + return; + } + if (gBattleMons[gEffectBattler].status1) + break; + if (!IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) && !IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL)) + { + if (gBattleMons[gEffectBattler].ability == ABILITY_IMMUNITY) + break; + // It's redundant, because at this point we know the status1 value is 0. + gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON); + gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON); + statusChanged = TRUE; + break; + } + else + { + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; + } + break; + } + if (statusChanged == TRUE) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + if (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]] == STATUS1_SLEEP) + gBattleMons[gEffectBattler].status1 |= ((Random() & 3) + 2); + else + gBattleMons[gEffectBattler].status1 |= sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]; + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + gActiveBattler = gEffectBattler; + BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gEffectBattler].status1); + MarkBattlerForControllerExec(gActiveBattler); + if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gHitMarker &= ~(HITMARKER_IGNORE_SAFEGUARD); + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + // for synchronize + if (gBattleCommunication[MOVE_EFFECT_BYTE] == MOVE_EFFECT_POISON + || gBattleCommunication[MOVE_EFFECT_BYTE] == MOVE_EFFECT_TOXIC + || gBattleCommunication[MOVE_EFFECT_BYTE] == MOVE_EFFECT_PARALYSIS + || gBattleCommunication[MOVE_EFFECT_BYTE] == MOVE_EFFECT_BURN) + { + u8 *synchronizeEffect = &gBattleStruct->synchronizeMoveEffect; + *synchronizeEffect = gBattleCommunication[MOVE_EFFECT_BYTE]; + gHitMarker |= HITMARKER_SYNCHRONISE_EFFECT; + } + return; + } + else if (statusChanged == FALSE) + { + ++gBattlescriptCurrInstr; + return; + } + return; + } + else + { + if (gBattleMons[gEffectBattler].status2 & sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]) + { + ++gBattlescriptCurrInstr; + } + else + { + u8 side; + switch (gBattleCommunication[MOVE_EFFECT_BYTE]) + { + case MOVE_EFFECT_CONFUSION: + if (gBattleMons[gEffectBattler].ability == ABILITY_OWN_TEMPO + || gBattleMons[gEffectBattler].status2 & STATUS2_CONFUSION) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleMons[gEffectBattler].status2 |= (((Random()) % 0x4)) + 2; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + } + break; + case MOVE_EFFECT_FLINCH: + if (gBattleMons[gEffectBattler].ability == ABILITY_INNER_FOCUS) + { + if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) + { + gLastUsedAbility = ABILITY_INNER_FOCUS; + RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); + gBattlescriptCurrInstr = BattleScript_FlinchPrevention; + } + else + { + ++gBattlescriptCurrInstr; + } + } + else + { + if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber) + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]; + ++gBattlescriptCurrInstr; + } + break; + case MOVE_EFFECT_UPROAR: + if (!(gBattleMons[gEffectBattler].status2 & STATUS2_UPROAR)) + { + gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gEffectBattler] = gCurrentMove; + gBattleMons[gEffectBattler].status2 |= ((Random() & 3) + 2) << 4; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + } + else + { + ++gBattlescriptCurrInstr; + } + break; + case MOVE_EFFECT_PAYDAY: + if (GET_BATTLER_SIDE(gBattlerAttacker) == B_SIDE_PLAYER) + { + u16 PayDay = gPaydayMoney; + gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5); + if (PayDay > gPaydayMoney) + gPaydayMoney = 0xFFFF; + } + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + break; + case MOVE_EFFECT_TRI_ATTACK: + if (gBattleMons[gEffectBattler].status1) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleCommunication[MOVE_EFFECT_BYTE] = Random() % 3 + 3; + SetMoveEffect(FALSE, 0); + } + break; + case MOVE_EFFECT_CHARGING: + gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gEffectBattler] = gCurrentMove; + gProtectStructs[gEffectBattler].chargingTurn = 1; + ++gBattlescriptCurrInstr; + break; + case MOVE_EFFECT_WRAP: + if (gBattleMons[gEffectBattler].status2 & STATUS2_WRAPPED) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleMons[gEffectBattler].status2 |= ((Random() & 3) + 3) << 0xD; + *(gBattleStruct->wrappedMove + gEffectBattler * 2 + 0) = gCurrentMove; + *(gBattleStruct->wrappedMove + gEffectBattler * 2 + 1) = gCurrentMove >> 8; + *(gBattleStruct->wrappedBy + gEffectBattler) = gBattlerAttacker; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; ++gBattleCommunication[MULTISTRING_CHOOSER]) + { + if (gBattleCommunication[MULTISTRING_CHOOSER] > 4) + break; + if (gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove) + break; + } + } + break; + case MOVE_EFFECT_RECOIL_25: // 25% recoil + gBattleMoveDamage = (gHpDealt) / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + break; + case MOVE_EFFECT_ATK_PLUS_1: + case MOVE_EFFECT_DEF_PLUS_1: + case MOVE_EFFECT_SPD_PLUS_1: + case MOVE_EFFECT_SP_ATK_PLUS_1: + case MOVE_EFFECT_SP_DEF_PLUS_1: + case MOVE_EFFECT_ACC_PLUS_1: + case MOVE_EFFECT_EVS_PLUS_1: + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1), + gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_PLUS_1 + 1, + affectsUser, + NULL)) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + gBattleScripting.animArg2 = 0; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_StatUp; + } + break; + case MOVE_EFFECT_ATK_MINUS_1: + case MOVE_EFFECT_DEF_MINUS_1: + case MOVE_EFFECT_SPD_MINUS_1: + case MOVE_EFFECT_SP_ATK_MINUS_1: + case MOVE_EFFECT_SP_DEF_MINUS_1: + case MOVE_EFFECT_ACC_MINUS_1: + case MOVE_EFFECT_EVS_MINUS_1: + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, + gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_MINUS_1 + 1, + affectsUser, + NULL)) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + gBattleScripting.animArg2 = 0; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_StatDown; + } + break; + case MOVE_EFFECT_ATK_PLUS_2: + case MOVE_EFFECT_DEF_PLUS_2: + case MOVE_EFFECT_SPD_PLUS_2: + case MOVE_EFFECT_SP_ATK_PLUS_2: + case MOVE_EFFECT_SP_DEF_PLUS_2: + case MOVE_EFFECT_ACC_PLUS_2: + case MOVE_EFFECT_EVS_PLUS_2: + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2), + gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_PLUS_2 + 1, + affectsUser, + NULL)) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + gBattleScripting.animArg2 = 0; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_StatUp; + } + break; + case MOVE_EFFECT_ATK_MINUS_2: + case MOVE_EFFECT_DEF_MINUS_2: + case MOVE_EFFECT_SPD_MINUS_2: + case MOVE_EFFECT_SP_ATK_MINUS_2: + case MOVE_EFFECT_SP_DEF_MINUS_2: + case MOVE_EFFECT_ACC_MINUS_2: + case MOVE_EFFECT_EVS_MINUS_2: + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE, + gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_MINUS_2 + 1, + affectsUser, + NULL)) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN); + gBattleScripting.animArg2 = 0; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_StatDown; + } + break; + case MOVE_EFFECT_RECHARGE: + gBattleMons[gEffectBattler].status2 |= STATUS2_RECHARGE; + gDisableStructs[gEffectBattler].rechargeTimer = 2; + gLockedMoves[gEffectBattler] = gCurrentMove; + ++gBattlescriptCurrInstr; + break; + case MOVE_EFFECT_RAGE: + gBattleMons[gBattlerAttacker].status2 |= STATUS2_RAGE; + ++gBattlescriptCurrInstr; + break; + case MOVE_EFFECT_STEAL_ITEM: + { + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_TOWER) + { + ++gBattlescriptCurrInstr; + break; + } + side = GetBattlerSide(gBattlerAttacker); + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT + && !(gBattleTypeFlags & + (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_BATTLE_TOWER + | BATTLE_TYPE_LINK)) + && gTrainerBattleOpponent_A != 0x400) + { + ++gBattlescriptCurrInstr; + } + else if (!(gBattleTypeFlags & + (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_BATTLE_TOWER + | BATTLE_TYPE_LINK)) + && gTrainerBattleOpponent_A != 0x400 + && (gWishFutureKnock.knockedOffMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) + { + ++gBattlescriptCurrInstr; + } + else if (gBattleMons[gBattlerTarget].item + && gBattleMons[gBattlerTarget].ability == ABILITY_STICKY_HOLD) + { + gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); + } + else if (gBattleMons[gBattlerAttacker].item != ITEM_NONE + || gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBattlerTarget].item) + || gBattleMons[gBattlerTarget].item == ITEM_NONE) + { + ++gBattlescriptCurrInstr; + } + else + { + u16 *changedItem = &gBattleStruct->changedItems[gBattlerAttacker]; + gLastUsedItem = *changedItem = gBattleMons[gBattlerTarget].item; + gBattleMons[gBattlerTarget].item = ITEM_NONE; + gActiveBattler = gBattlerAttacker; + BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); + MarkBattlerForControllerExec(gBattlerAttacker); + gActiveBattler = gBattlerTarget; + BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item); + MarkBattlerForControllerExec(gBattlerTarget); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_ItemSteal; + *(u8 *)((u8 *)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0; + *(u8 *)((u8 *)(&gBattleStruct->choicedMove[gBattlerTarget]) + 1) = 0; + } + } + break; + case MOVE_EFFECT_PREVENT_ESCAPE: + gBattleMons[gBattlerTarget].status2 |= STATUS2_ESCAPE_PREVENTION; + gDisableStructs[gBattlerTarget].battlerPreventingEscape = gBattlerAttacker; + ++gBattlescriptCurrInstr; + break; + case MOVE_EFFECT_NIGHTMARE: + gBattleMons[gBattlerTarget].status2 |= STATUS2_NIGHTMARE; + ++gBattlescriptCurrInstr; + break; + case MOVE_EFFECT_ALL_STATS_UP: + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_AllStatsUp; + break; + case MOVE_EFFECT_RAPIDSPIN: + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_RapidSpinAway; + break; + case MOVE_EFFECT_REMOVE_PARALYSIS: // Smelling salts + if (!(gBattleMons[gBattlerTarget].status1 & STATUS1_PARALYSIS)) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleMons[gBattlerTarget].status1 &= ~(STATUS1_PARALYSIS); + gActiveBattler = gBattlerTarget; + BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBattlerForControllerExec(gActiveBattler); + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_TargetPRLZHeal; + } + break; + case MOVE_EFFECT_ATK_DEF_DOWN: // SuperPower + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_AtkDefDown; + break; + case MOVE_EFFECT_RECOIL_33: // Double Edge + gBattleMoveDamage = gHpDealt / 3; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; + break; + case MOVE_EFFECT_THRASH: + if (gBattleMons[gEffectBattler].status2 & STATUS2_LOCK_CONFUSE) + { + ++gBattlescriptCurrInstr; + } + else + { + gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gEffectBattler] = gCurrentMove; + gBattleMons[gEffectBattler].status2 |= (((Random() & 1) + 2) << 0xA); + } + break; + case MOVE_EFFECT_KNOCK_OFF: + if (gBattleMons[gEffectBattler].ability == ABILITY_STICKY_HOLD) + { + if (gBattleMons[gEffectBattler].item == ITEM_NONE) + { + ++gBattlescriptCurrInstr; + } + else + { + gLastUsedAbility = ABILITY_STICKY_HOLD; + gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; + RecordAbilityBattle(gEffectBattler, ABILITY_STICKY_HOLD); + } + break; + } + if (gBattleMons[gEffectBattler].item) + { + side = GetBattlerSide(gEffectBattler); + gLastUsedItem = gBattleMons[gEffectBattler].item; + gBattleMons[gEffectBattler].item = ITEM_NONE; + gWishFutureKnock.knockedOffMons[side] |= gBitTable[gBattlerPartyIndexes[gEffectBattler]]; + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_KnockedOff; + *(u8 *)((u8 *)(&gBattleStruct->choicedMove[gEffectBattler]) + 0) = 0; + *(u8 *)((u8 *)(&gBattleStruct->choicedMove[gEffectBattler]) + 1) = 0; + } + else + { + ++gBattlescriptCurrInstr; + } + break; + case MOVE_EFFECT_SP_ATK_TWO_DOWN: // Overheat + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_SAtkDown2; + break; + } + } + } +} + +void atk15_seteffectwithchance(void) +{ + u32 percentChance; + + if (gBattleMons[gBattlerAttacker].ability == ABILITY_SERENE_GRACE) + percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2; + else + percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance; + if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_CERTAIN + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) + { + gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_CERTAIN); + SetMoveEffect(0, MOVE_EFFECT_CERTAIN); + } + else if (Random() % 100 <= percentChance + && gBattleCommunication[MOVE_EFFECT_BYTE] + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) + { + if (percentChance >= 100) + SetMoveEffect(0, MOVE_EFFECT_CERTAIN); + else + SetMoveEffect(0, 0); + } + else + { + ++gBattlescriptCurrInstr; + } + gBattleCommunication[MOVE_EFFECT_BYTE] = 0; + gBattleScripting.multihitMoveEffect = 0; +} + +void atk16_seteffectprimary(void) +{ + SetMoveEffect(TRUE, 0); +} + +void atk17_seteffectsecondary(void) +{ + SetMoveEffect(FALSE, 0); +} + +void atk18_clearstatusfromeffect(void) +{ + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + + if (gBattleCommunication[MOVE_EFFECT_BYTE] <= MOVE_EFFECT_TOXIC) + gBattleMons[gActiveBattler].status1 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); + else + gBattleMons[gActiveBattler].status2 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); + gBattleCommunication[MOVE_EFFECT_BYTE] = 0; + gBattlescriptCurrInstr += 2; + gBattleScripting.multihitMoveEffect = 0; +} + +void atk19_tryfaintmon(void) +{ + const u8 *BS_ptr; + + if (gBattlescriptCurrInstr[2] != 0) + { + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) + { + BS_ptr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + BattleScriptPop(); + gBattlescriptCurrInstr = BS_ptr; + gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + } + else + { + gBattlescriptCurrInstr += 7; + } + } + else + { + u8 battlerId; + + if (gBattlescriptCurrInstr[1] == BS_ATTACKER) + { + gActiveBattler = gBattlerAttacker; + battlerId = gBattlerTarget; + BS_ptr = BattleScript_FaintAttacker; + } + else + { + gActiveBattler = gBattlerTarget; + battlerId = gBattlerAttacker; + BS_ptr = BattleScript_FaintTarget; + } + if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler]) + && gBattleMons[gActiveBattler].hp == 0) + { + gHitMarker |= HITMARKER_FAINTED(gActiveBattler); + BattleScriptPush(gBattlescriptCurrInstr + 7); + gBattlescriptCurrInstr = BS_ptr; + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + { + gHitMarker |= HITMARKER_x400000; + if (gBattleResults.playerFaintCounter < 0xFF) + ++gBattleResults.playerFaintCounter; + AdjustFriendshipOnBattleFaint(gActiveBattler); + } + else + { + if (gBattleResults.opponentFaintCounter < 0xFF) + ++gBattleResults.opponentFaintCounter; + gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); + *(u8 *)(&gBattleStruct->field_182) = gBattlerAttacker; + } + if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) + { + gHitMarker &= ~(HITMARKER_DESTINYBOND); + BattleScriptPush(gBattlescriptCurrInstr); + gBattleMoveDamage = gBattleMons[battlerId].hp; + gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife; + } + if ((gStatuses3[gBattlerTarget] & STATUS3_GRUDGE) + && !(gHitMarker & HITMARKER_GRUDGE) + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) + && gBattleMons[gBattlerAttacker].hp != 0 + && gCurrentMove != MOVE_STRUGGLE) + { + u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); + + gBattleMons[gBattlerAttacker].pp[moveIndex] = 0; + BattleScriptPush(gBattlescriptCurrInstr); + gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp; + gActiveBattler = gBattlerAttacker; + BtlController_EmitSetMonData(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); + MarkBattlerForControllerExec(gActiveBattler); + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].moves[moveIndex]) + } + } + else + { + gBattlescriptCurrInstr += 7; + } + } +} + +void atk1A_dofaintanimation(void) +{ + if (!gBattleControllerExecFlags) + { + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + BtlController_EmitFaintAnimation(0); + MarkBattlerForControllerExec(gActiveBattler); + gBattlescriptCurrInstr += 2; + } +} + +void atk1B_cleareffectsonfaint(void) +{ + if (!gBattleControllerExecFlags) + { + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + gBattleMons[gActiveBattler].status1 = 0; + BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBattler].status1); + MarkBattlerForControllerExec(gActiveBattler); + FaintClearSetData(); // Effects like attractions, trapping, etc. + gBattlescriptCurrInstr += 2; + } +} + +void atk1C_jumpifstatus(void) +{ + u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + u32 flags = T2_READ_32(gBattlescriptCurrInstr + 2); + const u8 *jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 6); + + if (gBattleMons[battlerId].status1 & flags && gBattleMons[battlerId].hp != 0) + gBattlescriptCurrInstr = jumpPtr; + else + gBattlescriptCurrInstr += 10; +} + +void atk1D_jumpifstatus2(void) +{ + u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + u32 flags = T2_READ_32(gBattlescriptCurrInstr + 2); + const u8 *jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 6); + + if (gBattleMons[battlerId].status2 & flags && gBattleMons[battlerId].hp != 0) + gBattlescriptCurrInstr = jumpPtr; + else + gBattlescriptCurrInstr += 10; +} + +void atk1E_jumpifability(void) +{ + u8 battlerId; + u8 ability = gBattlescriptCurrInstr[2]; + const u8 *jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3); + + if (gBattlescriptCurrInstr[1] == BS_ATTACKER_SIDE) + { + battlerId = AbilityBattleEffects(ABILITYEFFECT_CHECK_BATTLER_SIDE, gBattlerAttacker, ability, 0, 0); + if (battlerId) + { + gLastUsedAbility = ability; + gBattlescriptCurrInstr = jumpPtr; + RecordAbilityBattle(battlerId - 1, gLastUsedAbility); + gBattleScripting.battlerWithAbility = battlerId - 1; + } + else + gBattlescriptCurrInstr += 7; + } + else if (gBattlescriptCurrInstr[1] == BS_NOT_ATTACKER_SIDE) + { + battlerId = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattlerAttacker, ability, 0, 0); + if (battlerId) + { + gLastUsedAbility = ability; + gBattlescriptCurrInstr = jumpPtr; + RecordAbilityBattle(battlerId - 1, gLastUsedAbility); + gBattleScripting.battlerWithAbility = battlerId - 1; + } + else + gBattlescriptCurrInstr += 7; + } + else + { + battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + if (gBattleMons[battlerId].ability == ability) + { + gLastUsedAbility = ability; + gBattlescriptCurrInstr = jumpPtr; + RecordAbilityBattle(battlerId, gLastUsedAbility); + gBattleScripting.battlerWithAbility = battlerId; + } + else + gBattlescriptCurrInstr += 7; + } +} + +void atk1F_jumpifsideaffecting(void) +{ + u8 side; + u16 flags; + const u8 *jumpPtr; + + if (gBattlescriptCurrInstr[1] == BS_ATTACKER) + side = GET_BATTLER_SIDE(gBattlerAttacker); + else + side = GET_BATTLER_SIDE(gBattlerTarget); + + flags = T2_READ_16(gBattlescriptCurrInstr + 2); + jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 4); + + if (gSideStatuses[side] & flags) + gBattlescriptCurrInstr = jumpPtr; + else + gBattlescriptCurrInstr += 8; +} + +void atk20_jumpifstat(void) +{ + u8 ret = 0; + u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + u8 value = gBattleMons[battlerId].statStages[gBattlescriptCurrInstr[3]]; + + switch (gBattlescriptCurrInstr[2]) + { + case CMP_EQUAL: + if (value == gBattlescriptCurrInstr[4]) + ++ret; + break; + case CMP_NOT_EQUAL: + if (value != gBattlescriptCurrInstr[4]) + ++ret; + break; + case CMP_GREATER_THAN: + if (value > gBattlescriptCurrInstr[4]) + ++ret; + break; + case CMP_LESS_THAN: + if (value < gBattlescriptCurrInstr[4]) + ++ret; + break; + case CMP_COMMON_BITS: + if (value & gBattlescriptCurrInstr[4]) + ++ret; + break; + case CMP_NO_COMMON_BITS: + if (!(value & gBattlescriptCurrInstr[4])) + ++ret; + break; + } + if (ret) + gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 5); + else + gBattlescriptCurrInstr += 9; +} + +void atk21_jumpifstatus3condition(void) +{ + u32 flags; + const u8 *jumpPtr; + + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + flags = T2_READ_32(gBattlescriptCurrInstr + 2); + jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 7); + if (gBattlescriptCurrInstr[6]) + { + if (gStatuses3[gActiveBattler] & flags) + gBattlescriptCurrInstr += 11; + else + gBattlescriptCurrInstr = jumpPtr; + } + else + { + if (gStatuses3[gActiveBattler] & flags) + gBattlescriptCurrInstr = jumpPtr; + else + gBattlescriptCurrInstr += 11; + } +} + +void atk22_jumpiftype(void) +{ + u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + u8 type = gBattlescriptCurrInstr[2]; + const u8 *jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3); + + if (IS_BATTLER_OF_TYPE(battlerId, type)) + gBattlescriptCurrInstr = jumpPtr; + else + gBattlescriptCurrInstr += 7; +} + +void atk23_getexp(void) +{ + u16 item; + s32 i; // also used as stringId + u8 holdEffect; + s32 sentIn; + s32 viaExpShare = 0; + u16 *exp = &gBattleStruct->expValue; + + gBattlerFainted = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + sentIn = gSentPokesToOpponent[(gBattlerFainted & 2) >> 1]; + switch (gBattleScripting.atk23_state) + { + case 0: // check if should receive exp at all + if (GetBattlerSide(gBattlerFainted) != B_SIDE_OPPONENT + || (gBattleTypeFlags & + (BATTLE_TYPE_LINK + | BATTLE_TYPE_TRAINER_TOWER + | BATTLE_TYPE_BATTLE_TOWER + | BATTLE_TYPE_SAFARI + | BATTLE_TYPE_EREADER_TRAINER))) + { + gBattleScripting.atk23_state = 6; // goto last case + } + else + { + ++gBattleScripting.atk23_state; + gBattleStruct->givenExpMons |= gBitTable[gBattlerPartyIndexes[gBattlerFainted]]; + } + break; + case 1: // calculate experience points to redistribute + { + u16 calculatedExp; + s32 viaSentIn; + + for (viaSentIn = 0, i = 0; i < PARTY_SIZE; ++i) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) + continue; + if (gBitTable[i] & sentIn) + ++viaSentIn; + item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + if (item == ITEM_ENIGMA_BERRY) + holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; + else + holdEffect = ItemId_GetHoldEffect(item); + if (holdEffect == HOLD_EFFECT_EXP_SHARE) + ++viaExpShare; + } + calculatedExp = gBaseStats[gBattleMons[gBattlerFainted].species].expYield * gBattleMons[gBattlerFainted].level / 7; + if (viaExpShare) // at least one mon is getting exp via exp share + { + *exp = calculatedExp / 2 / viaSentIn; + if (*exp == 0) + *exp = 1; + gExpShareExp = calculatedExp / 2 / viaExpShare; + if (gExpShareExp == 0) + gExpShareExp = 1; + } + else + { + *exp = calculatedExp / viaSentIn; + if (*exp == 0) + *exp = 1; + gExpShareExp = 0; + } + ++gBattleScripting.atk23_state; + gBattleStruct->expGetterMonId = 0; + gBattleStruct->sentInPokes = sentIn; + } + // fall through + case 2: // set exp value to the poke in expgetter_id and print message + if (!gBattleControllerExecFlags) + { + item = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HELD_ITEM); + if (item == ITEM_ENIGMA_BERRY) + holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; + else + holdEffect = ItemId_GetHoldEffect(item); + if (holdEffect != HOLD_EFFECT_EXP_SHARE && !(gBattleStruct->sentInPokes & 1)) + { + *(&gBattleStruct->sentInPokes) >>= 1; + gBattleScripting.atk23_state = 5; + gBattleMoveDamage = 0; // used for exp + } + else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL) + { + *(&gBattleStruct->sentInPokes) >>= 1; + gBattleScripting.atk23_state = 5; + gBattleMoveDamage = 0; // used for exp + } + else + { + // music change in wild battle after fainting a poke + if (!(gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_POKEDUDE)) + && gBattleMons[0].hp + && !gBattleStruct->wildVictorySong) + { + BattleStopLowHpSound(); + PlayBGM(BGM_FRLG_KACHI_WILD_POKEMON); + ++gBattleStruct->wildVictorySong; + } + if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP)) + { + if (gBattleStruct->sentInPokes & 1) + gBattleMoveDamage = *exp; + else + gBattleMoveDamage = 0; + if (holdEffect == HOLD_EFFECT_EXP_SHARE) + gBattleMoveDamage += gExpShareExp; + if (holdEffect == HOLD_EFFECT_LUCKY_EGG) + gBattleMoveDamage = (gBattleMoveDamage * 150) / 100; + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + gBattleMoveDamage = (gBattleMoveDamage * 150) / 100; + if (IsTradedMon(&gPlayerParty[gBattleStruct->expGetterMonId]) + && !(gBattleTypeFlags & BATTLE_TYPE_POKEDUDE)) + { + gBattleMoveDamage = (gBattleMoveDamage * 150) / 100; + i = STRINGID_ABOOSTED; + } + else + { + i = STRINGID_EMPTYSTRING4; + } + // get exp getter battlerId + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + if (!(gBattlerPartyIndexes[2] != gBattleStruct->expGetterMonId) && !(gAbsentBattlerFlags & gBitTable[2])) + gBattleStruct->expGetterBattlerId = 2; + else + { + if (!(gAbsentBattlerFlags & gBitTable[0])) + gBattleStruct->expGetterBattlerId = 0; + else + gBattleStruct->expGetterBattlerId = 2; + } + } + else + { + gBattleStruct->expGetterBattlerId = 0; + } + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleStruct->expGetterBattlerId, gBattleStruct->expGetterMonId); + // buffer 'gained' or 'gained a boosted' + PREPARE_STRING_BUFFER(gBattleTextBuff2, i); + PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff3, 5, gBattleMoveDamage); + PrepareStringBattle(STRINGID_PKMNGAINEDEXP, gBattleStruct->expGetterBattlerId); + MonGainEVs(&gPlayerParty[gBattleStruct->expGetterMonId], gBattleMons[gBattlerFainted].species); + } + gBattleStruct->sentInPokes >>= 1; + ++gBattleScripting.atk23_state; + } + } + break; + case 3: // Set stats and give exp + if (!gBattleControllerExecFlags) + { + gBattleBufferB[gBattleStruct->expGetterBattlerId][0] = 0; + if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_LEVEL) + { + gBattleResources->beforeLvlUp->stats[STAT_HP] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); + gBattleResources->beforeLvlUp->stats[STAT_ATK] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); + gBattleResources->beforeLvlUp->stats[STAT_DEF] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); + gBattleResources->beforeLvlUp->stats[STAT_SPEED] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + gBattleResources->beforeLvlUp->stats[STAT_SPATK] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); + gBattleResources->beforeLvlUp->stats[STAT_SPDEF] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); + gActiveBattler = gBattleStruct->expGetterBattlerId; + BtlController_EmitExpUpdate(0, gBattleStruct->expGetterMonId, gBattleMoveDamage); + MarkBattlerForControllerExec(gActiveBattler); + } + ++gBattleScripting.atk23_state; + } + break; + case 4: // lvl up if necessary + if (!gBattleControllerExecFlags) + { + gActiveBattler = gBattleStruct->expGetterBattlerId; + if (gBattleBufferB[gActiveBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBattler][1] == RET_VALUE_LEVELED_UP) + { + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlerPartyIndexes[gActiveBattler] == gBattleStruct->expGetterMonId) + HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattleStruct->expGetterMonId); + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL)); + BattleScriptPushCursor(); + gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterMonId]; + gBattlescriptCurrInstr = BattleScript_LevelUp; + gBattleMoveDamage = (gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)); + AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterMonId], 0); + // update battle mon structure after level up + if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId && gBattleMons[0].hp) + { + gBattleMons[0].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL); + gBattleMons[0].hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP); + gBattleMons[0].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); + gBattleMons[0].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); + gBattleMons[0].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); + // Why is this duplicated? + gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + gBattleMons[0].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); + gBattleMons[0].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF); + } + // What is else if? + if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gBattleMons[2].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL); + gBattleMons[2].hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP); + gBattleMons[2].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); + gBattleMons[2].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK); + gBattleMons[2].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF); + // Duplicated again, but this time there's no Sp Defense + gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED); + gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); + } + gBattleScripting.atk23_state = 5; + } + else + { + gBattleMoveDamage = 0; + gBattleScripting.atk23_state = 5; + } + } + break; + case 5: // looper increment + if (gBattleMoveDamage) // there is exp to give, goto case 3 that gives exp + { + gBattleScripting.atk23_state = 3; + } + else + { + ++gBattleStruct->expGetterMonId; + if (gBattleStruct->expGetterMonId <= 5) + gBattleScripting.atk23_state = 2; // loop again + else + gBattleScripting.atk23_state = 6; // we're done + } + break; + case 6: // increment instruction + if (!gBattleControllerExecFlags) + { + // not sure why gf clears the item and ability here + gBattleMons[gBattlerFainted].item = ITEM_NONE; + gBattleMons[gBattlerFainted].ability = ABILITY_NONE; + gBattlescriptCurrInstr += 2; + } + break; + } +} |