diff --git a/battle/core.asm b/battle/core.asm index f4b7c3cdb..4fb97aa23 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -28,11 +28,10 @@ Function3c000: ; 3c000 ld a, [InLinkBattle] and a jr z, .asm_3c031 + ld a, [$ffcb] cp $2 -.data_3c02f - db $28 - db $1b + jr z, .asm_3c04c .asm_3c031 ld a, [IsInBattle] @@ -40,14 +39,16 @@ Function3c000: ; 3c000 jr z, .asm_3c047 xor a ld [$c718], a - call Function3d834 - call Function3d867 - call Function3dc18 + call NewEnemyMonStatus + call ResetEnemyStatLevels + call BreakAttraction call Function3d4e1 .asm_3c047 - ld c, $28 + ld c, 40 call DelayFrames + +.asm_3c04c call Function309d call Function3d873 ld a, d @@ -87,15 +88,15 @@ Function3c000: ; 3c000 call Function309d call Function3d57a call Function3da0d - call Function3dab1 + call ResetPlayerStatLevels call Function3f26d - call Function3dbde - call Function3dc18 + call NewBattleMonStatus + call BreakAttraction call Function3db5f call EmptyBattleTextBox call Function309d call SetPlayerTurn - call Function3dc23 + call SpikesDamage ld a, [InLinkBattle] and a jr z, .asm_3c0df @@ -104,12 +105,12 @@ Function3c000: ; 3c000 jr nz, .asm_3c0df xor a ld [$c718], a - call Function3d834 - call Function3d867 - call Function3dc18 + call NewEnemyMonStatus + call ResetEnemyStatLevels + call BreakAttraction call Function3d4e1 call SetEnemyTurn - call Function3dc23 + call SpikesDamage .asm_3c0df jp Function3c12f @@ -470,7 +471,7 @@ Function3c314: ; 3c314 .asm_3c34c callab Function3846c call SetEnemyTurn - call Function3dc23 + call SpikesDamage jp Function3c3f3 .asm_3c35b @@ -668,7 +669,7 @@ Function3c434: ; 3c434 cp $74 jr z, .asm_3c4c9 xor a - ld [$c679], a + ld [PlayerProtectCount], a jr .asm_3c4c9 .asm_3c4b5 @@ -678,7 +679,7 @@ Function3c434: ; 3c434 .asm_3c4ba xor a ld [PlayerFuryCutterCount], a - ld [$c679], a + ld [PlayerProtectCount], a ld [$c72b], a ld hl, PlayerSubStatus4 res 6, [hl] @@ -691,7 +692,7 @@ Function3c434: ; 3c434 .asm_3c4ce xor a ld [PlayerFuryCutterCount], a - ld [$c679], a + ld [PlayerProtectCount], a ld [$c72b], a ld hl, PlayerSubStatus4 res 6, [hl] @@ -2144,14 +2145,14 @@ Function3cdca: ; 3cdca call ClearBox call Function3d2b3 ld a, $1 - call Function3cf78 + call EnemyPartyMonEntrance jr .asm_3cdfc .asm_3cde6 ld a, [CurPartyMon] push af ld a, $1 - call Function3cf78 + call EnemyPartyMonEntrance call ClearSprites call Function309d pop af @@ -2183,8 +2184,8 @@ Function3ce01: ; 3ce01 ld hl, EnemyDamageTaken ld [hli], a ld [hl], a - call Function3d834 - call Function3dc18 + call NewEnemyMonStatus + call BreakAttraction ld a, [IsInBattle] dec a jr z, .asm_3ce2f @@ -2382,18 +2383,18 @@ Function3cf4a: ; 3cf4a ld a, [hli] or [hl] ld a, $0 - jr nz, Function3cf78 + jr nz, EnemyPartyMonEntrance inc a ret ; 3cf78 -Function3cf78: ; 3cf78 +EnemyPartyMonEntrance: ; 3cf78 push af xor a ld [$c718], a - call Function3d834 - call Function3d867 - call Function3dc18 + call NewEnemyMonStatus + call ResetEnemyStatLevels + call BreakAttraction pop af and a jr nz, .asm_3cf8f @@ -2406,7 +2407,7 @@ Function3cf78: ; 3cf78 .asm_3cf92 call Function3d57a call SetEnemyTurn - call Function3dc23 + call SpikesDamage xor a ld [EnemyMoveAnimation], a ld [$d0ec], a @@ -2834,7 +2835,7 @@ Function3d227: ; 3d227 call EmptyBattleTextBox call Function1d6e call Function3d2f7 - call Function3d362 + call ForcePickPartyMonInBattle ld a, [InLinkBattle] and a jr z, .asm_3d241 @@ -2873,7 +2874,7 @@ Function3d227: ; 3d227 ld [CurBattleMon], a call Function3d581 call Function3da0d - call Function3dab1 + call ResetPlayerStatLevels call ClearPalettes call DelayFrame call Function3eda6 @@ -2881,13 +2882,13 @@ Function3d227: ; 3d227 call ClearSGB call Function32f9 call Function3f26d - call Function3dbde - call Function3dc18 + call NewBattleMonStatus + call BreakAttraction call Function3db5f call EmptyBattleTextBox call Function309d call SetPlayerTurn - call Function3dc23 + call SpikesDamage ld a, $1 and a ld c, a @@ -2901,15 +2902,15 @@ Function3d2b3: ; 3d2b3 ld [CurBattleMon], a call Function3d581 call Function3da0d - call Function3dab1 + call ResetPlayerStatLevels call Function3f26d - call Function3dbde - call Function3dc18 + call NewBattleMonStatus + call BreakAttraction call Function3db5f call EmptyBattleTextBox call Function309d call SetPlayerTurn - jp Function3dc23 + jp SpikesDamage ; 3d2e0 @@ -2965,9 +2966,9 @@ Function3d329: ; 3d329 ret ; 3d33c -Function3d33c: ; 3d33c +PickPartyMonInBattle: ; 3d33c .asm_3d33c - ld a, $2 + ld a, $2 ; Which PKMN? ld [PartyMenuActionText], a call Function3d313 call Function3d329 @@ -2978,52 +2979,58 @@ Function3d33c: ; 3d33c ret ; 3d34f -Function3d34f: ; 3d34f +SwitchMonAlreadyOut: ; 3d34f ld hl, CurBattleMon ld a, [CurPartyMon] cp [hl] - jr nz, .asm_3d360 + jr nz, .notout + ld hl, BattleText_0x80c0d call StdBattleTextBox scf ret -.asm_3d360 +.notout xor a ret ; 3d362 -Function3d362: ; 3d362 -.asm_3d362 - call Function3d33c +ForcePickPartyMonInBattle: ; 3d362 +; Can't back out. + +.pick + call PickPartyMonInBattle ret nc call Function3d2e0 ret c + ld de, SFX_WRONG call PlaySFX call WaitSFX - jr .asm_3d362 + jr .pick ; 3d375 - -Function3d375: ; 3d375 -.asm_3d375 - call Function3d33c +PickSwitchMonInBattle: ; 3d375 +.pick + call PickPartyMonInBattle ret c - call Function3d34f - jr c, .asm_3d375 + call SwitchMonAlreadyOut + jr c, .pick xor a ret ; 3d380 -Function3d380: ; 3d380 -.asm_3d380 - call Function3d362 +ForcePickSwitchMonInBattle: ; 3d380 +; Can't back out. + +.pick + call ForcePickPartyMonInBattle call Function3d2e0 ret c - call Function3d34f - jr c, .asm_3d380 + call SwitchMonAlreadyOut + jr c, .pick + xor a ret ; 3d38e @@ -3244,10 +3251,10 @@ Function3d4c3: ; 3d4c3 ld b, a call Function3d6ca call Function3d7a0 - call Function3d834 - call Function3d867 + call NewEnemyMonStatus + call ResetEnemyStatLevels call Function3d7c7 - call Function3dc18 + call BreakAttraction call Function3d57a ret ; 3d4e1 @@ -3628,7 +3635,7 @@ Function3d74b: ; 3d74b dec a jr nz, .asm_3d79a call Function3d2f7 - call Function3d375 + call PickSwitchMonInBattle jr c, .asm_3d791 ld a, [CurBattleMon] ld [$c71a], a @@ -3725,7 +3732,7 @@ Function3d7c7: ; 3d7c7 ret ; 3d834 -Function3d834: ; 3d834 +NewEnemyMonStatus: ; 3d834 xor a ld [LastEnemyCounterMove], a ld [LastPlayerCounterMove], a @@ -3750,14 +3757,14 @@ Function3d834: ; 3d834 ret ; 3d867 -Function3d867: ; 3d867 - ld a, $7 - ld b, $8 - ld hl, EnemyAtkLevel -.asm_3d86e +ResetEnemyStatLevels: ; 3d867 + ld a, 7 + ld b, 8 + ld hl, EnemyStatLevels +.loop ld [hli], a dec b - jr nz, .asm_3d86e + jr nz, .loop ret ; 3d873 @@ -4076,14 +4083,14 @@ Function3da97: ; 3da97 jp GetPartyLocation ; 3dab1 -Function3dab1: ; 3dab1 - ld a, $7 - ld b, $8 - ld hl, PlayerAtkLevel -.asm_3dab8 +ResetPlayerStatLevels: ; 3dab1 + ld a, 7 + ld b, 8 + ld hl, PlayerStatLevels +.loop ld [hli], a dec b - jr nz, .asm_3dab8 + jr nz, .loop ret ; 3dabd @@ -4150,9 +4157,9 @@ Function3db32: ; 3db32 ld [CurBattleMon], a call Function3d581 call Function3da0d - call Function3dab1 - call Function3dbde - call Function3dc18 + call ResetPlayerStatLevels + call NewBattleMonStatus + call BreakAttraction call Function3db5f call EmptyBattleTextBox call Function309d @@ -4220,7 +4227,7 @@ Function3db5f: ; 3db5f ret ; 3dbde -Function3dbde: ; 3dbde +NewBattleMonStatus: ; 3dbde xor a ld [LastEnemyCounterMove], a ld [LastPlayerCounterMove], a @@ -4238,7 +4245,7 @@ Function3dbde: ; 3dbde ld [hl], a ld [PlayerDisableCount], a ld [PlayerFuryCutterCount], a - ld [$c679], a + ld [PlayerProtectCount], a ld [$c72b], a ld [DisabledMove], a ld [$c6fe], a @@ -4246,50 +4253,56 @@ Function3dbde: ; 3dbde ld [$c730], a ld [PlayerTurnsTaken], a ld hl, EnemySubStatus5 - res 7, [hl] + res SUBSTATUS_CANT_RUN, [hl] ret ; 3dc18 -Function3dc18: ; 3dc18 +BreakAttraction: ; 3dc18 ld hl, PlayerSubStatus1 - res 7, [hl] + res SUBSTATUS_IN_LOVE, [hl] ld hl, EnemySubStatus1 - res 7, [hl] + res SUBSTATUS_IN_LOVE, [hl] ret ; 3dc23 -Function3dc23: ; 3dc23 +SpikesDamage: ; 3dc23 ld hl, PlayerScreens ld de, BattleMonType1 ld bc, Function3df48 ld a, [hBattleTurn] and a - jr z, .asm_3dc3a + jr z, .ok ld hl, EnemyScreens ld de, EnemyMonType1 ld bc, Function3e036 +.ok -.asm_3dc3a - bit 0, [hl] + bit SCREENS_SPIKES, [hl] ret z + +; Flying-types aren't affected by Spikes. ld a, [de] - cp $2 + cp FLYING ret z inc de ld a, [de] - cp $2 + cp FLYING ret z + push bc - ld hl, BattleText_0x80bae + + ld hl, BattleText_0x80bae ; "hurt by SPIKES!" call StdBattleTextBox + call GetEighthMaxHP call Function3cc39 - pop hl - call Function3dc5a - jp WaitBGMap -; 3dc5a -Function3dc5a: ; 3dc5a + pop hl + call .hl + + jp WaitBGMap + +.hl jp [hl] ; 3dc5b @@ -5375,7 +5388,7 @@ Function3e3ad: ; 3e3ad jr nz, .asm_3e3cf .asm_3e3ca - call Function3e40b + call BattleMonEntrance and a ret @@ -5396,14 +5409,14 @@ Function3e3ad: ; 3e3ad ld a, [$ffcb] cp $1 jr z, .asm_3e3f7 - call Function3e40b + call BattleMonEntrance call Function3e3ff and a ret .asm_3e3f7 call Function3e3ff - call Function3e40b + call BattleMonEntrance and a ret ; 3e3ff @@ -5411,48 +5424,54 @@ Function3e3ad: ; 3e3ad Function3e3ff: ; 3e3ff callab Function3846c call SetEnemyTurn - jp Function3dc23 + jp SpikesDamage ; 3e40b -Function3e40b: ; 3e40b +BattleMonEntrance: ; 3e40b call Function3f2f4 - ld c, $32 + + ld c, 50 call DelayFrames + ld hl, PlayerSubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] + call SetEnemyTurn call Function3dc5b jr c, .asm_3e423 call Function3dce6 - .asm_3e423 - ld hl, $c535 - ld bc, $050b + + hlcoord 9, 7 + lb bc, 5, 11 call ClearBox + ld a, [CurBattleMon] ld [CurPartyMon], a call Function3d581 call Function3da0d - call Function3dab1 + call ResetPlayerStatLevels call Function3f26d - call Function3dbde - call Function3dc18 + call NewBattleMonStatus + call BreakAttraction call Function3db5f call EmptyBattleTextBox call Function309d call SetPlayerTurn - call Function3dc23 + call SpikesDamage ld a, $2 ld [$cfa9], a ret ; 3e459 -Function3e459: ; 3e459 - ld c, $32 +PassedBattleMonEntrance: ; 3e459 + ld c, 50 call DelayFrames - ld hl, $c535 - ld bc, $050b + + hlcoord 9, 7 + lb bc, 5, 11 call ClearBox + ld a, [CurPartyMon] ld [CurBattleMon], a call Function3d581 @@ -5464,7 +5483,7 @@ Function3e459: ; 3e459 call EmptyBattleTextBox call Function309d call SetPlayerTurn - jp Function3dc23 + jp SpikesDamage ; 3e489 diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 8023bf583..17885e6e6 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -2715,6 +2715,7 @@ BattleCommand90: ; 34ecc BattleCommand0a: ; 34eee +; lowersub ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVar @@ -2755,7 +2756,7 @@ BattleCommand0a: ; 34eee ld [FXAnimIDHi], a inc a ld [$c689], a - ld a, $a4 + ld a, SUBSTITUTE jp Function37e44 .asm_34f36 @@ -2908,6 +2909,8 @@ BattleCommand93: ; 34ffd BattleCommand0c: ; 35004 +; raisesub + ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVar bit SUBSTATUS_SUBSTITUTE, a @@ -2921,7 +2924,7 @@ BattleCommand0c: ; 35004 ld [FXAnimIDHi], a ld a, $2 ld [$c689], a - ld a, $a4 + ld a, SUBSTITUTE jp Function37e44 ; 35023 @@ -4621,7 +4624,7 @@ BattleCommand41: ; 35864 ld de, EnemyMoveStruct call GetMoveData .asm_3591a - call Function37e01 + call AnimateCurrentMove ld hl, GotAnEncoreText jp StdBattleTextBox @@ -4641,7 +4644,7 @@ BattleCommand42: ; 35926 jp nz, Function359cd call CheckSubstituteOpp jp nz, Function359cd - call Function37e01 + call AnimateCurrentMove ld hl, $c63f ld de, EnemyMonMaxHPLo call .asm_3597d @@ -4774,7 +4777,7 @@ BattleCommand44: ; 359e6 pop hl cp CURSE_T jr z, .asm_35a50 ; 35a0b $43 - call Function37e01 + call AnimateCurrentMove call SwitchTurn .asm_35a13 @@ -4828,13 +4831,13 @@ BattleCommand45: ; 35a53 ld a, BATTLE_VARS_SUBSTATUS5_OPP call _GetBattleVar set SUBSTATUS_LOCK_ON, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, TookAimText jp StdBattleTextBox .asm_35a6e - call Function37e77 + call AnimateFailedMove jp PrintDidntAffect ; 35a74 @@ -4846,7 +4849,7 @@ BattleCommand46: ; 35a74 ld a, [InLinkBattle] and a jr z, .asm_35a83 ; 35a7b $6 - call Function37e77 + call AnimateFailedMove jp PrintNothingHappened .asm_35a83 call CheckSubstituteOpp @@ -4931,13 +4934,13 @@ BattleCommand46: ; 35a74 ld [hl], a .asm_35b04 call GetMoveName - call Function37e01 + call AnimateCurrentMove ld hl, SketchedText jp StdBattleTextBox .asm_35b10 - call Function37e77 + call AnimateFailedMove jp PrintDidntAffect ; 35b16 @@ -4948,7 +4951,7 @@ BattleCommand47: ; 35b16 ; If the opponent isn't frozen, raise Attack one stage. ; If the opponent is frozen, thaw them and raise Accuracy two stages. - call Function37e01 + call AnimateCurrentMove ld a, BATTLE_VARS_STATUS_OPP call _GetBattleVar @@ -5036,7 +5039,7 @@ BattleCommand48: ; 35b33 call UpdateMoveData jp ResetTurn .asm_35ba3 - call Function37e77 + call AnimateFailedMove jp TryPrintButItFailed .asm_35ba9 @@ -5123,7 +5126,7 @@ BattleCommand49: ; 35bff ld a, BATTLE_VARS_SUBSTATUS5 call _GetBattleVar set 6, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, DestinyBondEffectText jp StdBattleTextBox ; 35c0f @@ -5205,7 +5208,7 @@ BattleCommand4a: ; 35c0f ld [hl], e .asm_35c82 push de - call Function37e01 + call AnimateCurrentMove pop de ld a, d ld [$d265], a @@ -5285,7 +5288,7 @@ BattleCommand4c: ; 35cc9 add hl, bc dec d jr nz, .asm_35ce9 - call Function37e01 + call AnimateCurrentMove ld hl, BellChimedText call StdBattleTextBox @@ -5560,7 +5563,7 @@ BattleCommand14: ; 35e5c call CheckSubstituteOpp jr nz, .asm_35ec6 - call Function37e01 + call AnimateCurrentMove ld b, $7 ld a, [$cfc0] and a @@ -5588,7 +5591,7 @@ BattleCommand14: ; 35e5c .asm_35ec6 push hl - call Function37e77 + call AnimateFailedMove pop hl jp StdBattleTextBox ; 35ece @@ -5735,14 +5738,14 @@ BattleCommand2f: ; 35f2c .asm_35fb8 push hl - call Function37e77 + call AnimateFailedMove pop hl jp StdBattleTextBox ; 35fc0 Function35fc0: ; 35fc0 - call Function37e01 + call AnimateCurrentMove call Function35ff5 jp RefreshBattleHuds ; 35fc9 @@ -7036,7 +7039,7 @@ BattleCommand22: ; 366e5 ld [bc], a ld a, $1 ld [$c689], a - call Function37e01 + call AnimateCurrentMove jp EndMoveEffect ; 3671a @@ -7147,7 +7150,7 @@ BattleCommanda0: ; 36778 jr nc, .asm_367df ; 367b7 $26 .asm_367b9 - call Function37e77 + call AnimateFailedMove jp PrintButItFailed .asm_367bf @@ -7255,7 +7258,7 @@ BattleCommand23: ; 3680f call UpdateEnemyMonInParty ld a, $1 ld [$c689], a - call Function37e01 + call AnimateCurrentMove ld c, $14 call DelayFrames ld hl, $c4a1 @@ -7291,7 +7294,7 @@ BattleCommand23: ; 3680f ld hl, DraggedOutText call StdBattleTextBox - ld hl, Function3dc23 + ld hl, SpikesDamage jp CallBattleCore .asm_368ca @@ -7349,7 +7352,7 @@ BattleCommand23: ; 3680f call UpdateBattleMonInParty ld a, $1 ld [$c689], a - call Function37e01 + call AnimateCurrentMove ld c, $14 call DelayFrames ld hl, $c535 @@ -7388,7 +7391,7 @@ BattleCommand23: ; 3680f ld hl, DraggedOutText call StdBattleTextBox - ld hl, Function3dc23 + ld hl, SpikesDamage jp CallBattleCore .asm_36969 @@ -7402,7 +7405,7 @@ BattleCommand23: ; 3680f call Function36804 ld a, $1 ld [$c689], a - call Function37e01 + call AnimateCurrentMove ld c, $14 call DelayFrames pop af @@ -7944,11 +7947,11 @@ BattleCommand28: ; 36c7e bit 1, [hl] jr nz, .asm_36c92 ; 36c85 $b set 1, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, MistText jp StdBattleTextBox .asm_36c92 - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 36c98 @@ -7961,11 +7964,11 @@ BattleCommand29: ; 36c98 bit 2, [hl] jr nz, .asm_36cac ; 36c9f $b set 2, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, GettingPumpedText jp StdBattleTextBox .asm_36cac - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 36cb2 @@ -8067,7 +8070,7 @@ BattleCommand2a: ; 36d3b ld a, [hl] ld [$d265], a call GetItemName - call Function37e77 + call AnimateFailedMove ld hl, ProtectedByText jp StdBattleTextBox @@ -8076,7 +8079,7 @@ BattleCommand2a: ; 36d3b call _GetBattleVar bit 7, [hl] jr z, .asm_36d65 - call Function37e77 + call AnimateFailedMove ld hl, AlreadyConfusedText jp StdBattleTextBox @@ -8114,7 +8117,7 @@ Function36d70: ; 36d70 jr z, .asm_36d99 cp EFFECT_SWAGGER jr z, .asm_36d99 - call Function37e01 + call AnimateCurrentMove .asm_36d99 ld de, $0103 @@ -8164,7 +8167,7 @@ BattleCommand30: ; 36dc7 ld a, [hl] ld [$d265], a call GetItemName - call Function37e77 + call AnimateFailedMove ld hl, ProtectedByText jp StdBattleTextBox .asm_36def @@ -8195,7 +8198,7 @@ BattleCommand30: ; 36dc7 jr nz, .asm_36e52 ; 36e1f $31 ld c, $1e call DelayFrames - call Function37e01 + call AnimateCurrentMove ld a, $1 ld [$ffd4], a ld a, BATTLE_VARS_STATUS_OPP @@ -8209,13 +8212,13 @@ BattleCommand30: ; 36dc7 ld hl, Function3dde9 jp CallBattleCore .asm_36e49 - call Function37e77 + call AnimateFailedMove ld hl, AlreadyParalyzedText jp StdBattleTextBox .asm_36e52 jp PrintDidntAffect2 .asm_36e55 - call Function37e77 + call AnimateFailedMove jp PrintDoesntAffect ; 36e5b @@ -8445,7 +8448,7 @@ BattleCommand33: ; 36f46 add hl, bc ld [hl], $5 call GetMoveName - call Function37e01 + call AnimateCurrentMove ld hl, LearnedMoveText jp StdBattleTextBox .asm_36f9a @@ -8478,21 +8481,21 @@ BattleCommand35: ; 36f9d bit 7, [hl] jr nz, .asm_36fd8 ; 36fc5 $11 set 7, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, WasSeededText jp StdBattleTextBox .asm_36fd2 - call Function37e77 + call AnimateFailedMove jp PrintDoesntAffect .asm_36fd8 - call Function37e77 + call AnimateFailedMove ld hl, EvadedText jp StdBattleTextBox ; 36fe1 BattleCommand36: ; 36fe1 - call Function37e01 + call AnimateCurrentMove callba Function1060e5 jp PrintNothingHappened ; 36fed @@ -8548,7 +8551,7 @@ BattleCommand37: ; 36fed swap c add c ld [de], a - call Function37e01 + call AnimateCurrentMove ld hl, DisabledMove ld a, [hBattleTurn] and a @@ -8656,7 +8659,7 @@ BattleCommand1f: ; 3707f inc hl jr .asm_370bd ; 370d1 $ea .asm_370d3 - call Function37e77 + call AnimateFailedMove jp PrintButItFailed .asm_370d9 call BattleRandom @@ -8684,7 +8687,7 @@ BattleCommand1f: ; 3707f ld [de], a ld [$d265], a callba GetTypeName - call Function37e01 + call AnimateCurrentMove ld hl, TransformedTypeText jp StdBattleTextBox ; 3710e @@ -8710,7 +8713,7 @@ BattleCommand20: ; 3710e pop af ld [hBattleTurn], a - call Function37e01 + call AnimateCurrentMove ld hl, EliminatedStatsText jp StdBattleTextBox @@ -8788,7 +8791,7 @@ BattleCommand2c: ; 3713e ld hl, GetMaxHP call CallBattleCore .asm_371a9 - call Function37e01 + call AnimateCurrentMove call SwitchTurn ld hl, Function3ccef call CallBattleCore @@ -8799,7 +8802,7 @@ BattleCommand2c: ; 3713e jp StdBattleTextBox .asm_371c4 - call Function37e77 + call AnimateFailedMove ld hl, HPIsFullText jp StdBattleTextBox ; 371cd @@ -8833,7 +8836,7 @@ BattleCommand2d: ; 371cd ld a, BATTLE_VARS_SUBSTATUS5 call _GetBattleVar set 3, [hl] - call Function372e7 + call ResetActorDisable ld hl, BattleMonSpecies ld de, EnemyMonSpecies ld a, [hBattleTurn] @@ -8960,7 +8963,7 @@ BattleSideCopy: ; 372c6 Function372d2: ; 372d2 - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 372d8 @@ -8979,7 +8982,7 @@ Function372d8: ; 372d8 ; 372e7 -Function372e7: ; 372e7 +ResetActorDisable: ; 372e7 ld a, [hBattleTurn] and a jr z, .player @@ -9035,11 +9038,11 @@ BattleCommand2e: ; 372fc ld hl, ReflectEffectText .asm_37331 - call Function37e01 + call AnimateCurrentMove jp StdBattleTextBox .asm_37337 - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 3733d @@ -9075,7 +9078,7 @@ PrintButItFailed: ; 3734e Function37354: ; 37354 - call Function37e77 + call AnimateFailedMove ; fallthrough ; 37357 @@ -9094,7 +9097,7 @@ PrintDidntAffect: ; 37360 PrintDidntAffect2: ; 37366 - call Function37e77 + call AnimateFailedMove ld hl, DidntAffect1Text ; 'it didn't affect' ld de, DidntAffect2Text ; 'it didn't affect' jp Function35157 @@ -9216,12 +9219,12 @@ BattleCommand51: ; 37517 ; Otherwise trap the opponent. set SUBSTATUS_CANT_RUN, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, CantEscapeNowText jp StdBattleTextBox .failed - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 37536 @@ -9361,7 +9364,7 @@ BattleCommand5f: ; 377ce jr nz, .asm_377f2 set 7, [hl] - call Function37e01 + call AnimateCurrentMove ; 'fell in love!' ld hl, FellInLoveText @@ -9474,10 +9477,10 @@ BattleCommand61: ; 37874 .asm_37889 ld a, [$d265] and a - jp z, Function37e77 + jp z, AnimateFailedMove ld a, [AttackMissed] and a - jp nz, Function37e77 + jp nz, AnimateFailedMove push bc call BattleRandom ld b, a @@ -9503,7 +9506,7 @@ BattleCommand61: ; 37874 pop bc ld a, $3 ld [$c689], a - call Function37e01 + call AnimateCurrentMove call SwitchTurn ld hl, AICheckPlayerMaxHP ld a, [hBattleTurn] @@ -9529,7 +9532,7 @@ BattleCommand61: ; 37874 call SwitchTurn call Function37ed5 jr nc, .asm_37904 ; 378f9 $9 - call Function37e77 + call AnimateFailedMove ld hl, RefusedGiftText call StdBattleTextBox .asm_37904 @@ -9589,11 +9592,11 @@ BattleCommand64: ; 37939 set 2, [hl] ld a, $5 ld [de], a - call Function37e01 + call AnimateCurrentMove ld hl, CoveredByVeilText jp StdBattleTextBox .asm_3795c - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 37962 @@ -9678,74 +9681,81 @@ BattleCommand67: ; 379c9 and a jp nz, .Enemy - call Function37ae9 - jp z, Function37aab + +; Need something to switch to + call CheckAnyOtherAlivePartyMons + jp z, FailedBatonPass call UpdateBattleMonInParty - call Function37e01 + call AnimateCurrentMove ld c, 50 call DelayFrames +; Transition into switchmon menu call Function1d6e callba Function3d2f7 - callba Function3d380 + + callba ForcePickSwitchMonInBattle + +; Return to battle scene call ClearPalettes callba Function3ed9f call Function1c17 call ClearSprites - hlcoord 1, 0 lb bc, 4, 10 call ClearBox - ld b, 1 call GetSGBLayout call Function32f9 call Function37a67 +; Mobile link battles handle entrances differently callba Function3d2e0 jp c, EndMoveEffect - ld hl, Function3e459 + ld hl, PassedBattleMonEntrance call CallBattleCore - call Function37ab1 + + call ResetBatonPassStatus ret + .Enemy + +; Wildmons don't have anything to switch to ld a, [IsInBattle] dec a - jp z, Function37aab + jp z, FailedBatonPass - call Function37af6 - jp z, Function37aab + call CheckAnyOtherAliveEnemyMons + jp z, FailedBatonPass call UpdateEnemyMonInParty - call Function37e01 + call AnimateCurrentMove call Function37a82 +; Mobile link battles handle entrances differently callba Function3d2e0 jp c, EndMoveEffect +; Passed enemy PartyMon entrance xor a ld [$c718], a - ld hl, Function3d517 call CallBattleCore - ld hl, Function3d57a call CallBattleCore - ld a, 1 ld [$d265], a - ld hl, Function3ecab call CallBattleCore - ld hl, Function3dc23 + ld hl, SpikesDamage call CallBattleCore - jr Function37ab1 + jr ResetBatonPassStatus ; 37a67 @@ -9758,20 +9768,17 @@ Function37a67: ; 37a67 ld [$d0ec], a call Function1d6e - ld hl, Function3e8e4 call CallBattleCore - call Function1c17 xor a ld [$d0ec], a - ret ; 37a82 -Function37a82; 37a82 +Function37a82: ; 37a82 ld a, [InLinkBattle] and a ret z @@ -9779,54 +9786,65 @@ Function37a82; 37a82 call Function1d6e ld hl, Function3e8e4 call CallBattleCore + ld a, [OTPartyCount] - add $4 + add 4 ld b, a ld a, [$d430] - cp $4 + cp 4 jr c, .asm_37aa0 - cp b jr c, .asm_37aa8 .asm_37aa0 ld a, [CurOTMon] - add $4 + add 4 ld [$d430], a .asm_37aa8 - jp $1c17 + jp Function1c17 ; 37aab -Function37aab: ; 37aab - call Function37e77 +FailedBatonPass: ; 37aab + call AnimateFailedMove jp PrintButItFailed ; 37ab1 -Function37ab1: ; 37ab1 +ResetBatonPassStatus: ; 37ab1 +; Reset status changes that aren't passed by Baton Pass. + +; Nightmare isn't passed. ld a, BATTLE_VARS_STATUS call GetBattleVar - and 7 - jr nz, .asm_37ac1 + and SLP + jr nz, .ok + ld a, BATTLE_VARS_SUBSTATUS1 call _GetBattleVar - res 0, [hl] + res SUBSTATUS_NIGHTMARE, [hl] +.ok -.asm_37ac1 - call Function372e7 +; Disable isn't passed. + call ResetActorDisable + +; Attraction isn't passed. ld hl, PlayerSubStatus1 - res 7, [hl] + res SUBSTATUS_IN_LOVE, [hl] ld hl, EnemySubStatus1 - res 7, [hl] + res SUBSTATUS_IN_LOVE, [hl] ld hl, PlayerSubStatus5 + ld a, BATTLE_VARS_SUBSTATUS5 call _GetBattleVar res 3, [hl] res 4, [hl] + +; New mon hasn't used a move yet. ld a, BATTLE_VARS_LAST_MOVE call _GetBattleVar ld [hl], 0 + xor a ld [$c730], a ld [$c731], a @@ -9834,17 +9852,17 @@ Function37ab1: ; 37ab1 ; 37ae9 -Function37ae9: ; 37ae9 +CheckAnyOtherAlivePartyMons: ; 37ae9 ld hl, PartyMon1CurHP ld a, [PartyCount] ld d, a ld a, [CurBattleMon] ld e, a - jr Function37b01 + jr CheckAnyOtherAliveMons ; 37af6 -Function37af6: ; 37af6 +CheckAnyOtherAliveEnemyMons: ; 37af6 ld hl, OTPartyMon1CurHP ld a, [OTPartyCount] ld d, a @@ -9854,17 +9872,21 @@ Function37af6: ; 37af6 ; fallthrough ; 37b01 -Function37b01: ; 37b01 +CheckAnyOtherAliveMons: ; 37b01 +; Check for nonzero HP starting from partymon +; HP at hl for d partymons, besides current mon e. + +; Return nz if any are alive. + xor a ld b, a ld c, a -.asm_37b04 +.loop ld a, c cp d - jr z, .asm_37b1a - + jr z, .done cp e - jr z, .asm_37b11 + jr z, .next ld a, [hli] or b @@ -9872,15 +9894,16 @@ Function37b01: ; 37b01 ld a, [hld] or b ld b, a -.asm_37b11 + +.next push bc - ld bc, $30 + ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc inc c - jr .asm_37b04 + jr .loop -.asm_37b1a +.done ld a, b and a ret @@ -10021,7 +10044,7 @@ BattleCommand6a6c: ; 37b7e ld a, BANK(GetMaxHP) rst FarCall - call Function37e01 + call AnimateCurrentMove call SwitchTurn callab Function3ccef @@ -10034,7 +10057,7 @@ BattleCommand6a6c: ; 37b7e jp StdBattleTextBox .Full - call Function37e77 + call AnimateFailedMove ; 'hp is full!' ld hl, HPIsFullText @@ -10065,7 +10088,7 @@ BattleCommand6e: ; 37bf4 ld [Weather], a ld a, 5 ld [WeatherCount], a - call Function37e01 + call AnimateCurrentMove ld hl, DownpourText jp StdBattleTextBox ; 37c07 @@ -10077,7 +10100,7 @@ BattleCommand6f: ; 37c07 ld [Weather], a ld a, 5 ld [WeatherCount], a - call Function37e01 + call AnimateCurrentMove ld hl, SunGotBrightText jp StdBattleTextBox ; 37c1a @@ -10096,7 +10119,7 @@ BattleCommand95: ; 37c1a jr nc, .asm_37c4f push bc - call Function37e01 + call AnimateCurrentMove pop bc callab Function3cc3f call UpdateUserInParty @@ -10112,7 +10135,7 @@ BattleCommand95: ; 37c1a ld hl, BellyDrumText jp StdBattleTextBox .asm_37c4f - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 37c55 @@ -10139,7 +10162,7 @@ BattleCommand96: ; 37c55 dec b jr nz, .asm_37c67 ; 37c6d $f8 pop hl - call Function37e77 + call AnimateFailedMove jp PrintButItFailed .asm_37c76 pop hl @@ -10158,7 +10181,7 @@ BattleCommand96: ; 37c55 .asm_37c89 call Function365fd .asm_37c8c - call Function37e01 + call AnimateCurrentMove ld hl, CopiedStatsText jp StdBattleTextBox ; 37c95 @@ -10328,7 +10351,7 @@ BattleCommand9c: ; 37d34 .asm_37d87 pop bc call ResetDamage - call Function37e77 + call AnimateFailedMove call PrintButItFailed jp EndMoveEffect ; 37d94 @@ -10427,7 +10450,7 @@ Function37de9: ; 37de9 ; 37e01 -Function37e01: ; 37e01 +AnimateCurrentMove: ; 37e01 push hl push de push bc @@ -10533,7 +10556,7 @@ CallBattleCore: ; 37e73 ; 37e77 -Function37e77: ; 37e77 +AnimateFailedMove: ; 37e77 call BattleCommand0a call BattleCommandaa jp BattleCommand0c diff --git a/battle/effects/curse.asm b/battle/effects/curse.asm index c9dc3d374..fc08beae6 100644 --- a/battle/effects/curse.asm +++ b/battle/effects/curse.asm @@ -41,7 +41,7 @@ BattleCommand54: ; 37588 ld a, $1 ld [$c689], a - call Function37e01 + call AnimateCurrentMove ld a, $2 call Function36532 call SwitchTurn @@ -71,7 +71,7 @@ BattleCommand54: ; 37588 jr nz, .failed set 1, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, GetHalfMaxHP call CallBattleCore ld hl, Function3cc3f @@ -81,7 +81,7 @@ BattleCommand54: ; 37588 jp StdBattleTextBox .failed - call Function37e77 + call AnimateFailedMove jp PrintButItFailed @@ -91,7 +91,7 @@ BattleCommand54: ; 37588 ld b, $8 ; ABILITY call GetStatName - call Function37e77 + call AnimateFailedMove ld hl, WontRiseAnymoreText jp StdBattleTextBox ; 37618 diff --git a/battle/effects/endure.asm b/battle/effects/endure.asm index b8ab5dee4..f449dcebd 100644 --- a/battle/effects/endure.asm +++ b/battle/effects/endure.asm @@ -10,7 +10,7 @@ BattleCommand5a: ; 3766f call _GetBattleVar set SUBSTATUS_ENDURE, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, BracedItselfText jp StdBattleTextBox diff --git a/battle/effects/foresight.asm b/battle/effects/foresight.asm index 144bd1e26..7a8f33493 100644 --- a/battle/effects/foresight.asm +++ b/battle/effects/foresight.asm @@ -14,7 +14,7 @@ BattleCommand57: ; 376a0 jr nz, .failed set SUBSTATUS_IDENTIFIED, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, IdentifiedText jp StdBattleTextBox diff --git a/battle/effects/mirror_move.asm b/battle/effects/mirror_move.asm index 09d62f6b2..60748bdae 100644 --- a/battle/effects/mirror_move.asm +++ b/battle/effects/mirror_move.asm @@ -15,7 +15,7 @@ BattleCommand1b: ; 373c9 jr nz, .use .failed - call Function37e77 + call AnimateFailedMove ld hl, MirrorMoveFailedText call StdBattleTextBox diff --git a/battle/effects/nightmare.asm b/battle/effects/nightmare.asm index 1573979a8..cd3210cab 100644 --- a/battle/effects/nightmare.asm +++ b/battle/effects/nightmare.asm @@ -28,12 +28,12 @@ BattleCommand52: ; 37536 ; Otherwise give the opponent a nightmare. set SUBSTATUS_NIGHTMARE, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, StartedNightmareText jp StdBattleTextBox .failed - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 37563 diff --git a/battle/effects/perish_song.asm b/battle/effects/perish_song.asm index 06a22aa56..423d299fa 100644 --- a/battle/effects/perish_song.asm +++ b/battle/effects/perish_song.asm @@ -30,12 +30,12 @@ BattleCommand58: ; 376c2 ld [EnemyPerishCount], a .done - call Function37e01 + call AnimateCurrentMove ld hl, StartPerishText jp StdBattleTextBox .failed - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 376f8 diff --git a/battle/effects/protect.asm b/battle/effects/protect.asm index a24df82d7..a28c0461e 100644 --- a/battle/effects/protect.asm +++ b/battle/effects/protect.asm @@ -7,7 +7,7 @@ BattleCommand55: ; 37618 call _GetBattleVar set SUBSTATUS_PROTECT, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, ProtectedItselfText jp StdBattleTextBox @@ -73,7 +73,7 @@ ProtectChance: ; 3762c .failed xor a ld [de], a - call Function37e77 + call AnimateFailedMove call PrintButItFailed scf ret diff --git a/battle/effects/sandstorm.asm b/battle/effects/sandstorm.asm index c90e22957..b4f782721 100644 --- a/battle/effects/sandstorm.asm +++ b/battle/effects/sandstorm.asm @@ -9,12 +9,12 @@ BattleCommand59: ; 376f8 ld [Weather], a ld a, 5 ld [WeatherCount], a - call Function37e01 + call AnimateCurrentMove ld hl, SandstormBrewedText jp StdBattleTextBox .failed - call Function37e77 + call AnimateFailedMove jp PrintButItFailed ; 37718 diff --git a/battle/effects/spikes.asm b/battle/effects/spikes.asm index d40bbfe8c..2d9357941 100644 --- a/battle/effects/spikes.asm +++ b/battle/effects/spikes.asm @@ -17,7 +17,7 @@ BattleCommand56: ; 37683 set SCREENS_SPIKES, [hl] - call Function37e01 + call AnimateCurrentMove ld hl, SpikesText jp StdBattleTextBox diff --git a/main.asm b/main.asm index c927ef1b5..e022cbc95 100644 --- a/main.asm +++ b/main.asm @@ -36789,7 +36789,7 @@ ClearBattleRAM: ; 2ef18 xor a call ByteFill - callab Function3d867 + callab ResetEnemyStatLevels call Function1fbf @@ -37438,8 +37438,8 @@ Function3846c: ; 3846c .asm_384a3 ld a, $1 ld [$d264], a - callab Function3d834 - callab Function3d867 + callab NewEnemyMonStatus + callab ResetEnemyStatLevels ld hl, PlayerSubStatus1 res 7, [hl] callba Function3d4e1