DoPlayerTurn: ; 34000 call SetPlayerTurn ld a, [$d0ec] and a ret nz jr DoTurn ; 3400a DoEnemyTurn: ; 3400a call SetEnemyTurn ld a, [InLinkBattle] and a jr z, DoTurn ld a, [wBattleAction] cp $e jr z, DoTurn cp NUM_MOVES ret nc ; fallthrough ; 3401d DoTurn: ; 3401d ; Read in and execute the user's move effects for this turn. xor a ld [$c6b4], a ; Effect command checkturn is called for every move. call CheckTurn ld a, [$c6b4] and a ret nz call UpdateMoveData ; 3402c DoMove: ; 3402c ; Get the user's move effect. ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar ld c, a ld b, 0 ld hl, MoveEffectsPointers add hl, bc add hl, bc ld a, BANK(MoveEffectsPointers) call GetFarHalfword ld de, BattleScriptBuffer .GetMoveEffect ld a, BANK(MoveEffects) call GetFarByte inc hl ld [de], a inc de cp $ff jr nz, .GetMoveEffect ; Start at the first command. ld hl, BattleScriptBuffer ld a, l ld [BattleScriptBufferLoc], a ld a, h ld [BattleScriptBufferLoc + 1], a .ReadMoveEffectCommand ; ld a, [BattleScriptBufferLoc++] ld a, [BattleScriptBufferLoc] ld l, a ld a, [BattleScriptBufferLoc + 1] ld h, a ld a, [hli] push af ld a, l ld [BattleScriptBufferLoc], a ld a, h ld [BattleScriptBufferLoc + 1], a pop af ; $fe is used to terminate branches without ending the read cycle. cp $fe ret nc ; The rest of the commands (01-af) are read from BattleCommandPointers. push bc dec a ld c, a ld b, 0 ld hl, BattleCommandPointers add hl, bc add hl, bc pop bc ld a, BANK(BattleCommandPointers) call GetFarHalfword call .DoMoveEffectCommand jr .ReadMoveEffectCommand .DoMoveEffectCommand jp [hl] ; 34084 CheckTurn: BattleCommand01: ; 34084 ; checkturn ; Repurposed as hardcoded turn handling. Useless as a command. ; Move $ff immediately ends the turn. ld a, BATTLE_VARS_MOVE call GetBattleVar inc a jp z, Function34385 xor a ld [AttackMissed], a ld [EffectFailed], a ld [$c689], a ld [AlreadyDisobeyed], a ld [AlreadyFailed], a ld [$c73e], a ld a, 10 ; 1.0 ld [TypeModifier], a ld a, [hBattleTurn] and a jp nz, CheckEnemyTurn CheckPlayerTurn: ld hl, PlayerSubStatus4 bit SUBSTATUS_RECHARGE, [hl] jr z, .no_recharge res SUBSTATUS_RECHARGE, [hl] ld hl, MustRechargeText call StdBattleTextBox call CantMove jp Function34385 .no_recharge ld hl, BattleMonStatus ld a, [hl] and SLP jr z, .not_asleep dec a ld [BattleMonStatus], a and SLP jr z, .woke_up xor a ld [$cfca], a ld de, ANIM_SLP call FarPlayBattleAnimation jr .fast_asleep .woke_up ld hl, WokeUpText call StdBattleTextBox call CantMove call UpdateBattleMonInParty ld hl, Function3df48 call CallBattleCore ld a, $1 ld [$ffd4], a ld hl, PlayerSubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep .fast_asleep ld hl, FastAsleepText call StdBattleTextBox ; Snore and Sleep Talk bypass sleep. ld a, [CurPlayerMove] cp SNORE jr z, .not_asleep cp SLEEP_TALK jr z, .not_asleep call CantMove jp Function34385 .not_asleep ld hl, BattleMonStatus bit FRZ, [hl] jr z, .not_frozen ; Flame Wheel and Sacred Fire thaw the user. ld a, [CurPlayerMove] cp FLAME_WHEEL jr z, .not_frozen cp SACRED_FIRE jr z, .not_frozen ld hl, FrozenSolidText call StdBattleTextBox call CantMove jp Function34385 .not_frozen ld hl, PlayerSubStatus3 bit SUBSTATUS_FLINCHED, [hl] jr z, .not_flinched res SUBSTATUS_FLINCHED, [hl] ld hl, FlinchedText call StdBattleTextBox call CantMove jp Function34385 .not_flinched ld hl, PlayerDisableCount ld a, [hl] and a jr z, .not_disabled dec a ld [hl], a and $f jr nz, .not_disabled ld [hl], a ld [DisabledMove], a ld hl, DisabledNoMoreText call StdBattleTextBox .not_disabled ld a, [PlayerSubStatus3] add a jr nc, .not_confused ld hl, PlayerConfuseCount dec [hl] jr nz, .confused ld hl, PlayerSubStatus3 res SUBSTATUS_CONFUSED, [hl] ld hl, ConfusedNoMoreText call StdBattleTextBox jr .not_confused .confused ld hl, IsConfusedText call StdBattleTextBox xor a ld [$cfca], a ld de, ANIM_CONFUSED call FarPlayBattleAnimation ; 50% chance of hitting itself call BattleRandom cp $80 jr nc, .not_confused ; clear confussion-dependent substatus ld hl, PlayerSubStatus3 ld a, [hl] and 1 << SUBSTATUS_CONFUSED ld [hl], a call HitConfusion call CantMove jp Function34385 .not_confused ld a, [PlayerSubStatus1] add a ; bit SUBSTATUS_ATTRACT jr nc, .not_infatuated ld hl, InLoveWithText call StdBattleTextBox xor a ld [$cfca], a ld de, ANIM_IN_LOVE call FarPlayBattleAnimation ; 50% chance of infatuation call BattleRandom cp $80 jr c, .not_infatuated ld hl, InfatuationText call StdBattleTextBox call CantMove jp Function34385 .not_infatuated ; We can't disable a move that doesn't exist. ld a, [DisabledMove] and a jr z, .no_disabled_move ; Are we using the disabled move? ld hl, CurPlayerMove cp [hl] jr nz, .no_disabled_move call MoveDisabled call CantMove jp Function34385 .no_disabled_move ld hl, BattleMonStatus bit PAR, [hl] ret z ; 25% chance to be fully paralyzed call BattleRandom cp $3f ret nc ld hl, FullyParalyzedText call StdBattleTextBox call CantMove jp Function34385 ; 341f0 CantMove: ; 341f0 ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVarAddr res SUBSTATUS_ENCORED, [hl] ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr ld a, [hl] and $ff ^ (1< ReflectCount inc bc ld a, 5 ld [bc], a ld hl, ReflectEffectText .asm_37331 call AnimateCurrentMove jp StdBattleTextBox .failed call AnimateFailedMove jp PrintButItFailed ; 3733d PrintDoesntAffect: ; 3733d ; 'it doesn't affect' ld hl, DoesntAffectText jp StdBattleTextBox ; 37343 PrintNothingHappened: ; 37343 ; 'but nothing happened!' ld hl, NothingHappenedText jp StdBattleTextBox ; 37349 TryPrintButItFailed: ; 37349 ld a, [AlreadyFailed] and a ret nz ; fallthrough ; 3734e PrintButItFailed: ; 3734e ; 'but it failed!' ld hl, ButItFailedText jp StdBattleTextBox ; 37354 Function37354: ; 37354 call AnimateFailedMove ; fallthrough ; 37357 Function37357: ; 37357 ld hl, ButItFailedText ; 'but it failed!' ld de, ItFailedText ; 'it failed!' jp Function35157 ; 37360 PrintDidntAffect: ; 37360 ; 'it didn't affect' ld hl, DidntAffect1Text jp StdBattleTextBox ; 37366 PrintDidntAffect2: ; 37366 call AnimateFailedMove ld hl, DidntAffect1Text ; 'it didn't affect' ld de, DidntAffect2Text ; 'it didn't affect' jp Function35157 ; 37372 PrintParalyze: ; 37372 ; 'paralyzed! maybe it can't attack!' ld hl, ParalyzedText jp StdBattleTextBox ; 37378 CheckSubstituteOpp: ; 37378 ld a, BATTLE_VARS_SUBSTATUS4_OPP call GetBattleVar bit SUBSTATUS_SUBSTITUTE, a ret ; 37380 BattleCommand1a: ; 37380 callba Function10610d ld a, $4 ld [$cfca], a ld c, $3 call DelayFrames ld a, BATTLE_VARS_STATUS call GetBattleVarAddr xor a ld [hli], a inc hl ld [hli], a ld [hl], a ld a, $1 ld [$c689], a call BattleCommand0a call Function37e36 ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVarAddr res SUBSTATUS_LEECH_SEED, [hl] ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVarAddr res SUBSTATUS_DESTINY_BOND, [hl] call Function37ed5 ret nc callba DrawPlayerHUD callba Function3e043 call WaitBGMap jp RefreshBattleHuds ; 373c9 INCLUDE "battle/effects/mirror_move.asm" INCLUDE "battle/effects/metronome.asm" CheckUserMove: ; 37462 ; Return z if the user has move a. ld b, a ld de, BattleMonMoves ld a, [hBattleTurn] and a jr z, .ok ld de, EnemyMonMoves .ok ld c, NUM_MOVES .loop ld a, [de] inc de cp b ret z dec c jr nz, .loop ld a, 1 and a ret ; 3747b ResetTurn: ; 3747b ld hl, $c732 ld a, [hBattleTurn] and a jr z, .asm_37486 ld hl, $c733 .asm_37486 ld [hl], 1 xor a ld [AlreadyDisobeyed], a call DoMove jp EndMoveEffect ; 37492 INCLUDE "battle/effects/thief.asm" BattleCommand51: ; 37517 ; arenatrap ; Doesn't work on an absent opponent. call CheckHiddenOpponent jr nz, .failed ; Don't trap if the opponent is already trapped. ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarAddr bit SUBSTATUS_CANT_RUN, [hl] jr nz, .failed ; Otherwise trap the opponent. set SUBSTATUS_CANT_RUN, [hl] call AnimateCurrentMove ld hl, CantEscapeNowText jp StdBattleTextBox .failed call AnimateFailedMove jp PrintButItFailed ; 37536 INCLUDE "battle/effects/nightmare.asm" BattleCommand53: ; 37563 ; defrost ; Thaw the user. ld a, BATTLE_VARS_STATUS call GetBattleVarAddr bit FRZ, [hl] ret z res FRZ, [hl] ; Don't update the enemy's party struct in a wild battle. ld a, [hBattleTurn] and a jr z, .party ld a, [IsInBattle] dec a jr z, .done .party ld a, PartyMon1Status - PartyMon1 call UserPartyAttr res FRZ, [hl] .done call RefreshBattleHuds ld hl, WasDefrostedText jp StdBattleTextBox ; 37588 INCLUDE "battle/effects/curse.asm" INCLUDE "battle/effects/protect.asm" INCLUDE "battle/effects/endure.asm" INCLUDE "battle/effects/spikes.asm" INCLUDE "battle/effects/foresight.asm" INCLUDE "battle/effects/perish_song.asm" INCLUDE "battle/effects/sandstorm.asm" INCLUDE "battle/effects/rollout.asm" BattleCommand5d: ; 37791 ; unused ret ; 37792 BattleCommand5e: ; 37792 ; furycutter ld hl, PlayerFuryCutterCount ld a, [hBattleTurn] and a jr z, .go ld hl, EnemyFuryCutterCount .go ld a, [AttackMissed] and a jp nz, ResetFuryCutterCount inc [hl] ; Damage capped at 5 turns' worth (16x). ld a, [hl] ld b, a cp 6 jr c, .checkdouble ld b, 5 .checkdouble dec b ret z ; Double the damage ld hl, CurDamage + 1 sla [hl] dec hl rl [hl] jr nc, .checkdouble ; No overflow ld a, $ff ld [hli], a ld [hl], a ret ; 377be ResetFuryCutterCount: ; 377be push hl ld hl, PlayerFuryCutterCount ld a, [hBattleTurn] and a jr z, .reset ld hl, EnemyFuryCutterCount .reset xor a ld [hl], a pop hl ret ; 377ce BattleCommand5f: ; 377ce ; attract ld a, [AttackMissed] and a jr nz, .failed call Function377f5 jr c, .failed call CheckHiddenOpponent jr nz, .failed ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVarAddr bit SUBSTATUS_IN_LOVE, [hl] jr nz, .failed set SUBSTATUS_IN_LOVE, [hl] call AnimateCurrentMove ; 'fell in love!' ld hl, FellInLoveText jp StdBattleTextBox .failed jp Function37354 ; 377f5 Function377f5: ; 377f5 ld a, PartyMon1Species - PartyMon1 call BattlePartyAttr ld a, [hl] ld [CurPartySpecies], a ld a, [CurBattleMon] ld [CurPartyMon], a xor a ld [MonType], a callba GetGender jr c, .asm_37849 ld b, 1 jr nz, .asm_37815 dec b .asm_37815 push bc ld a, [TempEnemyMonSpecies] ld [CurPartySpecies], a ld hl, EnemyMonDVs ld a, [EnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a jr z, .asm_37829 ld hl, $c6f2 .asm_37829 ld a, [hli] ld [$d123], a ld a, [hl] ld [$d124], a ld a, 3 ld [MonType], a callba GetGender pop bc jr c, .asm_37849 ld a, 1 jr nz, .asm_37844 dec a .asm_37844 xor b jr z, .asm_37849 and a ret .asm_37849 scf ret ; 3784b BattleCommand60: ; 3784b ; happinesspower push bc ld hl, BattleMonHappiness ld a, [hBattleTurn] and a jr z, .ok ld hl, EnemyMonHappiness .ok xor a ld [hMultiplicand], a ld [hMultiplicand + 1], a ld a, [hl] ld [hMultiplicand + 2], a ld a, 10 ld [hMultiplier], a call Multiply ld a, 25 ld [hDivisor], a ld b, 4 call Divide ld a, [hQuotient + 2] ld d, a pop bc ret ; 37874 BattleCommand61: ; 37874 ; present ld a, [InLinkBattle] cp $3 jr z, .asm_3787d push bc push de .asm_3787d call BattleCommand07 ld a, [InLinkBattle] cp $3 jr z, .asm_37889 pop de pop bc .asm_37889 ld a, [$d265] and a jp z, AnimateFailedMove ld a, [AttackMissed] and a jp nz, AnimateFailedMove push bc call BattleRandom ld b, a ld hl, .table_37907 ld c, 0 .asm_378a1 ld a, [hli] cp $ff jr z, .asm_378b7 ; 378a4 $11 cp b jr nc, .asm_378ad ; 378a7 $4 inc c inc hl jr .asm_378a1 ; 378ab $f4 .asm_378ad ld a, c ld [$c689], a call Function37de9 ld d, [hl] pop bc ret .asm_378b7 pop bc ld a, $3 ld [$c689], a call AnimateCurrentMove call SwitchTurn ld hl, AICheckPlayerMaxHP ld a, [hBattleTurn] and a jr z, .asm_378ce ; 378c9 $3 ld hl, AICheckEnemyMaxHP .asm_378ce ld a, BANK(AICheckPlayerMaxHP) rst FarCall jr c, .asm_378f3 ; 378d1 $20 ld hl, GetQuarterMaxHP call CallBattleCore call SwitchTurn ld hl, Function3ccef call CallBattleCore call SwitchTurn ld hl, RegainedHealthText call StdBattleTextBox call SwitchTurn call UpdateOpponentInParty jr .asm_37904 ; 378f1 $11 .asm_378f3 call SwitchTurn call Function37ed5 jr nc, .asm_37904 ; 378f9 $9 call AnimateFailedMove ld hl, RefusedGiftText call StdBattleTextBox .asm_37904 jp EndMoveEffect .table_37907 db 40 percent, 40 db 70 percent + 1, 80 db 80 percent, 120 db $ff ; 3790e BattleCommand63: ; 3790e ; frustrationpower push bc ld hl, BattleMonHappiness ld a, [hBattleTurn] and a jr z, .asm_3791a ; 37915 $3 ld hl, EnemyMonHappiness .asm_3791a ld a, $ff sub [hl] ld [$ffb6], a xor a ld [$ffb4], a ld [$ffb5], a ld a, 10 ld [$ffb7], a call Multiply ld a, 25 ld [$ffb7], a ld b, 4 call Divide ld a, [$ffb6] ld d, a pop bc ret ; 37939 BattleCommand64: ; 37939 ; safeguard ld hl, PlayerScreens ld de, PlayerSafeguardCount ld a, [hBattleTurn] and a jr z, .ok ld hl, EnemyScreens ld de, EnemySafeguardCount .ok bit SCREENS_SAFEGUARD, [hl] jr nz, .failed set SCREENS_SAFEGUARD, [hl] ld a, 5 ld [de], a call AnimateCurrentMove ld hl, CoveredByVeilText jp StdBattleTextBox .failed call AnimateFailedMove jp PrintButItFailed ; 37962 Function37962: ; 37962 push hl ld hl, EnemyScreens ld a, [hBattleTurn] and a jr z, .asm_3796e ld hl, PlayerScreens .asm_3796e bit SCREENS_SAFEGUARD, [hl] pop hl ret ; 37972 BattleCommand65: ; 37972 ; checksafeguard ld hl, EnemyScreens ld a, [hBattleTurn] and a jr z, .asm_3797d ; 37978 $3 ld hl, PlayerScreens .asm_3797d bit SCREENS_SAFEGUARD, [hl] ret z ld a, 1 ld [AttackMissed], a call BattleCommandaa ld hl, SafeguardProtectText call StdBattleTextBox jp EndMoveEffect ; 37991 BattleCommand66: ; 37991 ; getmagnitude push bc call BattleRandom ld b, a ld hl, .Magnitudes .loop ld a, [hli] cp b jr nc, .ok inc hl inc hl jr .loop .ok ld d, [hl] push de inc hl ld a, [hl] ld [$d265], a call BattleCommandaa ld hl, MagnitudeText call StdBattleTextBox pop de pop bc ret .Magnitudes ; /255, BP, magnitude db 13, 10, 4 db 38, 30, 5 db 89, 50, 6 db 166, 70, 7 db 217, 90, 8 db 242, 110, 9 db 255, 150, 10 ; 379c9 BattleCommand67: ; 379c9 ; batonpass ld a, [hBattleTurn] and a jp nz, .Enemy ; Need something to switch to call CheckAnyOtherAlivePartyMons jp z, FailedBatonPass call UpdateBattleMonInParty call AnimateCurrentMove ld c, 50 call DelayFrames ; Transition into switchmon menu call Function1d6e callba Function3d2f7 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 BatonPass_LinkPlayerSwitch ; Mobile link battles handle entrances differently callba Function3d2e0 jp c, EndMoveEffect ld hl, PassedBattleMonEntrance call CallBattleCore call ResetBatonPassStatus ret .Enemy ; Wildmons don't have anything to switch to ld a, [IsInBattle] dec a ; WILDMON jp z, FailedBatonPass call CheckAnyOtherAliveEnemyMons jp z, FailedBatonPass call UpdateEnemyMonInParty call AnimateCurrentMove call BatonPass_LinkEnemySwitch ; 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, SpikesDamage call CallBattleCore jr ResetBatonPassStatus ; 37a67 BatonPass_LinkPlayerSwitch: ; 37a67 ld a, [InLinkBattle] and a ret z ld a, 1 ld [$d0ec], a call Function1d6e ld hl, Function3e8e4 call CallBattleCore call Function1c17 xor a ld [$d0ec], a ret ; 37a82 BatonPass_LinkEnemySwitch: ; 37a82 ld a, [InLinkBattle] and a ret z call Function1d6e ld hl, Function3e8e4 call CallBattleCore ld a, [OTPartyCount] add NUM_MOVES ld b, a ld a, [wBattleAction] cp NUM_MOVES jr c, .asm_37aa0 cp b jr c, .asm_37aa8 .asm_37aa0 ld a, [CurOTMon] add NUM_MOVES ld [wBattleAction], a .asm_37aa8 jp Function1c17 ; 37aab FailedBatonPass: ; 37aab call AnimateFailedMove jp PrintButItFailed ; 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 SLP jr nz, .ok ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVarAddr res SUBSTATUS_NIGHTMARE, [hl] .ok ; Disable isn't passed. call ResetActorDisable ; Attraction isn't passed. ld hl, PlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] ld hl, EnemySubStatus1 res SUBSTATUS_IN_LOVE, [hl] ld hl, PlayerSubStatus5 ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarAddr res SUBSTATUS_TRANSFORMED, [hl] res 4, [hl] ; New mon hasn't used a move yet. ld a, BATTLE_VARS_LAST_MOVE call GetBattleVarAddr ld [hl], 0 xor a ld [$c730], a ld [$c731], a ret ; 37ae9 CheckAnyOtherAlivePartyMons: ; 37ae9 ld hl, PartyMon1HP ld a, [PartyCount] ld d, a ld a, [CurBattleMon] ld e, a jr CheckAnyOtherAliveMons ; 37af6 CheckAnyOtherAliveEnemyMons: ; 37af6 ld hl, OTPartyMon1HP ld a, [OTPartyCount] ld d, a ld a, [CurOTMon] ld e, a ; fallthrough ; 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 .loop ld a, c cp d jr z, .done cp e jr z, .next ld a, [hli] or b ld b, a ld a, [hld] or b ld b, a .next push bc ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc inc c jr .loop .done ld a, b and a ret ; 37b1d BattleCommand68: ; 37b1d ; pursuit ; Double damage if the opponent is switching. ld hl, wEnemyIsSwitching ld a, [hBattleTurn] and a jr z, .ok ld hl, wPlayerIsSwitching .ok ld a, [hl] and a ret z ld hl, CurDamage + 1 sla [hl] dec hl rl [hl] ret nc ld a, $ff ld [hli], a ld [hl], a ret ; 37b39 BattleCommand69: ; 37b39 ; clearhazards ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVarAddr bit SUBSTATUS_LEECH_SEED, [hl] jr z, .asm_37b4a ; 37b40 $8 res SUBSTATUS_LEECH_SEED, [hl] ld hl, ShedLeechSeedText call StdBattleTextBox .asm_37b4a ld hl, PlayerScreens ld de, $c730 ld a, [hBattleTurn] and a jr z, .asm_37b5b ; 37b53 $6 ld hl, EnemyScreens ld de, $c731 .asm_37b5b bit SCREENS_SPIKES, [hl] jr z, .asm_37b69 ; 37b5d $a res SCREENS_SPIKES, [hl] ld hl, BlewSpikesText push de call StdBattleTextBox pop de .asm_37b69 ld a, [de] and a ret z xor a ld [de], a ld hl, ReleasedByText jp StdBattleTextBox ; 37b74 BattleCommand6a: ; 37b74 ; healmorn ld b, MORN jr BattleCommand6a6c ; 37b78 BattleCommand6b: ; 37b78 ; healday ld b, DAY jr BattleCommand6a6c ; 37b7c BattleCommand6c: ; 37b7c ; healnite ld b, NITE ; fallthrough ; 37b7e BattleCommand6a6c: ; 37b7e ; Time- and weather-sensitive heal. ld hl, BattleMonMaxHP ld de, BattleMonHP ld a, [hBattleTurn] and a jr z, .start ld hl, EnemyMonMaxHP ld de, EnemyMonHP .start ; Index for .Multipliers ; Default restores half max HP. ld c, 2 ; Don't bother healing if HP is already full. push bc call StringCmp pop bc jr z, .Full ; Don't factor in time of day in link battles. ld a, [InLinkBattle] and a jr nz, .Weather ld a, [TimeOfDay] cp b jr z, .Weather dec c .Weather ld a, [Weather] and a jr z, .Heal ; x2 in sun ; /2 in rain/sandstorm inc c cp WEATHER_SUN jr z, .Heal dec c dec c .Heal ld b, 0 ld hl, .Multipliers add hl, bc add hl, bc ld a, [hli] ld h, [hl] ld l, a ld a, BANK(GetMaxHP) rst FarCall call AnimateCurrentMove call SwitchTurn callab Function3ccef call SwitchTurn call UpdateUserInParty ; 'regained health!' ld hl, RegainedHealthText jp StdBattleTextBox .Full call AnimateFailedMove ; 'hp is full!' ld hl, HPIsFullText jp StdBattleTextBox .Multipliers dw GetEighthMaxHP dw GetQuarterMaxHP dw GetHalfMaxHP dw GetMaxHP ; 37be8 BattleCommand6d: ; 37be8 ; hiddenpower ld a, [AttackMissed] and a ret nz callba HiddenPowerDamage ret ; 37bf4 BattleCommand6e: ; 37bf4 ; startrain ld a, WEATHER_RAIN ld [Weather], a ld a, 5 ld [WeatherCount], a call AnimateCurrentMove ld hl, DownpourText jp StdBattleTextBox ; 37c07 BattleCommand6f: ; 37c07 ; startsun ld a, WEATHER_SUN ld [Weather], a ld a, 5 ld [WeatherCount], a call AnimateCurrentMove ld hl, SunGotBrightText jp StdBattleTextBox ; 37c1a BattleCommand95: ; 37c1a ; bellydrum call BattleCommand77 ld a, [AttackMissed] and a jr nz, .asm_37c4f callab GetHalfMaxHP callab Function3ccde jr nc, .asm_37c4f push bc call AnimateCurrentMove pop bc callab Function3cc3f call UpdateUserInParty ld a, 5 .asm_37c41 push af call BattleCommand77 pop af dec a jr nz, .asm_37c41 ld hl, BellyDrumText jp StdBattleTextBox .asm_37c4f call AnimateFailedMove jp PrintButItFailed ; 37c55 BattleCommand96: ; 37c55 ; psychup ld hl, EnemyStatLevels ld de, PlayerStatLevels ld a, [hBattleTurn] and a jr z, .asm_37c64 ; 37c5e $4 push hl ld h, d ld l, e pop de .asm_37c64 push hl ld b, $8 .asm_37c67 ld a, [hli] cp $7 jr nz, .asm_37c76 ; 37c6a $a dec b jr nz, .asm_37c67 ; 37c6d $f8 pop hl call AnimateFailedMove jp PrintButItFailed .asm_37c76 pop hl ld b, $8 .asm_37c79 ld a, [hli] ld [de], a inc de dec b jr nz, .asm_37c79 ; 37c7d $fa ld a, [hBattleTurn] and a jr nz, .asm_37c89 ; 37c82 $5 call Function365d7 jr .asm_37c8c ; 37c87 $3 .asm_37c89 call Function365fd .asm_37c8c call AnimateCurrentMove ld hl, CopiedStatsText jp StdBattleTextBox ; 37c95 BattleCommand9a: ; 37c95 ; mirrorcoat ld a, 1 ld [AttackMissed], a ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar and a ret z ld b, a callab GetMoveEffect ld a, b cp EFFECT_MIRROR_COAT ret z call BattleCommanda3 ld a, [$d265] and a ret z call Function36abf ret z ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar dec a ld de, StringBuffer1 call GetMoveData ld a, [$d075] and a ret z ld a, [$d076] cp SPECIAL ret c ld hl, CurDamage ld a, [hli] or [hl] ret z ld a, [hl] add a ld [hld], a ld a, [hl] adc a ld [hl], a jr nc, .capped ld a, $ff ld [hli], a ld [hl], a .capped xor a ld [AttackMissed], a ret ; 37ce6 BattleCommand9d: ; 37ce6 ; doubleminimizedamage ld hl, $c6fa ld a, [hBattleTurn] and a jr z, .ok ld hl, $c6fe .ok ld a, [hl] and a ret z ld hl, CurDamage + 1 sla [hl] dec hl rl [hl] ret nc ld a, $ff ld [hli], a ld [hl], a ret ; 37d02 BattleCommand9e: ; 37d02 ; skipsuncharge ld a, [Weather] cp WEATHER_SUN ret nz ld b, $39 ; charge jp SkipToBattleCommand ; 37d0d BattleCommand9b: ; 37d0d ; checkfuturesight ld hl, $c71d ld de, $c727 ld a, [hBattleTurn] and a jr z, .ok ld hl, $c71e ld de, $c729 .ok ld a, [hl] and a ret z cp 1 ret nz ld [hl], 0 ld a, [de] inc de ld [CurDamage], a ld a, [de] ld [CurDamage + 1], a ld b, $9c ; futuresight jp SkipToBattleCommand ; 37d34 BattleCommand9c: ; 37d34 ; futuresight call Function34548 jr nz, .asm_37d4b ; 37d37 $12 ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar ld b, a ld a, BATTLE_VARS_LAST_COUNTER_MOVE call GetBattleVarAddr ld [hl], b ld a, BATTLE_VARS_LAST_MOVE call GetBattleVarAddr ld [hl], b .asm_37d4b ld hl, $c71d ld a, [hBattleTurn] and a jr z, .asm_37d56 ; 37d51 $3 ld hl, $c71e .asm_37d56 ld a, [hl] and a jr nz, .asm_37d87 ; 37d58 $2d ld a, $4 ld [hl], a call BattleCommand0a call BattleCommandaa ld hl, ForesawAttackText call StdBattleTextBox call BattleCommand0c ld de, $c727 ld a, [hBattleTurn] and a jr z, .asm_37d77 ; 37d72 $3 ld de, $c729 .asm_37d77 ld hl, CurDamage ld a, [hl] ld [de], a ld [hl], 0 inc hl inc de ld a, [hl] ld [de], a ld [hl], 0 jp EndMoveEffect .asm_37d87 pop bc call ResetDamage call AnimateFailedMove call PrintButItFailed jp EndMoveEffect ; 37d94 BattleCommand9f: ; 37d94 ; thunderaccuracy ld a, BATTLE_VARS_MOVE_TYPE call GetBattleVarAddr inc hl ld a, [Weather] cp WEATHER_RAIN jr z, .rain cp WEATHER_SUN ret nz ld [hl], 50 percent + 1 ret .rain ld [hl], 100 percent ret ; 37daa CheckHiddenOpponent: ; 37daa ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret ; 37db2 GetUserItem: ; 37db2 ; Return the effect of the user's item in bc, and its id at hl. ld hl, BattleMonItem ld a, [hBattleTurn] and a jr z, .go ld hl, EnemyMonItem .go ld b, [hl] jp GetItem ; 37dc1 GetOpponentItem: ; 37dc1 ; Return the effect of the opponent's item in bc, and its id at hl. ld hl, EnemyMonItem ld a, [hBattleTurn] and a jr z, .go ld hl, BattleMonItem .go ld b, [hl] jp GetItem ; 37dd0 GetItem: ; 37dd0 ; Return the effect of item b in bc. ld a, b and a ret z push hl ld hl, ItemAttributes + 2 dec a ld c, a ld b, 0 ld a, Item2Attributes - Item1Attributes call AddNTimes ld a, BANK(ItemAttributes) call GetFarHalfword ld b, l ld c, h pop hl ret ; 37de9 Function37de9: ; 37de9 push hl push de push bc ld a, [$c689] push af call BattleCommand0a pop af ld [$c689], a call Function37e19 call BattleCommand0c pop bc pop de pop hl ret ; 37e01 AnimateCurrentMove: ; 37e01 push hl push de push bc ld a, [$c689] push af call BattleCommand0a pop af ld [$c689], a call Function37e36 call BattleCommand0c pop bc pop de pop hl ret ; 37e19 Function37e19: ; 37e19 xor a ld [FXAnimIDHi], a ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar and a ret z ld [FXAnimIDLo], a ld a, [hBattleTurn] and a ld a, 1 jr z, .asm_37e30 ld a, 4 .asm_37e30 ld [$cfca], a jp Function37e47 ; 37e36 Function37e36: ; 37e36 xor a ld [$cfca], a ld [FXAnimIDHi], a ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar and a ret z ; fallthrough ; 37e44 Function37e44: ; 37e44 ld [FXAnimIDLo], a ; fallthrough ; 37e47 Function37e47: ; 37e47 push hl push de push bc callab PlayBattleAnim pop bc pop de pop hl ret ; 37e54 Function37e54: ; 37e54 ld a, e ld [FXAnimIDLo], a ld a, d ld [FXAnimIDHi], a xor a ld [$cfca], a push hl push de push bc call SwitchTurn callab PlayBattleAnim call SwitchTurn pop bc pop de pop hl ret ; 37e73 CallBattleCore: ; 37e73 ld a, BANK(BattleCore) rst FarCall ret ; 37e77 AnimateFailedMove: ; 37e77 call BattleCommand0a call BattleCommandaa jp BattleCommand0c ; 37e80 BattleCommandaa: ; 37e80 ; movedelay ; Wait 40 frames. ld c, 40 jp DelayFrames ; 37e85 BattleCommand38: ; 37e85 ; cleartext ; Used in multi-hit moves. ld hl, .text jp BattleTextBox .text db "@" ; 37e8c SkipToBattleCommand: ; 37e8c ; Skip over commands until reaching command b. ld a, [BattleScriptBufferLoc + 1] ld h, a ld a, [BattleScriptBufferLoc] ld l, a .asm_37e94 ld a, [hli] cp b jr nz, .asm_37e94 ld a, h ld [BattleScriptBufferLoc + 1], a ld a, l ld [BattleScriptBufferLoc], a ret ; 37ea1 GetMoveAttr: ; 37ea1 ; Assuming hl = Moves + x, return attribute x of move a. push bc ld bc, MOVE_LENGTH call AddNTimes call GetMoveByte pop bc ret ; 37ead GetMoveData: ; 37ead ; Copy move struct a to de. ld hl, Moves ld bc, MOVE_LENGTH call AddNTimes ld a, Bank(Moves) jp FarCopyBytes ; 37ebb GetMoveByte: ; 37ebb ld a, BANK(Moves) jp GetFarByte ; 37ec0 Function37ec0: ; 37ec0 callba Functionfbd54 ret ; 37ec7 Function37ec7: ; 37ec7 callba Functionfbd71 ret ; 37ece Function37ece: ; 37ece callba Functionfbd69 ret ; 37ed5 Function37ed5: ; 37ed5 ; Related to mobile link battles. push hl push de push bc callba CheckBattleScene pop bc pop de pop hl ret ; 37ee2