2018-06-24 07:09:41 -07:00
|
|
|
DoPlayerTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
call SetPlayerTurn
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
jr DoTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoEnemyTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
call SetEnemyTurn
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, DoTurn
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, [wBattleAction]
|
2018-10-20 21:52:10 -07:00
|
|
|
cp BATTLEACTION_STRUGGLE
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, DoTurn
|
2015-11-06 11:45:10 -08:00
|
|
|
cp BATTLEACTION_SWITCH1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Read in and execute the user's move effects for this turn.
|
|
|
|
|
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [wTurnEnded], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Effect command checkturn is called for every move.
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckTurn
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, [wTurnEnded]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
call UpdateMoveData
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoMove:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Get the user's move effect.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, MoveEffectsPointers
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BANK(MoveEffectsPointers)
|
|
|
|
call GetFarHalfword
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wBattleScriptBuffer
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetMoveEffect:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BANK(MoveEffects)
|
|
|
|
call GetFarByte
|
|
|
|
inc hl
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2018-06-01 00:04:36 -07:00
|
|
|
cp endmove_command
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .GetMoveEffect
|
|
|
|
|
|
|
|
; Start at the first command.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleScriptBuffer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ReadMoveEffectCommand:
|
2018-01-23 14:39:09 -08:00
|
|
|
; ld a, [wBattleScriptBufferAddress++]
|
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
|
|
|
push af
|
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
|
2015-04-13 21:39:54 -07:00
|
|
|
; endturn_command (-2) is used to terminate branches without ending the read cycle.
|
|
|
|
cp endturn_command
|
2013-03-26 17:39:44 -07:00
|
|
|
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
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
|
|
|
|
ld a, BANK(BattleCommandPointers)
|
|
|
|
call GetFarHalfword
|
|
|
|
|
|
|
|
call .DoMoveEffectCommand
|
|
|
|
|
|
|
|
jr .ReadMoveEffectCommand
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoMoveEffectCommand:
|
2017-06-09 14:01:10 -07:00
|
|
|
jp hl
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
CheckTurn:
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkturn
|
|
|
|
|
|
|
|
; Repurposed as hardcoded turn handling. Useless as a command.
|
|
|
|
|
|
|
|
; Move $ff immediately ends the turn.
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-09 13:41:09 -08:00
|
|
|
jp z, EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
|
|
|
ld [wEffectFailed], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
|
|
|
ld [wAlreadyFailed], a
|
2016-01-09 13:28:22 -08:00
|
|
|
ld [wSomeoneIsRampaging], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
ld a, EFFECTIVE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jp nz, CheckEnemyTurn
|
|
|
|
|
|
|
|
CheckPlayerTurn:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_RECHARGE, [hl]
|
|
|
|
jr z, .no_recharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MustRechargeText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_recharge
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonStatus], a
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .woke_up
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WokeUpText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateBattleMonInParty
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdatePlayerHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus1
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
|
|
|
jr .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FastAsleepText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPlayerMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SLEEP_TALK
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_asleep
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit FRZ, [hl]
|
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flame Wheel and Sacred Fire thaw the user.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurPlayerMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLAME_WHEEL
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SACRED_FIRE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FrozenSolidText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jr z, .not_flinched
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FlinchedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_flinched
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerDisableCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
and $f
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .not_disabled
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, DisabledNoMoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_disabled
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ConfusedNoMoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.confused
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, IsConfusedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of hitting itself
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-09 14:05:19 -07:00
|
|
|
; clear confusion-dependent substatus
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_CONFUSED
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
call HitConfusion
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_confused
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSubStatus1]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_ATTRACT
|
|
|
|
jr nc, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InLoveWithText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_IN_LOVE
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of infatuation
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr c, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InfatuationText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; We can't disable a move that doesn't exist.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Are we using the disabled move?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurPlayerMove
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call MoveDisabled
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_disabled_move
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit PAR, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 25% chance to be fully paralyzed
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 25 percent
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld hl, FullyParalyzedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CantMove:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ROLLOUT, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-05-23 09:48:14 -07:00
|
|
|
and $ff ^ (1 << SUBSTATUS_BIDE | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_CHARGED)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
call ResetFuryCutterCount
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLY
|
2015-11-06 19:36:06 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
cp DIG
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
.fly_dig
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
jp AppearUserRaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
OpponentCantMove:
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-10-10 04:45:39 -07:00
|
|
|
jp BattleCommand_SwitchTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckEnemyTurn:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_RECHARGE, [hl]
|
|
|
|
jr z, .no_recharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, MustRechargeText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_recharge
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
|
|
|
jr z, .not_asleep
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyMonStatus], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FastAsleepText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .fast_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.woke_up
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, WokeUpText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateEnemyMonInParty
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdateEnemyHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus1
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
|
|
|
jr .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.fast_asleep
|
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SLEEP_TALK
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_asleep
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_asleep
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit FRZ, [hl]
|
|
|
|
jr z, .not_frozen
|
2018-01-10 14:30:27 -08:00
|
|
|
|
|
|
|
; Flame Wheel and Sacred Fire thaw the user.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMove]
|
2014-06-13 21:18:14 -07:00
|
|
|
cp FLAME_WHEEL
|
|
|
|
jr z, .not_frozen
|
|
|
|
cp SACRED_FIRE
|
|
|
|
jr z, .not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, FrozenSolidText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_frozen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jr z, .not_flinched
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, FlinchedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_flinched
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyDisableCount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .not_disabled
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
and $f
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .not_disabled
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEnemyDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, DisabledNoMoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_disabled
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus3]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_CONFUSED
|
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, ConfusedNoMoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2014-06-13 21:18:14 -07:00
|
|
|
jr .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.confused
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, IsConfusedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of hitting itself
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nc, .not_confused
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; clear confusion-dependent substatus
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySubStatus3
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_CONFUSED
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
ld hl, HurtItselfText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2019-03-03 16:55:28 -08:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call HitSelfInConfusion
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2019-03-03 16:55:28 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flicker the monster pic unless flying or underground.
|
|
|
|
ld de, ANIM_HIT_CONFUSION
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
call z, PlayFXAnimID
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
|
|
|
call DoEnemyDamage
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_confused
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySubStatus1]
|
2014-06-13 21:18:14 -07:00
|
|
|
add a ; bit SUBSTATUS_ATTRACT
|
|
|
|
jr nc, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InLoveWithText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-12-19 01:47:39 -08:00
|
|
|
ld de, ANIM_IN_LOVE
|
2013-03-26 17:39:44 -07:00
|
|
|
call FarPlayBattleAnimation
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 50% chance of infatuation
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
cp 50 percent + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr c, .not_infatuated
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, InfatuationText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.not_infatuated
|
|
|
|
|
|
|
|
; We can't disable a move that doesn't exist.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Are we using the disabled move?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurEnemyMove
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .no_disabled_move
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call MoveDisabled
|
|
|
|
|
|
|
|
call CantMove
|
2015-11-09 13:41:09 -08:00
|
|
|
jp EndTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.no_disabled_move
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2014-06-13 21:18:14 -07:00
|
|
|
bit PAR, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; 25% chance to be fully paralyzed
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 25 percent
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld hl, FullyParalyzedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call CantMove
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EndTurn:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [wTurnEnded], a
|
2013-03-26 17:39:44 -07:00
|
|
|
jp ResetDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MoveDisabled:
|
2014-06-13 21:18:14 -07:00
|
|
|
; Make sure any charged moves fail
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_CHARGED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call GetMoveName
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, DisabledMoveText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HitConfusion:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, HurtItselfText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call HitSelfInConfusion
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Flicker the monster pic unless flying or underground.
|
|
|
|
ld de, ANIM_HIT_CONFUSION
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
call z, PlayFXAnimID
|
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
ld hl, UpdatePlayerHUD
|
2013-12-31 00:25:38 -08:00
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
|
|
|
call DoPlayerDamage
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckObedience:
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkobedience
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; Enemy can't disobey
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; If we've already checked this turn
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAlreadyDisobeyed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; No obedience in link battles
|
|
|
|
; (since no handling exists for enemy)
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; If the monster's id doesn't match the player's,
|
|
|
|
; some conditions need to be met.
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_ID
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
jr nz, .obeylevel
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
ret z
|
|
|
|
|
|
|
|
.obeylevel
|
2014-06-13 21:18:14 -07:00
|
|
|
; The maximum obedience level is constrained by owned badges:
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, wJohtoBadges
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; risingbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit RISINGBADGE, [hl]
|
2017-12-25 13:21:31 -08:00
|
|
|
ld a, MAX_LEVEL + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; stormbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit STORMBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 70
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; fogbadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit FOGBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 50
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; hivebadge
|
2015-11-07 18:04:54 -08:00
|
|
|
bit HIVEBADGE, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 30
|
|
|
|
jr nz, .getlevel
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; no badges
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 10
|
|
|
|
|
|
|
|
.getlevel
|
|
|
|
; c = obedience level
|
|
|
|
; d = monster level
|
|
|
|
; b = c + d
|
|
|
|
|
|
|
|
ld b, a
|
|
|
|
ld c, a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
|
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; No overflow (this should never happen)
|
|
|
|
jr nc, .checklevel
|
|
|
|
ld b, $ff
|
|
|
|
|
|
|
|
.checklevel
|
|
|
|
; If the monster's level is lower than the obedience level, it will obey.
|
|
|
|
ld a, c
|
|
|
|
cp d
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
; Random number from 0 to obedience level + monster level
|
|
|
|
.rand1
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
swap a
|
|
|
|
cp b
|
|
|
|
jr nc, .rand1
|
|
|
|
|
|
|
|
; The higher above the obedience level the monster is,
|
|
|
|
; the more likely it is to disobey.
|
|
|
|
cp c
|
|
|
|
ret c
|
|
|
|
|
|
|
|
; Sleep-only moves have separate handling, and a higher chance of
|
|
|
|
; being ignored. Lazy monsters like their sleep.
|
|
|
|
call IgnoreSleepOnly
|
|
|
|
ret c
|
|
|
|
|
|
|
|
; Another random number from 0 to obedience level + monster level
|
|
|
|
.rand2
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr nc, .rand2
|
|
|
|
|
|
|
|
; A second chance.
|
|
|
|
cp c
|
|
|
|
jr c, .UseInstead
|
|
|
|
|
|
|
|
; No hope of using a move now.
|
|
|
|
|
|
|
|
; b = number of levels the monster is above the obedience level
|
|
|
|
ld a, d
|
|
|
|
sub c
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; The chance of napping is the difference out of 256.
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
swap a
|
|
|
|
sub b
|
|
|
|
jr c, .Nap
|
|
|
|
|
|
|
|
; The chance of not hitting itself is the same.
|
|
|
|
cp b
|
|
|
|
jr nc, .DoNothing
|
|
|
|
|
|
|
|
ld hl, WontObeyText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
call HitConfusion
|
2015-12-26 15:11:55 -08:00
|
|
|
jp .EndDisobedience
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nap:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
|
|
|
swap a
|
2014-06-13 21:18:14 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Nap
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleMonStatus], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, BeganToNapText
|
|
|
|
jr .Print
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoNothing:
|
2018-01-11 09:00:01 -08:00
|
|
|
; 4 random choices
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-11 09:00:01 -08:00
|
|
|
and %11
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld hl, LoafingAroundText
|
2018-01-11 09:00:01 -08:00
|
|
|
and a ; 0
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, WontObeyText
|
2018-01-11 09:00:01 -08:00
|
|
|
dec a ; 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, TurnedAwayText
|
2018-01-11 09:00:01 -08:00
|
|
|
dec a ; 2
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Print
|
|
|
|
|
|
|
|
ld hl, IgnoredOrdersText
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Print:
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
jp .EndDisobedience
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.UseInstead:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Can't use another move if the monster only has one!
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonMoves + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
; Don't bother trying to handle Disable.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wDisabledMove]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr nz, .DoNothing
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld de, wBattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetTotalPP:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
dec c
|
|
|
|
jr z, .CheckMovePP
|
|
|
|
|
|
|
|
; Stop at undefined moves.
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
jr nz, .GetTotalPP
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckMovePP:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; Can't use another move if only one move has PP.
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr z, .DoNothing
|
|
|
|
|
|
|
|
; Make sure we can actually use the move once we get there.
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
ld a, [w2DMenuNumRows]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; Save the move we originally picked for afterward.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
push af
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.RandomMove:
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_MOVES
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp b
|
|
|
|
jr nc, .RandomMove
|
|
|
|
|
|
|
|
; Not the move we were trying to use.
|
|
|
|
cp c
|
|
|
|
jr z, .RandomMove
|
|
|
|
|
|
|
|
; Make sure it has PP.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurMoveNum], a
|
|
|
|
ld hl, wBattleMonPP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .RandomMove
|
|
|
|
|
|
|
|
; Use it.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurPlayerMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call SetPlayerTurn
|
|
|
|
call UpdateMoveData
|
|
|
|
call DoMove
|
|
|
|
|
|
|
|
; Restore original move choice.
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurMoveNum], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.EndDisobedience:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wLastPlayerMove], a
|
|
|
|
ld [wLastPlayerCounterMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
; Break Encore too.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPlayerEncoreCount], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IgnoreSleepOnly:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
; Snore and Sleep Talk bypass sleep.
|
2013-03-26 17:39:44 -07:00
|
|
|
cp SNORE
|
|
|
|
jr z, .CheckSleep
|
|
|
|
cp SLEEP_TALK
|
|
|
|
jr z, .CheckSleep
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckSleep:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-17 12:52:32 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
; 'ignored orders…sleeping!'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, IgnoredSleepingText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call EndMoveEffect
|
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_UsedMoveText:
|
2013-03-26 17:39:44 -07:00
|
|
|
; usedmovetext
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DisplayUsedMoveText
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckUserIsCharging:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [wPlayerCharging] ; player
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .end
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [wEnemyCharging] ; enemy
|
2013-03-26 17:39:44 -07:00
|
|
|
.end
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DoTurn:
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonPP
|
|
|
|
ld de, wPlayerSubStatus3
|
|
|
|
ld bc, wPlayerTurnsTaken
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-10-07 18:27:32 -07:00
|
|
|
jr z, .proceed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonPP
|
|
|
|
ld de, wEnemySubStatus3
|
|
|
|
ld bc, wEnemyTurnsTaken
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
.proceed
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If we've gotten this far, this counts as a turn.
|
|
|
|
ld a, [bc]
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp STRUGGLE
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [de]
|
2014-08-13 19:44:56 -07:00
|
|
|
and 1 << SUBSTATUS_IN_LOOP | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
call .consume_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jp nz, EndMoveEffect
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
; SubStatus5
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2015-12-26 18:59:03 -08:00
|
|
|
inc de
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [de]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPartyMon1PP
|
|
|
|
ld a, [wCurBattleMon]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
; mimic this part entirely if wildbattle
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .wild
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOTPartyMon1PP
|
|
|
|
ld a, [wCurOTMon]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetPartyLocation
|
|
|
|
push hl
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckMimicUsed
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.consume_pp
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2015-11-06 11:45:10 -08:00
|
|
|
jr z, .okay
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
.okay
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
and PP_MASK
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .out_of_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.wild
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
2015-11-06 11:45:10 -08:00
|
|
|
jr z, .mimic
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
|
|
|
ret z
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
.mimic
|
2015-11-09 13:41:09 -08:00
|
|
|
ld hl, wWildMonPP
|
2015-11-06 17:55:16 -08:00
|
|
|
call .consume_pp
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.out_of_pp
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
; get move effect
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
; continuous?
|
|
|
|
ld hl, .continuousmoves
|
2013-03-27 13:19:51 -07:00
|
|
|
ld de, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
call IsInArray
|
|
|
|
|
|
|
|
; 'has no pp left for [move]'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, HasNoPPLeftText
|
2013-03-26 17:39:44 -07:00
|
|
|
jr c, .print
|
|
|
|
; 'but no pp is left for the move'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, NoPPLeftText
|
2013-03-26 17:39:44 -07:00
|
|
|
.print
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-04-27 14:12:23 -07:00
|
|
|
ld b, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.continuousmoves
|
2013-04-27 14:12:23 -07:00
|
|
|
db EFFECT_RAZOR_WIND
|
|
|
|
db EFFECT_SKY_ATTACK
|
|
|
|
db EFFECT_SKULL_BASH
|
|
|
|
db EFFECT_SOLARBEAM
|
|
|
|
db EFFECT_FLY
|
|
|
|
db EFFECT_ROLLOUT
|
|
|
|
db EFFECT_BIDE
|
|
|
|
db EFFECT_RAMPAGE
|
2018-01-10 14:30:27 -08:00
|
|
|
db -1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckMimicUsed:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurMoveNum]
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, MON_MOVES
|
2013-05-02 23:43:44 -07:00
|
|
|
call UserPartyAttr
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp MIMIC
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .mimic
|
2016-04-10 11:42:14 -07:00
|
|
|
;
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp MIMIC
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Critical:
|
2013-03-26 17:39:44 -07:00
|
|
|
; critical
|
|
|
|
|
|
|
|
; Determine whether this attack's hit will be critical.
|
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_POWER
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
|
|
|
ld a, [wEnemyMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nz, .Item
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
|
|
|
ld a, [wBattleMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Item:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, 0
|
|
|
|
|
|
|
|
cp CHANSEY
|
|
|
|
jr nz, .Farfetchd
|
|
|
|
ld a, [hl]
|
|
|
|
cp LUCKY_PUNCH
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
ld c, 2
|
|
|
|
jr .Tally
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Farfetchd:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FARFETCH_D
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
ld a, [hl]
|
|
|
|
cp STICK
|
|
|
|
jr nz, .FocusEnergy
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
ld c, 2
|
|
|
|
jr .Tally
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FocusEnergy:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_FOCUS_ENERGY, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .CheckCritical
|
|
|
|
|
|
|
|
; +1 critical level
|
|
|
|
inc c
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CheckCritical:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld de, 1
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, CriticalHitMoves
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call IsInArray
|
|
|
|
pop bc
|
|
|
|
jr nc, .ScopeLens
|
|
|
|
|
|
|
|
; +2 critical level
|
|
|
|
inc c
|
2015-12-26 18:59:03 -08:00
|
|
|
inc c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ScopeLens:
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call GetUserItem
|
|
|
|
ld a, b
|
2014-01-19 21:07:51 -08:00
|
|
|
cp HELD_CRITICAL_UP ; Increased critical chance. Only Scope Lens has this.
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
jr nz, .Tally
|
|
|
|
|
|
|
|
; +1 critical level
|
|
|
|
inc c
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Tally:
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, CriticalHitChances
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
ret nc
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2018-07-03 23:42:11 -07:00
|
|
|
INCLUDE "data/moves/critical_hit_moves.asm"
|
|
|
|
|
|
|
|
INCLUDE "data/battle/critical_hit_chances.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/triple_kick.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Stab:
|
2015-09-09 16:27:07 -07:00
|
|
|
; STAB = Same Type Attack Bonus
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp STRUGGLE
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-09-09 16:27:07 -07:00
|
|
|
jr z, .go ; Who Attacks and who Defends
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
ld e, [hl]
|
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
.go
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wCurType], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoWeatherModifiers
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoBadgeTypeBoosts
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wCurType]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .stab
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .stab
|
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .SkipStab
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 00:50:45 -07:00
|
|
|
.stab
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
add hl, bc
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage + 1], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wTypeModifier
|
2013-03-26 17:39:44 -07:00
|
|
|
set 7, [hl]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipStab:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2017-12-26 14:47:05 -08:00
|
|
|
ld hl, TypeMatchups
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.TypesLoop:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-04-19 00:50:45 -07:00
|
|
|
jr z, .end
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
; foresight
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -2
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .SkipForesightCheck
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2013-04-19 00:50:45 -07:00
|
|
|
jr nz, .end
|
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipForesightCheck:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .SkipType
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .GotMatchup
|
2013-03-26 17:39:44 -07:00
|
|
|
cp e
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .GotMatchup
|
|
|
|
jr .SkipType
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GotMatchup:
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and %10000000
|
|
|
|
ld b, a
|
2015-10-07 10:19:41 -07:00
|
|
|
; If the target is immune to the move, treat it as a miss and calculate the damage as 0
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .NotImmune
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2016-04-10 11:42:14 -07:00
|
|
|
.NotImmune:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 0], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .ok ; This is a very convoluted way to get back that we've essentially dealt no damage.
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
; Take the product and divide it by 10.
|
|
|
|
ld a, 10
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2015-10-07 10:19:41 -07:00
|
|
|
ld b, 4
|
2013-05-02 23:43:44 -07:00
|
|
|
call Divide
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2018-08-26 10:49:38 -07:00
|
|
|
ld b, a
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .ok
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2015-10-07 10:19:41 -07:00
|
|
|
.ok
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMultiplicand + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SkipType:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2013-04-19 00:50:45 -07:00
|
|
|
|
|
|
|
.end
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCheckTypeMatchup
|
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2015-11-06 17:55:16 -08:00
|
|
|
and %10000000
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCheckTypeMatchup:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-16 11:30:10 -08:00
|
|
|
jr z, CheckTypeMatchup
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonType1
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckTypeMatchup:
|
2017-01-07 16:33:38 -08:00
|
|
|
; There is an incorrect assumption about this function made in the AI related code: when
|
2018-02-03 17:40:21 -08:00
|
|
|
; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
|
|
|
|
; offensive type in a will make this function do the right thing. Since a is overwritten,
|
2017-01-07 16:33:38 -08:00
|
|
|
; this assumption is incorrect. A simple fix would be to load the move type for the
|
|
|
|
; current move into a in BattleCheckTypeMatchup, before falling through, which is
|
|
|
|
; consistent with how the rest of the code assumes this code works like.
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
ld b, [hl]
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
2014-06-18 00:55:44 -07:00
|
|
|
ld a, 10 ; 1.0
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2017-12-26 14:47:05 -08:00
|
|
|
ld hl, TypeMatchups
|
2016-04-10 11:42:14 -07:00
|
|
|
.TypesLoop:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .End
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -2
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .Next
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .End
|
|
|
|
jr .TypesLoop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Next:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp d
|
2015-10-07 10:19:41 -07:00
|
|
|
jr nz, .Nope
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .Yup
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2015-10-07 10:19:41 -07:00
|
|
|
jr z, .Yup
|
|
|
|
jr .Nope2
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nope:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2016-04-10 11:42:14 -07:00
|
|
|
.Nope2:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Yup:
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 0], a
|
|
|
|
ldh [hMultiplicand + 0], a
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wTypeMatchup]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
2014-08-13 19:44:56 -07:00
|
|
|
ld a, 10
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2014-08-13 19:44:56 -07:00
|
|
|
ld b, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
call Divide
|
|
|
|
pop bc
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2015-10-07 10:19:41 -07:00
|
|
|
jr .TypesLoop
|
2014-08-13 19:44:56 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.End:
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ResetTypeMatchup:
|
2015-11-07 05:05:57 -08:00
|
|
|
; Reset the type matchup multiplier to 1.0, if the type matchup is not 0.
|
|
|
|
; If there is immunity in play, the move automatically misses.
|
2015-11-06 17:55:16 -08:00
|
|
|
call BattleCheckTypeMatchup
|
|
|
|
ld a, [wTypeMatchup]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-23 12:47:07 -07:00
|
|
|
ld a, 10 ; 1.0
|
2015-11-07 05:05:57 -08:00
|
|
|
jr nz, .reset
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTypeModifier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-11-06 17:55:16 -08:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
.reset
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wTypeMatchup], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2017-12-26 14:47:05 -08:00
|
|
|
INCLUDE "engine/battle/ai/switch.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-22 13:23:34 -08:00
|
|
|
INCLUDE "data/types/type_matchups.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DamageVariation:
|
2013-03-26 17:39:44 -07:00
|
|
|
; damagevariation
|
|
|
|
|
|
|
|
; Modify the damage spread between 85% and 100%.
|
|
|
|
|
|
|
|
; Because of the method of division the probability distribution
|
|
|
|
; is not consistent. This makes the highest damage multipliers
|
|
|
|
; rarer than normal.
|
|
|
|
|
|
|
|
; No point in reducing 1 or 0 damage.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr nz, .go
|
|
|
|
ld a, [hl]
|
|
|
|
cp 2
|
|
|
|
ret c
|
|
|
|
|
|
|
|
.go
|
|
|
|
; Start with the maximum damage.
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 0], a
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; Multiply by 85-100%...
|
|
|
|
.loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
rrca
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 85 percent + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr c, .loop
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; ...divide by 100%...
|
|
|
|
ld a, $ff ; 100%
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $4
|
|
|
|
call Divide
|
|
|
|
|
|
|
|
; ...to get .85-1.00x damage.
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckHit:
|
2013-03-26 17:39:44 -07:00
|
|
|
; checkhit
|
|
|
|
|
|
|
|
call .DreamEater
|
|
|
|
jp z, .Miss
|
|
|
|
|
|
|
|
call .Protect
|
|
|
|
jp nz, .Miss
|
|
|
|
|
|
|
|
call .DrainSub
|
|
|
|
jp z, .Miss
|
|
|
|
|
|
|
|
call .LockOn
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
call .FlyDigMoves
|
|
|
|
jp nz, .Miss
|
|
|
|
|
|
|
|
call .ThunderRain
|
|
|
|
ret z
|
|
|
|
|
2014-08-13 19:44:56 -07:00
|
|
|
call .XAccuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2014-06-23 12:47:07 -07:00
|
|
|
; Perfect-accuracy moves
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_ALWAYS_HIT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
call .StatModifiers
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wPlayerMoveStruct + MOVE_ACC]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .BrightPowder
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [wEnemyMoveStruct + MOVE_ACC]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.BrightPowder:
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2013-05-02 22:29:57 -07:00
|
|
|
cp HELD_BRIGHTPOWDER
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c ; % miss
|
|
|
|
pop bc
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, a
|
|
|
|
ld a, b
|
|
|
|
sub c
|
|
|
|
ld b, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.skip_brightpowder
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Hit
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr nc, .Miss
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Hit:
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Miss:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Keep the damage value intact if we're using (Hi) Jump Kick.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_JUMP_KICK
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .Missed
|
|
|
|
call ResetDamage
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Missed:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DreamEater:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if we're trying to eat the dream of
|
|
|
|
; a monster that isn't sleeping.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_DREAM_EATER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
and SLP
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Protect:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return nz if the opponent is protected.
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_PROTECT, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
; 'protecting itself!'
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, ProtectingItselfText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LockOn:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return nz if we are locked-on and aren't trying to use Earthquake,
|
|
|
|
; Fissure or Magnitude on a monster that is flying.
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, [hl]
|
|
|
|
res SUBSTATUS_LOCK_ON, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .LockedOn
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp EARTHQUAKE
|
|
|
|
ret z
|
|
|
|
cp FISSURE
|
|
|
|
ret z
|
|
|
|
cp MAGNITUDE
|
|
|
|
ret z
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LockedOn:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DrainSub:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if using an HP drain move on a substitute.
|
2013-05-02 23:43:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .not_draining_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_LEECH_HIT
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_DREAM_EATER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.not_draining_sub
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.FlyDigMoves:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Check for moves that can hit underground/flying opponents.
|
|
|
|
; Return z if the current move can hit the opponent.
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_FLYING, a
|
2013-03-26 17:39:44 -07:00
|
|
|
jr z, .DigMoves
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp GUST
|
|
|
|
ret z
|
|
|
|
cp WHIRLWIND
|
|
|
|
ret z
|
|
|
|
cp THUNDER
|
|
|
|
ret z
|
|
|
|
cp TWISTER
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DigMoves:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
cp EARTHQUAKE
|
|
|
|
ret z
|
|
|
|
cp FISSURE
|
|
|
|
ret z
|
|
|
|
cp MAGNITUDE
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ThunderRain:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return z if the current move always hits in rain, and it is raining.
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_THUNDER
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp WEATHER_RAIN
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.XAccuracy:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-08-13 19:44:56 -07:00
|
|
|
bit SUBSTATUS_X_ACCURACY, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.StatModifiers:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; load the user's accuracy into b and the opponent's evasion into c.
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wPlayerMoveStruct + MOVE_ACC
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAccLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyEvaLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_acc_eva
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wEnemyMoveStruct + MOVE_ACC
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAccLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerEvaLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld c, a
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_acc_eva
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2016-01-17 21:39:01 -08:00
|
|
|
jr c, .skip_foresight_check
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; if the target's evasion is greater than the user's accuracy,
|
|
|
|
; check the target's foresight status
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_IDENTIFIED, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
.skip_foresight_check
|
|
|
|
; subtract evasion from 14
|
2018-01-10 14:30:27 -08:00
|
|
|
ld a, MAX_STAT_LEVEL + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
sub c
|
|
|
|
ld c, a
|
2016-01-17 21:39:01 -08:00
|
|
|
; store the base move accuracy for math ops
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 0], a
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2016-01-17 21:39:01 -08:00
|
|
|
ld d, 2 ; do this twice, once for the user's accuracy and once for the target's evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.accuracy_loop
|
2016-01-17 21:39:01 -08:00
|
|
|
; look up the multiplier from the table
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2018-01-10 14:30:27 -08:00
|
|
|
ld hl, AccuracyLevelMultipliers
|
2013-03-26 17:39:44 -07:00
|
|
|
dec b
|
|
|
|
sla b
|
|
|
|
ld c, b
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
2016-01-17 21:39:01 -08:00
|
|
|
; multiply by the first byte in that row...
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call Multiply
|
2016-01-17 21:39:01 -08:00
|
|
|
; ... and divide by the second byte
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld b, 4
|
2013-03-26 17:39:44 -07:00
|
|
|
call Divide
|
2016-01-17 21:39:01 -08:00
|
|
|
; minimum accuracy is $0001
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .min_accuracy
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hQuotient + 2], a
|
2018-08-26 10:49:38 -07:00
|
|
|
ld a, 1
|
|
|
|
ldh [hQuotient + 3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.min_accuracy
|
2016-01-17 21:39:01 -08:00
|
|
|
; do the same thing to the target's evasion
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, c
|
|
|
|
dec d
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .accuracy_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
; if the result is more than 2 bytes, max out at 100%
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2018-08-26 10:49:38 -07:00
|
|
|
and a
|
|
|
|
ldh a, [hQuotient + 3]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .finish_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $ff
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish_accuracy
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2018-01-10 14:30:27 -08:00
|
|
|
INCLUDE "data/battle/accuracy_multipliers.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EffectChance:
|
2013-03-26 22:52:04 -07:00
|
|
|
; effectchance
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEffectFailed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
2013-03-26 22:52:04 -07:00
|
|
|
jr nz, .failed
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wPlayerMoveStruct + MOVE_CHANCE
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_move_chance
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, wEnemyMoveStruct + MOVE_CHANCE
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_move_chance
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2019-01-05 17:29:45 -08:00
|
|
|
; BUG: 1/256 chance to fail even for a 100% effect chance,
|
|
|
|
; since carry is not set if BattleRandom == [hl] == 255
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp [hl]
|
|
|
|
pop hl
|
|
|
|
ret c
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
.failed
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wEffectFailed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_LowerSub:
|
2014-01-01 05:09:15 -08:00
|
|
|
; lowersub
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_CHARGED, a
|
2015-11-06 13:42:38 -08:00
|
|
|
jr nz, .already_charged
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_RAZOR_WIND
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SKY_ATTACK
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SKULL_BASH
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_SOLARBEAM
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_FLY
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.already_charged
|
2013-03-26 17:39:44 -07:00
|
|
|
call .Rampage
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .charge_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call CheckUserIsCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.charge_turn
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
2015-11-09 13:41:09 -08:00
|
|
|
jr c, .mimic_anims
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld a, SUBSTITUTE
|
2015-11-09 13:41:09 -08:00
|
|
|
jp LoadAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_anims
|
2015-11-06 19:36:06 -08:00
|
|
|
call BattleCommand_LowerSubNoAnim
|
2015-11-06 11:45:10 -08:00
|
|
|
jp BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Rampage:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_ROLLOUT
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .rollout_rampage
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_RAMPAGE
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .rollout_rampage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.rollout_rampage
|
2016-01-09 13:28:22 -08:00
|
|
|
ld a, [wSomeoneIsRampaging]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, 0
|
2016-01-09 13:28:22 -08:00
|
|
|
ld [wSomeoneIsRampaging], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_MoveAnim:
|
2018-04-04 14:27:40 -07:00
|
|
|
; moveanim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2018-04-04 14:27:40 -07:00
|
|
|
call BattleCommand_MoveAnimNoSub
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_MoveAnimNoSub:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_DAMAGE
|
2015-11-07 05:05:57 -08:00
|
|
|
jr z, .got_rollout_count
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_PLAYER_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
.got_rollout_count
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_CONVERSION
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .alternate_anim
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, .triplekick
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.triplekick
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
call PlayFXAnimID
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp FLY
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .clear_sprite
|
2013-03-26 17:39:44 -07:00
|
|
|
cp DIG
|
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
.clear_sprite
|
2015-11-09 13:41:09 -08:00
|
|
|
jp AppearUserLowerSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.alternate_anim
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-05-02 23:43:44 -07:00
|
|
|
and 1
|
|
|
|
xor 1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp 1
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
2013-05-02 23:43:44 -07:00
|
|
|
ld d, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
jp z, PlayFXAnimID
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
jp PlayFXAnimID
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatUpAnim:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2015-11-06 13:42:38 -08:00
|
|
|
jr BattleCommand_StatUpDownAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatDownAnim:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-06 11:45:10 -08:00
|
|
|
jp nz, BattleCommand_MoveDelay
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_STAT_DOWN
|
2015-11-06 13:42:38 -08:00
|
|
|
jr z, BattleCommand_StatUpDownAnim
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_WOBBLE
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatUpDownAnim:
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
jp PlayFXAnimID
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SwitchTurn:
|
2013-03-26 22:52:04 -07:00
|
|
|
; switchturn
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 22:52:04 -07:00
|
|
|
xor 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_RaiseSub:
|
2014-01-01 05:09:15 -08:00
|
|
|
; raisesub
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
call _CheckBattleScene
|
|
|
|
jp c, BattleCommand_RaiseSubNoAnim
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $2
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld a, SUBSTITUTE
|
2015-11-09 13:41:09 -08:00
|
|
|
jp LoadAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_FailureText:
|
2015-11-09 13:41:09 -08:00
|
|
|
; failuretext
|
|
|
|
; If the move missed or failed, load the appropriate
|
|
|
|
; text, and end the effects of multi-turn or multi-
|
|
|
|
; hit moves.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
call GetFailureResultText
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
cp FLY
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 22:52:04 -07:00
|
|
|
cp DIG
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .fly_dig
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-27 14:33:29 -07:00
|
|
|
; Move effect:
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .multihit
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.multihit
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fly_dig
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-05-02 23:43:44 -07:00
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
2015-11-09 13:41:09 -08:00
|
|
|
call AppearUserRaiseSub
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ApplyDamage:
|
2018-04-04 14:27:40 -07:00
|
|
|
; applydamage
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_ENDURE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr z, .focus_band
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nc, .damage
|
|
|
|
ld b, 1
|
|
|
|
jr .damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.focus_band
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2013-05-02 22:29:57 -07:00
|
|
|
cp HELD_FOCUS_BAND
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nz, .damage
|
|
|
|
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .damage
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_FalseSwipe
|
2018-04-04 14:27:40 -07:00
|
|
|
ld b, 0
|
|
|
|
jr nc, .damage
|
|
|
|
ld b, 2
|
|
|
|
|
|
|
|
.damage
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
2018-04-04 14:27:40 -07:00
|
|
|
call .update_damage_taken
|
|
|
|
ld c, FALSE
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .damage_player
|
2018-04-04 14:27:40 -07:00
|
|
|
call DoEnemyDamage
|
2015-11-09 13:41:09 -08:00
|
|
|
jr .done_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.damage_player
|
2018-04-04 14:27:40 -07:00
|
|
|
call DoPlayerDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.done_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .focus_band_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, EnduredText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.focus_band_text
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, [hl]
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-05-02 22:29:57 -07:00
|
|
|
call GetItemName
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, HungOnText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.update_damage_taken
|
2013-05-02 22:29:57 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 22:29:57 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2013-05-02 22:29:57 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wPlayerDamageTaken + 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .got_damage_taken
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wEnemyDamageTaken + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.got_damage_taken
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
|
|
|
adc b
|
|
|
|
ld [de], a
|
|
|
|
ret nc
|
|
|
|
ld a, $ff
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetFailureResultText:
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, DoesntAffectText
|
|
|
|
ld de, DoesntAffectText
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_text
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_FUTURE_SIGHT
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, ButItFailedText
|
|
|
|
ld de, ItFailedText
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, AttackMissedText
|
|
|
|
ld de, AttackMissed2Text
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .got_text
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, UnaffectedText
|
2015-11-09 13:41:09 -08:00
|
|
|
.got_text
|
|
|
|
call FailText_CheckOpponentProtect
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2014-06-23 12:47:07 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_JUMP_KICK
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
2018-05-06 09:16:57 -07:00
|
|
|
rept 3
|
2013-03-26 17:39:44 -07:00
|
|
|
srl a
|
|
|
|
rr b
|
2018-05-06 09:16:57 -07:00
|
|
|
endr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
|
|
|
dec hl
|
|
|
|
ld [hli], a
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .do_at_least_1_damage
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
|
|
|
ld [hl], a
|
2015-11-09 13:41:09 -08:00
|
|
|
.do_at_least_1_damage
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, CrashedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2018-04-04 14:27:40 -07:00
|
|
|
ld c, TRUE
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoEnemyDamage
|
|
|
|
jp DoPlayerDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FailText_CheckOpponentProtect:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_PROTECT, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .not_protected
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, d
|
|
|
|
ld l, e
|
2015-11-09 13:41:09 -08:00
|
|
|
.not_protected
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_BideFailText:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
jp z, PrintDoesntAffect
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CriticalText:
|
2013-03-26 17:39:44 -07:00
|
|
|
; criticaltext
|
|
|
|
; Prints the message for critical hits or one-hit KOs.
|
|
|
|
|
|
|
|
; If there is no message to be printed, wait 20 frames.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .wait
|
|
|
|
|
|
|
|
dec a
|
|
|
|
add a
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, .texts
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCriticalHit], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
.wait
|
|
|
|
ld c, 20
|
|
|
|
jp DelayFrames
|
|
|
|
|
2014-06-23 12:47:07 -07:00
|
|
|
.texts
|
|
|
|
dw CriticalHitText
|
|
|
|
dw OneHitKOText
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StartLoop:
|
2013-03-26 22:52:04 -07:00
|
|
|
; startloop
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerRolloutCount
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-23 12:47:07 -07:00
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyRolloutCount
|
2014-06-23 12:47:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SuperEffectiveLoopText:
|
2013-03-26 22:52:04 -07:00
|
|
|
; supereffectivelooptext
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2014-06-23 12:47:07 -07:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SuperEffectiveText:
|
2013-03-26 22:52:04 -07:00
|
|
|
; supereffectivetext
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
cp 10 ; 1.0
|
|
|
|
ret z
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, SuperEffectiveText
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .print
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, NotVeryEffectiveText
|
2013-03-26 17:39:44 -07:00
|
|
|
.print
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-08-17 11:16:37 -07:00
|
|
|
BattleCommand_CheckFaint:
|
|
|
|
; checkfaint
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-08-17 11:16:37 -07:00
|
|
|
; Faint the opponent if its HP reached zero
|
|
|
|
; and faint the user along with it if it used Destiny Bond.
|
|
|
|
; Ends the move effect if the opponent faints.
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_DESTINY_BOND, a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .no_dbond
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, TookDownWithItText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP + 1
|
2013-04-27 14:12:23 -07:00
|
|
|
bccoord 2, 2 ; hp bar
|
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_max_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMaxHP + 1
|
2013-04-27 14:12:23 -07:00
|
|
|
bccoord 10, 9 ; hp bar
|
|
|
|
ld a, 1
|
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.got_max_hp
|
|
|
|
ld [wWhichHPBar], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer4], a
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
|
|
|
ld [wBuffer6], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, b
|
|
|
|
ld l, c
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
|
|
|
ld a, DESTINY_BOND
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadAnim
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .finish
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.no_dbond
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_DOUBLE_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_TRIPLE_KICK
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .multiple_hit_raise_sub
|
2013-04-27 14:12:23 -07:00
|
|
|
cp EFFECT_BEAT_UP
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .finish
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.multiple_hit_raise_sub
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-12-26 15:11:55 -08:00
|
|
|
.finish
|
2013-03-26 17:39:44 -07:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_BuildOpponentRage:
|
2013-03-26 22:52:04 -07:00
|
|
|
; buildopponentrage
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
jp .start
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
.start
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
bit SUBSTATUS_RAGE, a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
ld de, wEnemyRageCounter
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
jr z, .player
|
|
|
|
ld de, wPlayerRageCounter
|
|
|
|
.player
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
|
|
|
inc a
|
|
|
|
ret z
|
|
|
|
ld [de], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 14:07:00 -07:00
|
|
|
ld hl, RageBuildingText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2015-10-10 04:45:39 -07:00
|
|
|
jp BattleCommand_SwitchTurn
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_RageDamage:
|
2013-03-26 22:52:04 -07:00
|
|
|
; ragedamage
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wPlayerRageCounter]
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .rage_loop
|
2015-11-05 16:13:09 -08:00
|
|
|
ld a, [wEnemyRageCounter]
|
2015-12-26 15:11:55 -08:00
|
|
|
.rage_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
add hl, bc
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .rage_loop
|
2018-01-25 18:34:42 -08:00
|
|
|
ld hl, $ffff
|
2015-12-26 15:11:55 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurDamage + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EndMoveEffect:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld l, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld h, a
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
ld [hli], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DittoMetalPowder:
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_SPECIES
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, [hl]
|
|
|
|
jr nz, .Ditto
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Ditto:
|
2013-03-26 17:39:44 -07:00
|
|
|
cp DITTO
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
push bc
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, [hl]
|
|
|
|
cp METAL_POWDER
|
|
|
|
pop bc
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
srl a
|
|
|
|
add c
|
|
|
|
ld c, a
|
|
|
|
ret nc
|
|
|
|
|
|
|
|
srl b
|
|
|
|
ld a, b
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
2015-12-26 15:11:55 -08:00
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
scf
|
|
|
|
rr c
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DamageStats:
|
2013-04-19 23:53:08 -07:00
|
|
|
; damagestats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jp nz, EnemyAttackDamage
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayerAttackDamage:
|
2013-04-19 23:53:08 -07:00
|
|
|
; Return move power d, player level e, enemy defense c and player attack b.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
call ResetDamage
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wPlayerMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
ld d, a
|
|
|
|
ret z
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .special
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .physicalcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.physicalcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonAttack
|
2018-08-16 07:11:28 -07:00
|
|
|
call CheckDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .thickclub
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerAttack
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .thickclub
|
|
|
|
|
|
|
|
.special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonSpclDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_LIGHT_SCREEN, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .specialcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.specialcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonSpclAtk
|
2018-08-16 07:11:28 -07:00
|
|
|
call CheckDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSpAtk
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.lightball
|
|
|
|
; Note: Returns player special attack at hl in hl.
|
2013-03-27 15:50:10 -07:00
|
|
|
call LightBallBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .done
|
|
|
|
|
|
|
|
.thickclub
|
|
|
|
; Note: Returns player attack at hl in hl.
|
2013-03-27 15:50:10 -07:00
|
|
|
call ThickClubBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.done
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
|
|
|
call DittoMetalPowder
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TruncateHL_BC:
|
2015-11-09 13:41:09 -08:00
|
|
|
.loop
|
2013-04-19 23:53:08 -07:00
|
|
|
; Truncate 16-bit values hl and bc to 8-bit values b and c respectively.
|
|
|
|
; b = hl, c = bc
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .finish
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .done_bc
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.done_bc
|
2013-03-26 17:39:44 -07:00
|
|
|
srl h
|
|
|
|
rr l
|
|
|
|
srl h
|
|
|
|
rr l
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, l
|
|
|
|
or h
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .finish
|
2013-03-26 17:39:44 -07:00
|
|
|
inc l
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.finish
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2018-07-27 15:45:33 -07:00
|
|
|
cp LINK_COLOSSEUM
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .done
|
2016-03-08 16:54:06 -08:00
|
|
|
; If we go back to the loop point,
|
|
|
|
; it's the same as doing this exact
|
|
|
|
; same check twice.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, h
|
|
|
|
or b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .loop
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
.done
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, l
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-08-16 07:11:28 -07:00
|
|
|
CheckDamageStatsCritical:
|
|
|
|
; Return carry if boosted stats should be used in damage calculations.
|
|
|
|
; Unboosted stats should be used if the attack is a critical hit,
|
|
|
|
; and the stage of the opponent's defense is higher than the user's attack.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
scf
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr nz, .enemy
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wPlayerMoveStructType]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
; special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .end
|
|
|
|
; physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr .end
|
|
|
|
|
|
|
|
.enemy
|
2016-01-09 16:34:14 -08:00
|
|
|
ld a, [wEnemyMoveStructType]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
; special
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemySAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerSDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .end
|
|
|
|
; physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyAtkLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerDefLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
.end
|
|
|
|
cp b
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ThickClubBoost:
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is Cubone or Marowak and
|
2013-04-19 23:29:39 -07:00
|
|
|
; it's holding a Thick Club, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld b, CUBONE
|
|
|
|
ld c, MAROWAK
|
|
|
|
ld d, THICK_CLUB
|
|
|
|
call SpeciesItemBoost
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LightBallBoost:
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is Pikachu and it's
|
2013-04-19 23:29:39 -07:00
|
|
|
; holding a Light Ball, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld b, PIKACHU
|
|
|
|
ld c, PIKACHU
|
|
|
|
ld d, LIGHT_BALL
|
|
|
|
call SpeciesItemBoost
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpeciesItemBoost:
|
2013-04-19 23:29:39 -07:00
|
|
|
; Return in hl the stat value at hl.
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; If the attacking monster is species b or c and
|
2013-04-19 23:29:39 -07:00
|
|
|
; it's holding item d, double it.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
|
|
|
|
|
|
|
push hl
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_SPECIES
|
2013-03-26 17:39:44 -07:00
|
|
|
call BattlePartyAttr
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, [hl]
|
|
|
|
jr z, .CompareSpecies
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2016-04-10 11:42:14 -07:00
|
|
|
.CompareSpecies:
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
|
|
|
|
cp b
|
2015-11-10 08:05:26 -08:00
|
|
|
jr z, .GetItemHeldEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
cp c
|
|
|
|
ret nz
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.GetItemHeldEffect:
|
2013-03-26 17:39:44 -07:00
|
|
|
push hl
|
|
|
|
call GetUserItem
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
cp d
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
; Double the stat
|
|
|
|
sla l
|
|
|
|
rl h
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EnemyAttackDamage:
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
|
|
|
|
|
|
|
; No damage dealt with 0 power.
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wEnemyMoveStructPower
|
|
|
|
ld a, [hli] ; hl = wEnemyMoveStructType
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, a
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
ld a, [hl]
|
2014-01-05 05:24:27 -08:00
|
|
|
cp SPECIAL
|
2013-03-26 17:39:44 -07:00
|
|
|
jr nc, .Special
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.physical
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .physicalcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.physicalcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonAttack
|
2018-08-16 07:11:28 -07:00
|
|
|
call CheckDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .thickclub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerDefense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyAttack
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .thickclub
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Special:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonSpclDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerScreens]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_LIGHT_SCREEN, a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .specialcrit
|
2013-03-26 17:39:44 -07:00
|
|
|
sla c
|
|
|
|
rl b
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.specialcrit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonSpclAtk
|
2018-08-16 07:11:28 -07:00
|
|
|
call CheckDamageStatsCritical
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .lightball
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerSpDef
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemySpAtk
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.lightball
|
2013-03-27 15:50:10 -07:00
|
|
|
call LightBallBoost
|
2013-04-19 23:53:08 -07:00
|
|
|
jr .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.thickclub
|
2013-03-27 15:50:10 -07:00
|
|
|
call ThickClubBoost
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
.done
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEnemyMonLevel]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld e, a
|
2013-03-27 15:50:10 -07:00
|
|
|
call DittoMetalPowder
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
|
|
|
and a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/beat_up.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ClearMissDamage:
|
2013-03-26 22:52:04 -07:00
|
|
|
; clearmissdamage
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
jp ResetDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HitSelfInConfusion:
|
2013-03-26 17:39:44 -07:00
|
|
|
call ResetDamage
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonDefense
|
|
|
|
ld de, wPlayerScreens
|
|
|
|
ld a, [wBattleMonLevel]
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .got_it
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonDefense
|
|
|
|
ld de, wEnemyScreens
|
|
|
|
ld a, [wEnemyMonLevel]
|
2015-11-09 13:41:09 -08:00
|
|
|
.got_it
|
2013-03-26 17:39:44 -07:00
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
ld a, [de]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SCREENS_REFLECT, a
|
2015-11-09 13:41:09 -08:00
|
|
|
jr z, .mimic_screen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
sla c
|
|
|
|
rl b
|
2015-11-09 13:41:09 -08:00
|
|
|
.mimic_screen
|
2013-03-26 17:39:44 -07:00
|
|
|
dec hl
|
2016-05-10 09:31:49 -07:00
|
|
|
dec hl
|
|
|
|
dec hl
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
2015-11-09 13:41:09 -08:00
|
|
|
call TruncateHL_BC
|
2016-01-09 16:34:14 -08:00
|
|
|
ld d, 40
|
2013-03-26 17:39:44 -07:00
|
|
|
pop af
|
|
|
|
ld e, a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DamageCalc:
|
2013-04-19 23:53:08 -07:00
|
|
|
; damagecalc
|
|
|
|
|
|
|
|
; Return a damage value for move power d, player level e, enemy defense c and player attack b.
|
|
|
|
|
|
|
|
; Return 1 if successful, else 0.
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Selfdestruct and Explosion halve defense.
|
2017-11-15 07:36:13 -08:00
|
|
|
cp EFFECT_SELFDESTRUCT
|
|
|
|
jr nz, .dont_selfdestruct
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
srl c
|
2017-11-15 07:36:13 -08:00
|
|
|
jr nz, .dont_selfdestruct
|
2013-03-26 17:39:44 -07:00
|
|
|
inc c
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-11-15 07:36:13 -08:00
|
|
|
.dont_selfdestruct
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Variable-hit moves and Conversion can have a power of 0.
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_MULTI_HIT
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-04-25 01:26:37 -07:00
|
|
|
cp EFFECT_CONVERSION
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; No damage if move power is 0.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
|
|
|
and a
|
|
|
|
ret z
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.skip_zero_damage_check
|
2013-04-19 23:53:08 -07:00
|
|
|
; Minimum defense value is 1.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nz, .not_dividing_by_zero
|
2013-04-19 23:53:08 -07:00
|
|
|
ld c, 1
|
2015-11-09 20:01:45 -08:00
|
|
|
.not_dividing_by_zero
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2013-04-19 23:53:08 -07:00
|
|
|
ld hl, hDividend
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
ld [hli], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Level * 2
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, e
|
|
|
|
add a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .level_not_overflowing
|
2018-08-26 10:49:38 -07:00
|
|
|
ld [hl], 1
|
2015-11-09 20:01:45 -08:00
|
|
|
.level_not_overflowing
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld [hli], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; / 5
|
|
|
|
ld a, 5
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
|
|
|
push bc
|
2018-08-26 10:49:38 -07:00
|
|
|
ld b, 4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; + 2
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2015-12-26 18:59:03 -08:00
|
|
|
inc [hl]
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; * bp
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
2013-04-19 23:53:08 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; * Attack
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], b
|
2013-04-19 23:53:08 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; / Defense
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], c
|
2018-08-26 10:49:38 -07:00
|
|
|
ld b, 4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
|
|
|
|
|
|
|
; / 50
|
|
|
|
ld [hl], 50
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, $4
|
2013-04-19 23:53:08 -07:00
|
|
|
call Divide
|
|
|
|
|
|
|
|
; Item boosts
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetUserItem
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .DoneItem
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, TypeBoostItems
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NextItem:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-10 14:30:27 -08:00
|
|
|
cp -1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .DoneItem
|
|
|
|
|
|
|
|
; Item effect
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
ld a, [hli]
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .NextItem
|
|
|
|
|
|
|
|
; Type
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .DoneItem
|
|
|
|
|
|
|
|
; * 100 + item effect amount
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, c
|
2013-04-19 23:53:08 -07:00
|
|
|
add 100
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-04-19 23:53:08 -07:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; / 100
|
|
|
|
ld a, 100
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2013-04-19 23:53:08 -07:00
|
|
|
ld b, 4
|
|
|
|
call Divide
|
|
|
|
|
2018-06-25 09:24:18 -07:00
|
|
|
.DoneItem:
|
2013-04-19 23:53:08 -07:00
|
|
|
; Critical hits
|
|
|
|
call .CriticalMultiplier
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
; Update wCurDamage (capped at 997).
|
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
add b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hProduct + 3], a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .dont_cap_1
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
inc a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hProduct + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr z, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 1]
|
2013-03-26 17:39:44 -07:00
|
|
|
or a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nz, .Cap
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_2
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_2
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
add b
|
|
|
|
ld [hld], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
adc b
|
|
|
|
ld [hl], a
|
2013-04-19 23:53:08 -07:00
|
|
|
jr c, .Cap
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
|
2013-04-19 23:53:08 -07:00
|
|
|
jr nc, .Cap
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
2017-12-25 10:40:10 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
|
2015-11-09 20:01:45 -08:00
|
|
|
jr c, .dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Cap:
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2017-12-25 10:40:10 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_cap_3
|
2013-04-19 23:53:08 -07:00
|
|
|
; Minimum neutral damage is 2 (bringing the cap to 999).
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
add MIN_NEUTRAL_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hld], a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .dont_floor
|
2013-03-26 17:39:44 -07:00
|
|
|
inc [hl]
|
2015-11-09 20:01:45 -08:00
|
|
|
.dont_floor
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.CriticalMultiplier:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCriticalHit]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2013-04-19 23:53:08 -07:00
|
|
|
; x2
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
add a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hProduct + 3], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
rl a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hProduct + 2], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
|
|
|
; Cap at $ffff.
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nc
|
|
|
|
|
|
|
|
ld a, $ff
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hProduct + 2], a
|
|
|
|
ldh [hProduct + 3], a
|
2013-04-19 23:53:08 -07:00
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-22 13:23:34 -08:00
|
|
|
INCLUDE "data/types/type_boost_items.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ConstantDamage:
|
2013-03-26 22:52:04 -07:00
|
|
|
; constantdamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonLevel
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .got_turn
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonLevel
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.got_turn
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_LEVEL_DAMAGE
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, [hl]
|
|
|
|
ld a, 0
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_PSYWAVE
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .psywave
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_SUPER_FANG
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .super_fang
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2013-05-02 23:43:44 -07:00
|
|
|
cp EFFECT_REVERSAL
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .reversal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_POWER
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, $0
|
2015-11-09 20:01:45 -08:00
|
|
|
jr .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.psywave
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
srl a
|
|
|
|
add b
|
|
|
|
ld b, a
|
2015-11-09 20:01:45 -08:00
|
|
|
.psywave_loop
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .psywave_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nc, .psywave_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_power
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.super_fang
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2015-11-09 20:01:45 -08:00
|
|
|
.got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
srl a
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
rr a
|
|
|
|
push af
|
|
|
|
ld a, b
|
|
|
|
pop bc
|
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_power
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 0
|
2015-12-26 15:11:55 -08:00
|
|
|
jr nz, .got_power
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, 1
|
2015-12-26 15:11:55 -08:00
|
|
|
jr .got_power
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.got_power
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], b
|
|
|
|
ret
|
2015-11-09 20:01:45 -08:00
|
|
|
|
|
|
|
.reversal
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2015-12-26 15:11:55 -08:00
|
|
|
jr z, .reversal_got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2015-11-09 20:01:45 -08:00
|
|
|
.reversal_got_hp
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend], a
|
|
|
|
ldh [hMultiplicand + 0], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2018-08-26 10:49:38 -07:00
|
|
|
ld a, 48
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2013-05-02 23:43:44 -07:00
|
|
|
call Multiply
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
|
|
|
and a
|
2015-11-09 20:01:45 -08:00
|
|
|
jr z, .skip_to_divide
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 4]
|
2013-03-26 17:39:44 -07:00
|
|
|
srl b
|
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
|
|
|
ldh a, [hProduct + 2]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
srl b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hProduct + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 3], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.skip_to_divide
|
2018-01-25 18:34:42 -08:00
|
|
|
ld b, 4
|
2013-05-02 23:43:44 -07:00
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-25 18:34:42 -08:00
|
|
|
ld hl, FlailReversalPower
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.reversal_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 20:01:45 -08:00
|
|
|
jr nc, .break_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
inc hl
|
2015-11-09 20:01:45 -08:00
|
|
|
jr .reversal_loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
.break_loop
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ld a, [hl]
|
2015-09-09 16:27:07 -07:00
|
|
|
jr nz, .notPlayersTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wPlayerMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
push hl
|
|
|
|
call PlayerAttackDamage
|
2015-09-09 16:27:07 -07:00
|
|
|
jr .notEnemysTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
.notPlayersTurn
|
2016-01-09 16:34:14 -08:00
|
|
|
ld hl, wEnemyMoveStructPower
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
|
|
|
push hl
|
|
|
|
call EnemyAttackDamage
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
.notEnemysTurn
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_DamageCalc
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
|
|
|
ld [hl], 1
|
|
|
|
ret
|
|
|
|
|
2018-01-26 08:01:15 -08:00
|
|
|
INCLUDE "data/moves/flail_reversal_power.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/counter.asm"
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/encore.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/pain_split.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/snore.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/conversion2.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/lock_on.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sketch.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DefrostOpponent:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defrostopponent
|
|
|
|
; Thaw the opponent if frozen, and
|
|
|
|
; raise the user's Attack one stage.
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateCurrentMove
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
call Defrost
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
|
|
|
push af
|
|
|
|
|
|
|
|
ld a, EFFECT_ATTACK_UP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hl], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_StatUp
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop af
|
|
|
|
pop hl
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sleep_talk.asm"
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/destiny_bond.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/spite.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/false_swipe.asm"
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/heal_bell.asm"
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FarPlayBattleAnimation:
|
2018-01-26 08:36:00 -08:00
|
|
|
; play animation de
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayFXAnimID:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, e
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFXAnimID], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, d
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, 3
|
|
|
|
call DelayFrames
|
|
|
|
callfar PlayBattleAnim
|
|
|
|
ret
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoEnemyDamage:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
or b
|
|
|
|
jr z, .did_no_damage
|
|
|
|
|
|
|
|
ld a, c
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .ignore_substitute
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemySubStatus4]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoSubstituteDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.ignore_substitute
|
|
|
|
; Substract wCurDamage from wEnemyMonHP.
|
|
|
|
; store original HP in little endian wBuffer3/4
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonHP + 1]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyMonHP + 1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonHP]
|
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyMonHP], a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .no_underflow
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer4]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer3]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.no_underflow
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer2], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer1], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
hlcoord 2, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2018-01-26 08:36:00 -08:00
|
|
|
.did_no_damage
|
|
|
|
jp RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoPlayerDamage:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
or b
|
|
|
|
jr z, .did_no_damage
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, c
|
|
|
|
and a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nz, .ignore_substitute
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus4]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2018-04-04 14:27:40 -07:00
|
|
|
jp nz, DoSubstituteDamage
|
|
|
|
|
|
|
|
.ignore_substitute
|
|
|
|
; Substract wCurDamage from wBattleMonHP.
|
|
|
|
; store original HP in little endian wBuffer3/4
|
|
|
|
; store new HP in little endian wBuffer5/6
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hld]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonHP + 1]
|
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleMonHP + 1], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonHP]
|
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleMonHP], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer6], a
|
2018-04-04 14:27:40 -07:00
|
|
|
jr nc, .no_underflow
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer4]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBuffer3]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], a
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBuffer5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-04-04 14:27:40 -07:00
|
|
|
.no_underflow
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer2], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer1], a
|
2018-04-04 14:27:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
hlcoord 10, 9
|
2018-04-04 14:27:40 -07:00
|
|
|
ld a, 1
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wWhichHPBar], a
|
|
|
|
predef AnimateHPBar
|
|
|
|
.did_no_damage
|
|
|
|
jp RefreshBattleHuds
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoSubstituteDamage:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SubTookDamageText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemySubstituteHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerSubstituteHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .broke
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
|
|
|
ld [de], a
|
|
|
|
jr z, .broke
|
|
|
|
jr nc, .done
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.broke
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_SUBSTITUTE, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SubFadedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call BattleCommand_LowerSubNoAnim
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
call z, AppearUserLowerSub
|
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
cp EFFECT_MULTI_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_DOUBLE_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_TRIPLE_KICK
|
|
|
|
jr z, .ok
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .ok
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
.ok
|
|
|
|
call RefreshBattleHuds
|
|
|
|
.done
|
|
|
|
jp ResetDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateMoveData:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE
|
|
|
|
call GetBattleVar
|
2018-07-29 13:04:38 -07:00
|
|
|
ld [wCurSpecies], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
dec a
|
|
|
|
call GetMoveData
|
|
|
|
call GetMoveName
|
|
|
|
jp CopyName1
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SleepTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; sleeptarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_SLEEP
|
|
|
|
jr nz, .not_protected_by_item
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
ld hl, ProtectedByText
|
|
|
|
jr .fail
|
|
|
|
|
|
|
|
.not_protected_by_item
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
and SLP
|
|
|
|
ld hl, AlreadyAsleepText
|
|
|
|
jr nz, .fail
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, PrintDidntAffect2
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DidntAffect1Text
|
|
|
|
call .CheckAIRandomFail
|
|
|
|
jr c, .fail
|
|
|
|
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .fail
|
|
|
|
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .fail
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, $7
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .random_loop
|
|
|
|
ld b, $3
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.random_loop
|
|
|
|
call BattleRandom
|
|
|
|
and b
|
|
|
|
jr z, .random_loop
|
|
|
|
cp 7
|
|
|
|
jr z, .random_loop
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
call RefreshBattleHuds
|
|
|
|
|
|
|
|
ld hl, FellAsleepText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
farcall UseHeldStatusHealingItem
|
|
|
|
|
|
|
|
jp z, OpponentCantMove
|
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
.fail
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2018-01-26 08:36:00 -08:00
|
|
|
pop hl
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CheckAIRandomFail:
|
2018-01-26 08:36:00 -08:00
|
|
|
; Enemy turn
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Not in link battle
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Not locked-on by the enemy
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .dont_fail
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
ret c
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_fail
|
|
|
|
xor a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_PoisonTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; poisontarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call CheckIfTargetIsPoisonType
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_POISON
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call PoisonOpponent
|
|
|
|
ld de, ANIM_PSN
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasPoisonedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
farcall UseHeldStatusHealingItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Poison:
|
2018-01-26 08:36:00 -08:00
|
|
|
; poison
|
|
|
|
|
|
|
|
ld hl, DoesntAffectText
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jp z, .failed
|
|
|
|
|
|
|
|
call CheckIfTargetIsPoisonType
|
|
|
|
jp z, .failed
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
|
|
|
ld hl, AlreadyPoisonedText
|
|
|
|
and 1 << PSN
|
|
|
|
jp nz, .failed
|
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_POISON
|
|
|
|
jr nz, .do_poison
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
ld hl, ProtectedByText
|
|
|
|
jr .failed
|
|
|
|
|
|
|
|
.do_poison
|
|
|
|
ld hl, DidntAffect1Text
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr z, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
2018-02-04 10:16:40 -08:00
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
jr c, .failed
|
|
|
|
|
2018-02-04 10:16:40 -08:00
|
|
|
.dont_sample_failure
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .failed
|
|
|
|
call .check_toxic
|
|
|
|
jr z, .toxic
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call .apply_poison
|
|
|
|
ld hl, WasPoisonedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
jr .finished
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.toxic
|
|
|
|
set SUBSTATUS_TOXIC, [hl]
|
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
call .apply_poison
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, BadlyPoisonedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.finished
|
|
|
|
farcall UseHeldStatusHealingItem
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
push hl
|
|
|
|
call AnimateFailedMove
|
|
|
|
pop hl
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.apply_poison
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2018-01-26 08:36:00 -08:00
|
|
|
call PoisonOpponent
|
|
|
|
jp RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.check_toxic
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBattleVarAddr
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyToxicCount
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerToxicCount
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_TOXIC
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckIfTargetIsPoisonType:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonType1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonType1
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
inc de
|
2018-01-26 08:36:00 -08:00
|
|
|
cp POISON
|
|
|
|
ret z
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [de]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp POISON
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PoisonOpponent:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
set PSN, [hl]
|
|
|
|
jp UpdateOpponentInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DrainTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; draintarget
|
|
|
|
call SapHealth
|
|
|
|
ld hl, SuckedHealthText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EatDream:
|
2018-01-26 08:36:00 -08:00
|
|
|
; eatdream
|
|
|
|
call SapHealth
|
|
|
|
ld hl, DreamEatenText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SapHealth:
|
2018-04-04 13:35:47 -07:00
|
|
|
; Divide damage by 2, store it in hDividend
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
srl a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
rr a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 1], a
|
2013-03-26 17:39:44 -07:00
|
|
|
or b
|
2018-04-04 13:35:47 -07:00
|
|
|
jr nz, .at_least_one
|
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDividend + 1], a
|
2018-04-04 13:35:47 -07:00
|
|
|
.at_least_one
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonHP
|
|
|
|
ld de, wBattleMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .battlemonhp
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonHP
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.battlemonhp
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Store current HP in little endian wBuffer3/4
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wBuffer4
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [bc], a
|
|
|
|
ld a, [hl]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Store max HP in little endian wBuffer1/2
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec bc
|
|
|
|
ld [bc], a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
; Add hDividend to current HP and copy it to little endian wBuffer5/6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hDividend + 1]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, [hl]
|
|
|
|
add b
|
|
|
|
ld [hld], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBuffer5], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hDividend]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, [hl]
|
|
|
|
adc b
|
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-04-04 13:35:47 -07:00
|
|
|
jr c, .max_hp
|
|
|
|
|
|
|
|
; Substract current HP from max HP (to see if we have more than max HP)
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hld]
|
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
2013-03-26 17:39:44 -07:00
|
|
|
sub b
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2013-03-26 17:39:44 -07:00
|
|
|
sbc b
|
2018-04-04 13:35:47 -07:00
|
|
|
jr nc, .finish
|
|
|
|
|
|
|
|
.max_hp
|
|
|
|
; Load max HP into current HP and copy it to little endian wBuffer5/6
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
|
|
|
ld [hld], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
2013-03-26 17:39:44 -07:00
|
|
|
ld [hli], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc de
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
.finish
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
hlcoord 10, 9
|
|
|
|
ld a, $1
|
|
|
|
jr z, .hp_bar
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 2
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-01-26 08:36:00 -08:00
|
|
|
.hp_bar
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
predef AnimateHPBar
|
2018-01-26 08:36:00 -08:00
|
|
|
call RefreshBattleHuds
|
|
|
|
jp UpdateBattleMonInParty
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_BurnTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; burntarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, Defrost
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_BURN
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set BRN, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
|
|
|
ld de, ANIM_BRN
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasBurnedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
farcall UseHeldStatusHealingItem
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Defrost:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and 1 << FRZ
|
|
|
|
ret z
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurOTMon]
|
|
|
|
ld hl, wOTPartyMon1Status
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1Status
|
|
|
|
ld a, [wCurBattleMon]
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
call UpdateOpponentInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DefrostedOpponentText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_FreezeTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; freezetarget
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleWeather]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp WEATHER_SUN
|
|
|
|
ret z
|
|
|
|
call CheckMoveTypeMatchesTarget ; Don't freeze an Ice-type
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_FREEZE
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set FRZ, [hl]
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateOpponentInParty
|
2018-01-26 08:36:00 -08:00
|
|
|
ld de, ANIM_FRZ
|
|
|
|
call PlayOpponentBattleAnim
|
2013-05-02 21:22:28 -07:00
|
|
|
call RefreshBattleHuds
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, WasFrozenText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall UseHeldStatusHealingItem
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call OpponentCantMove
|
|
|
|
call EndRechargeOpp
|
|
|
|
ld hl, wEnemyJustGotFrozen
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .finish
|
|
|
|
ld hl, wPlayerJustGotFrozen
|
|
|
|
.finish
|
|
|
|
ld [hl], $1
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ParalyzeTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; paralyzetarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
2013-03-26 17:39:44 -07:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTypeModifier]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $7f
|
|
|
|
ret z
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
2018-01-26 08:36:00 -08:00
|
|
|
cp HELD_PREVENT_PARALYZE
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-11-06 19:36:06 -08:00
|
|
|
call SafeCheckSafeguard
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set PAR, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
|
|
|
ld de, ANIM_PAR
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
call RefreshBattleHuds
|
|
|
|
call PrintParalyze
|
|
|
|
ld hl, UseHeldStatusHealingItem
|
|
|
|
jp CallBattleCore
|
2015-11-06 19:36:06 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AttackUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; attackup
|
|
|
|
ld b, ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DefenseUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defenseup
|
|
|
|
ld b, DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpeedUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; speedup
|
|
|
|
ld b, SPEED
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialAttackUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialattackup
|
|
|
|
ld b, SP_ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialDefenseUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialdefenseup
|
|
|
|
ld b, SP_DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AccuracyUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; accuracyup
|
|
|
|
ld b, ACCURACY
|
|
|
|
jr BattleCommand_StatUp
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EvasionUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; evasionup
|
|
|
|
ld b, EVASION
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AttackUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; attackup2
|
|
|
|
ld b, $10 | ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DefenseUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defenseup2
|
|
|
|
ld b, $10 | DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpeedUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; speedup2
|
|
|
|
ld b, $10 | SPEED
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialAttackUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialattackup2
|
|
|
|
ld b, $10 | SP_ATTACK
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialDefenseUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialdefenseup2
|
|
|
|
ld b, $10 | SP_DEFENSE
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AccuracyUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; accuracyup2
|
|
|
|
ld b, $10 | ACCURACY
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EvasionUp2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; evasionup2
|
|
|
|
ld b, $10 | EVASION
|
|
|
|
jr BattleCommand_StatUp
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; statup
|
2018-08-17 08:48:41 -07:00
|
|
|
call RaiseStat
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2018-08-17 08:48:41 -07:00
|
|
|
jp MinimizeDropSub
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-08-17 08:48:41 -07:00
|
|
|
RaiseStat:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
|
|
|
ld hl, wPlayerStatLevels
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_stat_levels
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_stat_levels
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, .stat_raise_failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jp nz, .stat_raise_failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
|
|
|
jp c, .cant_raise_stat
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
jr z, .got_num_stages
|
|
|
|
inc b
|
|
|
|
ld a, $d
|
|
|
|
cp b
|
|
|
|
jr nc, .got_num_stages
|
|
|
|
ld b, a
|
|
|
|
.got_num_stages
|
|
|
|
ld [hl], b
|
|
|
|
push hl
|
|
|
|
ld a, c
|
|
|
|
cp $5
|
|
|
|
jr nc, .done_calcing_stats
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonStats + 1
|
|
|
|
ld de, wPlayerStats
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_stats_pointer
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonStats + 1
|
|
|
|
ld de, wEnemyStats
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_stats_pointer
|
|
|
|
push bc
|
|
|
|
sla c
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, c
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
jr nc, .no_carry
|
|
|
|
inc d
|
|
|
|
.no_carry
|
|
|
|
pop bc
|
|
|
|
ld a, [hld]
|
|
|
|
sub LOW(MAX_STAT_VALUE)
|
|
|
|
jr nz, .not_already_max
|
|
|
|
ld a, [hl]
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
|
|
|
jp z, .stats_already_max
|
|
|
|
.not_already_max
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .calc_player_stats
|
|
|
|
call CalcEnemyStats
|
|
|
|
jr .done_calcing_stats
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.calc_player_stats
|
|
|
|
call CalcPlayerStats
|
|
|
|
.done_calcing_stats
|
|
|
|
pop hl
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.stats_already_max
|
2013-03-26 17:39:44 -07:00
|
|
|
pop hl
|
2018-01-26 08:36:00 -08:00
|
|
|
dec [hl]
|
|
|
|
; fallthrough
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.cant_raise_stat
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.stat_raise_failed
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-17 08:48:41 -07:00
|
|
|
MinimizeDropSub:
|
|
|
|
; Lower the substitute if we're minimizing
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld bc, wPlayerMinimized
|
|
|
|
ld hl, DropPlayerSub
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .do_player
|
|
|
|
ld bc, wEnemyMinimized
|
|
|
|
ld hl, DropEnemySub
|
|
|
|
.do_player
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
cp MINIMIZE
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [bc], a
|
|
|
|
call _CheckBattleScene
|
|
|
|
ret nc
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call CallBattleCore
|
|
|
|
call WaitBGMap
|
|
|
|
jp BattleCommand_MoveDelay
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AttackDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; attackdown
|
|
|
|
ld a, ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DefenseDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defensedown
|
|
|
|
ld a, DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpeedDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; speeddown
|
|
|
|
ld a, SPEED
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialAttackDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialattackdown
|
|
|
|
ld a, SP_ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialDefenseDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialdefensedown
|
|
|
|
ld a, SP_DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AccuracyDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; accuracydown
|
|
|
|
ld a, ACCURACY
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EvasionDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; evasiondown
|
|
|
|
ld a, EVASION
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AttackDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; attackdown2
|
|
|
|
ld a, $10 | ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DefenseDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defensedown2
|
|
|
|
ld a, $10 | DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpeedDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; speeddown2
|
|
|
|
ld a, $10 | SPEED
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialAttackDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialattackdown2
|
|
|
|
ld a, $10 | SP_ATTACK
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SpecialDefenseDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; specialdefensedown2
|
|
|
|
ld a, $10 | SP_DEFENSE
|
|
|
|
jr BattleCommand_StatDown
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AccuracyDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; accuracydown2
|
|
|
|
ld a, $10 | ACCURACY
|
|
|
|
jr BattleCommand_StatDown
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EvasionDown2:
|
2018-01-26 08:36:00 -08:00
|
|
|
; evasiondown2
|
|
|
|
ld a, $10 | EVASION
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatDown:
|
2018-01-26 08:36:00 -08:00
|
|
|
; statdown
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckMist
|
|
|
|
jp nz, .Mist
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .GetStatLevel
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.GetStatLevel:
|
|
|
|
; Attempt to lower the stat.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f
|
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld b, 0
|
2013-03-26 17:39:44 -07:00
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
2018-01-26 08:36:00 -08:00
|
|
|
dec b
|
|
|
|
jp z, .CantLower
|
|
|
|
|
|
|
|
; Sharply lower the stat if applicable.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wLoweredStat]
|
2013-03-26 17:39:44 -07:00
|
|
|
and $f0
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ComputerMiss
|
|
|
|
dec b
|
|
|
|
jr nz, .ComputerMiss
|
2013-03-26 17:39:44 -07:00
|
|
|
inc b
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.ComputerMiss:
|
|
|
|
; Computer opponents have a 25% chance of failing.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .DidntMiss
|
|
|
|
|
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2013-06-13 13:10:39 -07:00
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
|
|
|
; Lock-On still always works.
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2013-06-13 13:10:39 -07:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .DidntMiss
|
|
|
|
|
|
|
|
; Attacking moves that also lower accuracy are unaffected.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_ACCURACY_DOWN_HIT
|
|
|
|
jr z, .DidntMiss
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
|
|
|
jr c, .Failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.DidntMiss:
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .Failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckHiddenOpponent
|
|
|
|
jr nz, .Failed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Accuracy/Evasion reduction don't involve stats.
|
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
|
|
|
cp ACCURACY
|
|
|
|
jr nc, .Hit
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonAttack + 1
|
|
|
|
ld de, wEnemyStats
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .do_enemy
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonAttack + 1
|
|
|
|
ld de, wPlayerStats
|
2018-01-26 08:36:00 -08:00
|
|
|
.do_enemy
|
|
|
|
call TryLowerStat
|
|
|
|
pop hl
|
|
|
|
jr z, .CouldntLower
|
|
|
|
|
|
|
|
.Hit:
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.CouldntLower:
|
|
|
|
inc [hl]
|
|
|
|
.CantLower:
|
|
|
|
ld a, 3
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAttackMissed], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Failed:
|
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Mist:
|
|
|
|
ld a, 2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckMist:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_ATTACK_DOWN
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
cp EFFECT_ATTACK_DOWN_2
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN_2 + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
cp EFFECT_ATTACK_DOWN_HIT
|
|
|
|
jr c, .dont_check_mist
|
|
|
|
cp EFFECT_EVASION_DOWN_HIT + 1
|
|
|
|
jr c, .check_mist
|
|
|
|
.dont_check_mist
|
|
|
|
xor a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_mist
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_MIST, a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatUpMessage:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, .stat
|
2019-04-08 05:15:10 -07:00
|
|
|
jp BattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.stat
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far Text_BattleEffectActivate
|
2018-11-17 10:33:03 -08:00
|
|
|
text_asm
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleStatWentUpText
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
ret z
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleStatWentWayUpText
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleStatWentWayUpText:
|
|
|
|
text_far _BattleStatWentWayUpText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleStatWentUpText:
|
|
|
|
text_far _BattleStatWentUpText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatDownMessage:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret nz
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, .stat
|
2019-04-08 05:15:10 -07:00
|
|
|
jp BattleTextbox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.stat
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far Text_BattleFoeEffectActivate
|
2018-11-17 10:33:03 -08:00
|
|
|
text_asm
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleStatFellText
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
ret z
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleStatSharplyFellText
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleStatSharplyFellText:
|
|
|
|
text_far _BattleStatSharplyFellText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleStatFellText:
|
|
|
|
text_far _BattleStatFellText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryLowerStat:
|
2018-01-26 08:36:00 -08:00
|
|
|
; Lower stat c from stat struct hl (buffer de).
|
|
|
|
|
|
|
|
push bc
|
|
|
|
sla c
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
; add de, c
|
|
|
|
ld a, c
|
2013-03-26 17:39:44 -07:00
|
|
|
add e
|
2018-01-26 08:36:00 -08:00
|
|
|
ld e, a
|
|
|
|
jr nc, .no_carry
|
|
|
|
inc d
|
|
|
|
.no_carry
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
; The lowest possible stat is 1.
|
|
|
|
ld a, [hld]
|
|
|
|
sub 1
|
|
|
|
jr nz, .not_min
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_min
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .Player
|
|
|
|
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call CalcPlayerStats
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
jr .end
|
|
|
|
|
|
|
|
.Player:
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call CalcEnemyStats
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
.end
|
|
|
|
ld a, 1
|
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatUpFailText:
|
2018-01-26 08:36:00 -08:00
|
|
|
; statupfailtext
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jp z, TryPrintButItFailed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, WontRiseAnymoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_StatDownFailText:
|
2018-01-26 08:36:00 -08:00
|
|
|
; statdownfailtext
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wFailedMessage]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-01-26 08:36:00 -08:00
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jp z, TryPrintButItFailed
|
|
|
|
dec a
|
|
|
|
ld hl, ProtectedByMistText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp z, StdBattleTextbox
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
inc b
|
|
|
|
call GetStatName
|
|
|
|
ld hl, WontDropAnymoreText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetStatName:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, StatNames
|
|
|
|
ld c, "@"
|
|
|
|
.CheckName:
|
|
|
|
dec b
|
|
|
|
jr z, .Copy
|
|
|
|
.GetName:
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr z, .CheckName
|
|
|
|
jr .GetName
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Copy:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wStringBuffer2
|
|
|
|
ld bc, wStringBuffer3 - wStringBuffer2
|
2018-01-26 08:36:00 -08:00
|
|
|
jp CopyBytes
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "data/battle/stat_names.asm"
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "data/battle/stat_multipliers.asm"
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_AllStatsUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; allstatsup
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Attack
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_AttackUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Defense
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_DefenseUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Speed
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpeedUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Special Attack
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpecialAttackUp
|
|
|
|
call BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Special Defense
|
|
|
|
call ResetMiss
|
|
|
|
call BattleCommand_SpecialDefenseUp
|
|
|
|
jp BattleCommand_StatUpMessage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetMiss:
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LowerStat:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wLoweredStat], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_target
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_target
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl]
|
|
|
|
dec b
|
|
|
|
jr z, .cant_lower_anymore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wLoweredStat]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $f0
|
|
|
|
jr z, .got_num_stages
|
|
|
|
dec b
|
|
|
|
jr nz, .got_num_stages
|
|
|
|
inc b
|
|
|
|
|
|
|
|
.got_num_stages
|
|
|
|
ld [hl], b
|
|
|
|
ld a, c
|
|
|
|
cp 5
|
|
|
|
jr nc, .accuracy_evasion
|
|
|
|
|
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonStats + 1
|
|
|
|
ld de, wPlayerStats
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_target_2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonStats + 1
|
|
|
|
ld de, wEnemyStats
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_target_2
|
|
|
|
call TryLowerStat
|
|
|
|
pop hl
|
|
|
|
jr z, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.accuracy_evasion
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .player
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jr .finish
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
call CalcPlayerStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.finish
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
inc [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.cant_lower_anymore
|
|
|
|
ld a, 2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFailedMessage], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_TriStatusChance:
|
2018-01-26 08:36:00 -08:00
|
|
|
; tristatuschance
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_EffectChance
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.loop
|
|
|
|
; 1/3 chance of each status
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-26 08:36:00 -08:00
|
|
|
swap a
|
2018-01-11 09:00:01 -08:00
|
|
|
and %11
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .loop
|
|
|
|
dec a
|
|
|
|
ld hl, .ptrs
|
|
|
|
rst JumpTable
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.ptrs
|
|
|
|
dw BattleCommand_ParalyzeTarget ; paralyze
|
|
|
|
dw BattleCommand_FreezeTarget ; freeze
|
|
|
|
dw BattleCommand_BurnTarget ; burn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Curl:
|
2018-01-26 08:36:00 -08:00
|
|
|
; curl
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS2
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_CURLED, [hl]
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_RaiseSubNoAnim:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, GetBattleMonBackpic
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .PlayerTurn
|
|
|
|
ld hl, GetEnemyMonFrontpic
|
|
|
|
.PlayerTurn:
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call CallBattleCore
|
|
|
|
jp WaitBGMap
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_LowerSubNoAnim:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DropPlayerSub
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .PlayerTurn
|
|
|
|
ld hl, DropEnemySub
|
|
|
|
.PlayerTurn:
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call CallBattleCore
|
|
|
|
jp WaitBGMap
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CalcPlayerStats:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerAtkLevel
|
|
|
|
ld de, wPlayerStats
|
|
|
|
ld bc, wBattleMonAttack
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 5
|
2018-11-23 14:03:27 -08:00
|
|
|
call CalcBattleStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, BadgeStatBoosts
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jp BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CalcEnemyStats:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyAtkLevel
|
|
|
|
ld de, wEnemyStats
|
|
|
|
ld bc, wEnemyMonAttack
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
ld a, 5
|
2018-11-23 14:03:27 -08:00
|
|
|
call CalcBattleStats
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ApplyBrnEffectOnAttack
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
jp BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-11-23 14:03:27 -08:00
|
|
|
CalcBattleStats:
|
2018-01-26 08:36:00 -08:00
|
|
|
.loop
|
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
push hl
|
|
|
|
push bc
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
dec c
|
|
|
|
ld b, 0
|
|
|
|
ld hl, StatLevelMultipliers
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 0], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [de]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplicand + 2], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc de
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMultiplier], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call Multiply
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hDivisor], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, 4
|
|
|
|
call Divide
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2018-08-26 10:49:38 -07:00
|
|
|
ld b, a
|
|
|
|
ldh a, [hQuotient + 3]
|
2018-01-26 08:36:00 -08:00
|
|
|
or b
|
|
|
|
jr nz, .check_maxed_out
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh [hQuotient + 3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_maxed_out
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp LOW(MAX_STAT_VALUE)
|
|
|
|
ld a, b
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
|
|
|
jr c, .not_maxed_out
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh [hQuotient + 3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh [hQuotient + 2], a
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_maxed_out
|
|
|
|
pop bc
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 2]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
2018-08-26 10:49:38 -07:00
|
|
|
ldh a, [hQuotient + 3]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [bc], a
|
|
|
|
inc bc
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/bide.asm"
|
2015-09-04 13:30:40 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckRampage:
|
2018-01-26 08:36:00 -08:00
|
|
|
; checkrampage
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .player
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
ret z
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
jr nz, .continue_rampage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
res SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call SafeCheckSafeguard
|
|
|
|
push af
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
pop af
|
|
|
|
jr nz, .continue_rampage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
|
|
|
call BattleRandom
|
|
|
|
and %00000001
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
inc de ; ConfuseCount
|
|
|
|
ld [de], a
|
|
|
|
.continue_rampage
|
|
|
|
ld b, rampage_command
|
|
|
|
jp SkipToBattleCommand
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Rampage:
|
2018-01-26 08:36:00 -08:00
|
|
|
; rampage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; No rampage during Sleep Talk.
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVar
|
|
|
|
and SLP
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
2013-03-26 17:39:44 -07:00
|
|
|
.ok
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_RAMPAGE, [hl]
|
|
|
|
; Rampage for 1 or 2 more turns
|
|
|
|
call BattleRandom
|
|
|
|
and %00000001
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
|
|
|
ld a, 1
|
|
|
|
ld [wSomeoneIsRampaging], a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/teleport.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetBattleDraw:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
or DRAW
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wBattleResult], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ForceSwitch:
|
2018-01-26 08:36:00 -08:00
|
|
|
; forceswitch
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleType]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp BATTLETYPE_SHINY
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_TRAP
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_CELEBI
|
|
|
|
jp z, .fail
|
|
|
|
cp BATTLETYPE_SUICUNE
|
|
|
|
jp z, .fail
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jp nz, .force_player_switch
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .missed
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .trainer
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp b
|
|
|
|
jr nc, .wild_force_flee
|
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
.random_loop_wild
|
|
|
|
call BattleRandom
|
|
|
|
cp c
|
|
|
|
jr nc, .random_loop_wild
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
|
|
|
jr nc, .wild_force_flee
|
|
|
|
.missed
|
|
|
|
jp .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.wild_force_flee
|
|
|
|
call UpdateBattleMonInParty
|
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
inc a
|
|
|
|
ld [wForcedSwitch], a
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, [wPlayerMoveStructAnimation]
|
|
|
|
jp .succeed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.trainer
|
|
|
|
call FindAliveEnemyMons
|
|
|
|
jr c, .switch_fail
|
|
|
|
ld a, [wEnemyGoesFirst]
|
|
|
|
and a
|
|
|
|
jr z, .switch_fail
|
|
|
|
call UpdateEnemyMonInParty
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, $14
|
|
|
|
call DelayFrames
|
|
|
|
hlcoord 1, 0
|
|
|
|
lb bc, 4, 10
|
|
|
|
call ClearBox
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurOTMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
; select a random enemy mon to switch to
|
|
|
|
.random_loop_trainer
|
|
|
|
call BattleRandom
|
|
|
|
and $7
|
|
|
|
cp b
|
|
|
|
jr nc, .random_loop_trainer
|
|
|
|
cp c
|
|
|
|
jr z, .random_loop_trainer
|
|
|
|
push af
|
|
|
|
push bc
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wOTPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hli]
|
2018-01-26 08:36:00 -08:00
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr z, .random_loop_trainer
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, d
|
2018-01-26 08:36:00 -08:00
|
|
|
inc a
|
|
|
|
ld [wEnemySwitchMonIndex], a
|
|
|
|
callfar ForceEnemySwitch
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DraggedOutText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SpikesDamage
|
|
|
|
jp CallBattleCore
|
|
|
|
|
|
|
|
.switch_fail
|
|
|
|
jp .fail
|
|
|
|
|
|
|
|
.force_player_switch
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .player_miss
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .vs_trainer
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurPartyLevel]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp b
|
|
|
|
jr nc, .wild_succeed_playeristarget
|
|
|
|
|
|
|
|
add b
|
|
|
|
ld c, a
|
|
|
|
inc c
|
|
|
|
.wild_random_loop_playeristarget
|
|
|
|
call BattleRandom
|
|
|
|
cp c
|
|
|
|
jr nc, .wild_random_loop_playeristarget
|
|
|
|
|
|
|
|
srl b
|
|
|
|
srl b
|
|
|
|
cp b
|
|
|
|
jr nc, .wild_succeed_playeristarget
|
|
|
|
|
|
|
|
.player_miss
|
|
|
|
jr .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.wild_succeed_playeristarget
|
|
|
|
call UpdateBattleMonInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-26 08:36:00 -08:00
|
|
|
inc a
|
|
|
|
ld [wForcedSwitch], a
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, [wEnemyMoveStructAnimation]
|
|
|
|
jr .succeed
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.vs_trainer
|
|
|
|
call CheckPlayerHasMonToSwitchTo
|
|
|
|
jr c, .fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wEnemyGoesFirst]
|
|
|
|
cp $1
|
|
|
|
jr z, .switch_fail
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call UpdateBattleMonInParty
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
|
|
|
hlcoord 9, 7
|
|
|
|
lb bc, 5, 11
|
|
|
|
call ClearBox
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
.random_loop_trainer_playeristarget
|
|
|
|
call BattleRandom
|
|
|
|
and $7
|
|
|
|
cp b
|
|
|
|
jr nc, .random_loop_trainer_playeristarget
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp c
|
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push af
|
|
|
|
push bc
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
jr z, .random_loop_trainer_playeristarget
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, d
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCurPartyMon], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SwitchPlayerMon
|
|
|
|
call CallBattleCore
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, DraggedOutText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, SpikesDamage
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.fail
|
|
|
|
call BattleCommand_LowerSub
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
jp PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.succeed
|
|
|
|
push af
|
|
|
|
call SetBattleDraw
|
|
|
|
ld a, $1
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
|
|
|
pop af
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, FledInFearText
|
|
|
|
cp ROAR
|
|
|
|
jr z, .do_text
|
|
|
|
ld hl, BlownAwayText
|
|
|
|
.do_text
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckPlayerHasMonToSwitchTo:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld d, a
|
|
|
|
ld e, 0
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
.loop
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp e
|
|
|
|
jr z, .next
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, e
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1HP
|
2018-01-26 08:36:00 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
jr nz, .not_fainted
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.next
|
|
|
|
inc e
|
|
|
|
dec d
|
|
|
|
jr nz, .loop
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
scf
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_fainted
|
|
|
|
and a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_EndLoop:
|
2018-01-26 08:36:00 -08:00
|
|
|
; endloop
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-04-02 16:05:44 -07:00
|
|
|
; Loop back to 'critical'.
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wPlayerRolloutCount
|
|
|
|
ld bc, wPlayerDamageTaken
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_addrs
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyRolloutCount
|
|
|
|
ld bc, wEnemyDamageTaken
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_addrs
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_IN_LOOP, [hl]
|
|
|
|
jp nz, .in_loop
|
|
|
|
set SUBSTATUS_IN_LOOP, [hl]
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld a, [hl]
|
|
|
|
cp EFFECT_POISON_MULTI_HIT
|
|
|
|
jr z, .twineedle
|
|
|
|
cp EFFECT_DOUBLE_HIT
|
|
|
|
ld a, 1
|
|
|
|
jr z, .double_hit
|
|
|
|
ld a, [hl]
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .beat_up
|
|
|
|
cp EFFECT_TRIPLE_KICK
|
|
|
|
jr nz, .not_triple_kick
|
|
|
|
.reject_triple_kick_sample
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
jr z, .reject_triple_kick_sample
|
|
|
|
dec a
|
|
|
|
jr nz, .double_hit
|
|
|
|
ld a, 1
|
|
|
|
ld [bc], a
|
|
|
|
jr .done_loop
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.beat_up
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nz, .check_ot_beat_up
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
|
|
|
dec a
|
|
|
|
jr .double_hit
|
2015-11-09 13:41:09 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.check_ot_beat_up
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
cp WILD_BATTLE
|
|
|
|
jp z, .only_one_beatup
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp 1
|
|
|
|
jp z, .only_one_beatup
|
|
|
|
dec a
|
|
|
|
jr .double_hit
|
|
|
|
|
|
|
|
.only_one_beatup
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2018-04-03 03:00:24 -07:00
|
|
|
call BattleCommand_BeatUpFailText
|
2018-01-26 08:36:00 -08:00
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_triple_kick
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
cp 2
|
|
|
|
jr c, .got_number_hits
|
|
|
|
call BattleRandom
|
|
|
|
and $3
|
|
|
|
.got_number_hits
|
|
|
|
inc a
|
|
|
|
.double_hit
|
|
|
|
ld [de], a
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
|
|
|
jr .loop_back_to_critical
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.twineedle
|
|
|
|
ld a, 1
|
|
|
|
jr .double_hit
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.in_loop
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
jr nz, .loop_back_to_critical
|
|
|
|
.done_loop
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, PlayerHitTimesText
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hit_n_times_text
|
|
|
|
ld hl, EnemyHitTimesText
|
|
|
|
.got_hit_n_times_text
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_BEAT_UP
|
|
|
|
jr z, .beat_up_2
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
.beat_up_2
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop bc
|
|
|
|
xor a
|
|
|
|
ld [bc], a
|
|
|
|
ret
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.loop_back_to_critical
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld h, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld l, a
|
|
|
|
.not_critical
|
|
|
|
ld a, [hld]
|
|
|
|
cp critical_command
|
|
|
|
jr nz, .not_critical
|
|
|
|
inc hl
|
|
|
|
ld a, h
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, l
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_FakeOut:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .fail
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << FRZ | SLP
|
|
|
|
jr nz, .fail
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckOpponentWentFirst
|
|
|
|
jr z, FlinchTarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.fail
|
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_FlinchTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
and 1 << FRZ | SLP
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckOpponentWentFirst
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FlinchTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
|
|
|
jp EndRechargeOpp
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckOpponentWentFirst:
|
2018-01-26 08:36:00 -08:00
|
|
|
; Returns a=0, z if user went first
|
|
|
|
; Returns a=1, nz if opponent went first
|
|
|
|
push bc
|
|
|
|
ld a, [wEnemyGoesFirst] ; 0 if player went first
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn] ; 0 if it's the player's turn
|
2018-01-26 08:36:00 -08:00
|
|
|
xor b ; 1 if opponent went first
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_HeldFlinch:
|
2018-01-26 08:36:00 -08:00
|
|
|
; kingsrock
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetUserItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_FLINCH
|
|
|
|
ret nz
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
call GetUserItem
|
2013-08-30 19:59:40 -07:00
|
|
|
call BattleRandom
|
2018-01-26 08:36:00 -08:00
|
|
|
cp c
|
|
|
|
ret nc
|
|
|
|
call EndRechargeOpp
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_FLINCHED, [hl]
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_OHKO:
|
2018-01-26 08:36:00 -08:00
|
|
|
; ohko
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call ResetDamage
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jr z, .no_effect
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonLevel
|
|
|
|
ld de, wBattleMonLevel
|
2018-01-26 08:36:00 -08:00
|
|
|
ld bc, wPlayerMoveStruct + MOVE_ACC
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_move_accuracy
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
|
|
|
pop de
|
|
|
|
ld bc, wEnemyMoveStruct + MOVE_ACC
|
|
|
|
.got_move_accuracy
|
|
|
|
ld a, [de]
|
|
|
|
sub [hl]
|
|
|
|
jr c, .no_effect
|
|
|
|
add a
|
|
|
|
ld e, a
|
|
|
|
ld a, [bc]
|
|
|
|
add e
|
|
|
|
jr nc, .finish_ohko
|
|
|
|
ld a, $ff
|
|
|
|
.finish_ohko
|
|
|
|
ld [bc], a
|
|
|
|
call BattleCommand_CheckHit
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, $2
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCriticalHit], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
.no_effect
|
|
|
|
ld a, $ff
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCriticalHit], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckCharge:
|
2018-01-26 08:36:00 -08:00
|
|
|
; checkcharge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CHARGED, [hl]
|
|
|
|
ret z
|
|
|
|
res SUBSTATUS_CHARGED, [hl]
|
|
|
|
res SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
res SUBSTATUS_FLYING, [hl]
|
|
|
|
ld b, charge_command
|
|
|
|
jp SkipToBattleCommand
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Charge:
|
2018-01-26 08:36:00 -08:00
|
|
|
; charge
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_ClearText
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVar
|
|
|
|
and SLP
|
|
|
|
jr z, .awake
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
call PrintButItFailed
|
|
|
|
jp EndMoveEffect
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.awake
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_CHARGED, [hl]
|
|
|
|
|
|
|
|
ld hl, IgnoredOrders2Text
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAlreadyDisobeyed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2019-04-08 05:15:10 -07:00
|
|
|
call nz, StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
call BattleCommand_LowerSub
|
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
|
|
|
inc a
|
|
|
|
ld [wKickCounter], a
|
|
|
|
call LoadMoveAnim
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
cp FLY
|
|
|
|
jr z, .flying
|
|
|
|
cp DIG
|
|
|
|
jr z, .flying
|
|
|
|
call BattleCommand_RaiseSub
|
|
|
|
jr .not_flying
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.flying
|
|
|
|
call DisappearUser
|
|
|
|
.not_flying
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld b, a
|
|
|
|
cp FLY
|
|
|
|
jr z, .set_flying
|
|
|
|
cp DIG
|
|
|
|
jr nz, .dont_set_digging
|
|
|
|
set SUBSTATUS_UNDERGROUND, [hl]
|
|
|
|
jr .dont_set_digging
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.set_flying
|
|
|
|
set SUBSTATUS_FLYING, [hl]
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_set_digging
|
|
|
|
call CheckUserIsCharging
|
|
|
|
jr nz, .mimic
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld [hl], b
|
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld [hl], b
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.mimic
|
|
|
|
call ResetDamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, .UsedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call BattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_SKULL_BASH
|
|
|
|
ld b, endturn_command
|
|
|
|
jp z, SkipToBattleCommand
|
|
|
|
jp EndMoveEffect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.UsedText:
|
2019-10-20 15:24:17 -07:00
|
|
|
text_far Text_BattleUser ; "<USER>"
|
2018-11-17 10:33:03 -08:00
|
|
|
text_asm
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
cp RAZOR_WIND
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleMadeWhirlwindText
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SOLARBEAM
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleTookSunlightText
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SKULL_BASH
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleLoweredHeadText
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .done
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp SKY_ATTACK
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleGlowingText
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp FLY
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleFlewText
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp DIG
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .BattleDugText
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.done
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleMadeWhirlwindText:
|
|
|
|
text_far _BattleMadeWhirlwindText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleTookSunlightText:
|
|
|
|
text_far _BattleTookSunlightText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleLoweredHeadText:
|
|
|
|
text_far _BattleLoweredHeadText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleGlowingText:
|
|
|
|
text_far _BattleGlowingText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleFlewText:
|
|
|
|
text_far _BattleFlewText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.BattleDugText:
|
|
|
|
text_far _BattleDugText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand3c:
|
2018-01-26 08:36:00 -08:00
|
|
|
; unused
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_TrapTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; traptarget
|
2013-03-26 22:52:04 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld hl, wEnemyWrapCount
|
|
|
|
ld de, wEnemyTrappingMove
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_trap
|
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
ld de, wPlayerTrappingMove
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_trap
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
|
|
|
ret nz
|
|
|
|
call BattleRandom
|
|
|
|
; trapped for 2-5 turns
|
|
|
|
and %11
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld [de], a
|
|
|
|
ld b, a
|
|
|
|
ld hl, .Traps
|
2013-04-27 14:12:23 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.find_trap_text
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
|
|
|
jr z, .found_trap_text
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
jr .find_trap_text
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.found_trap_text
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-27 14:07:00 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Traps:
|
|
|
|
dbw BIND, UsedBindText ; 'used BIND on'
|
|
|
|
dbw WRAP, WrappedByText ; 'was WRAPPED by'
|
|
|
|
dbw FIRE_SPIN, FireSpinTrapText ; 'was trapped!'
|
|
|
|
dbw CLAMP, ClampedByText ; 'was CLAMPED by'
|
|
|
|
dbw WHIRLPOOL, WhirlpoolTrapText ; 'was trapped!'
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mist.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/focus_energy.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Recoil:
|
2018-01-26 08:36:00 -08:00
|
|
|
; recoil
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld d, a
|
|
|
|
; get 1/4 damage or 1 HP, whichever is higher
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurDamage]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurDamage + 1]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
ld a, b
|
|
|
|
or c
|
|
|
|
jr nz, .min_damage
|
|
|
|
inc c
|
|
|
|
.min_damage
|
|
|
|
ld a, [hli]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer2], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer1], a
|
2018-01-26 08:36:00 -08:00
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer3], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sub c
|
|
|
|
ld [hld], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer5], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer4], a
|
2018-01-26 08:36:00 -08:00
|
|
|
sbc b
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wBuffer6], a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr nc, .dont_ko
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBuffer5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
.dont_ko
|
|
|
|
hlcoord 10, 9
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ld a, 1
|
|
|
|
jr z, .animate_hp_bar
|
|
|
|
hlcoord 2, 2
|
|
|
|
xor a
|
|
|
|
.animate_hp_bar
|
|
|
|
ld [wWhichHPBar], a
|
|
|
|
predef AnimateHPBar
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, RecoilText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ConfuseTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; confusetarget
|
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_CONFUSE
|
|
|
|
ret z
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEffectFailed]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2018-01-26 08:36:00 -08:00
|
|
|
call SafeCheckSafeguard
|
|
|
|
ret nz
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
ret nz
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
|
|
|
ret nz
|
|
|
|
jr BattleCommand_FinishConfusingTarget
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Confuse:
|
2018-01-26 08:36:00 -08:00
|
|
|
; confuse
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_CONFUSE
|
|
|
|
jr nz, .no_item_protection
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, ProtectedByText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.no_item_protection
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_CONFUSED, [hl]
|
|
|
|
jr z, .not_already_confused
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, AlreadyConfusedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_already_confused
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_FinishConfusingTarget:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wEnemyConfuseCount
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .got_confuse_count
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wPlayerConfuseCount
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_confuse_count
|
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
|
|
|
; confused for 2-5 turns
|
|
|
|
call BattleRandom
|
|
|
|
and %11
|
|
|
|
inc a
|
|
|
|
inc a
|
|
|
|
ld [bc], a
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_CONFUSE_HIT
|
|
|
|
jr z, .got_effect
|
|
|
|
cp EFFECT_SNORE
|
|
|
|
jr z, .got_effect
|
|
|
|
cp EFFECT_SWAGGER
|
|
|
|
jr z, .got_effect
|
|
|
|
call AnimateCurrentMove
|
|
|
|
|
|
|
|
.got_effect
|
|
|
|
ld de, ANIM_CONFUSED
|
|
|
|
call PlayOpponentBattleAnim
|
|
|
|
|
|
|
|
ld hl, BecameConfusedText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_HEAL_STATUS
|
|
|
|
jr z, .heal_confusion
|
|
|
|
cp HELD_HEAL_CONFUSION
|
|
|
|
ret nz
|
|
|
|
.heal_confusion
|
|
|
|
ld hl, UseConfusionHealingItem
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_CONFUSE_HIT
|
|
|
|
ret z
|
|
|
|
cp EFFECT_SNORE
|
|
|
|
ret z
|
|
|
|
cp EFFECT_SWAGGER
|
|
|
|
ret z
|
|
|
|
jp PrintDidntAffect2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Paralyze:
|
2018-01-26 08:36:00 -08:00
|
|
|
; paralyze
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit PAR, a
|
|
|
|
jr nz, .paralyzed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wTypeModifier]
|
2018-01-26 08:36:00 -08:00
|
|
|
and $7f
|
|
|
|
jr z, .didnt_affect
|
|
|
|
call GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp HELD_PREVENT_PARALYZE
|
|
|
|
jr nz, .no_item_protection
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetItemName
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ProtectedByText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.no_item_protection
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .dont_sample_failure
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus5]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_LOCK_ON, a
|
|
|
|
jr nz, .dont_sample_failure
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleRandom
|
2018-02-04 10:16:40 -08:00
|
|
|
cp 25 percent + 1 ; 25% chance AI fails
|
2018-01-26 08:36:00 -08:00
|
|
|
jr c, .failed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.dont_sample_failure
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .failed
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAttackMissed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .failed
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jr nz, .failed
|
|
|
|
ld c, 30
|
|
|
|
call DelayFrames
|
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
set PAR, [hl]
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
ld hl, ApplyPrzEffectOnSpeed
|
|
|
|
call CallBattleCore
|
|
|
|
call UpdateBattleHuds
|
|
|
|
call PrintParalyze
|
|
|
|
ld hl, UseHeldStatusHealingItem
|
|
|
|
jp CallBattleCore
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.paralyzed
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, AlreadyParalyzedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
|
|
|
jp PrintDidntAffect2
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.didnt_affect
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintDoesntAffect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckMoveTypeMatchesTarget:
|
2018-01-26 08:36:00 -08:00
|
|
|
; Compare move type to opponent type.
|
|
|
|
; Return z if matching the opponent type,
|
|
|
|
; unless the move is Normal (Tri Attack).
|
|
|
|
|
|
|
|
push hl
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonType1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonType1
|
2013-03-26 17:39:44 -07:00
|
|
|
.ok
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_MOVE_TYPE
|
|
|
|
call GetBattleVar
|
|
|
|
cp NORMAL
|
|
|
|
jr z, .normal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
cp [hl]
|
|
|
|
jr z, .return
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
inc hl
|
|
|
|
cp [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.return
|
|
|
|
pop hl
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.normal
|
|
|
|
ld a, 1
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
pop hl
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/substitute.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_RechargeNextTurn:
|
2018-01-26 08:36:00 -08:00
|
|
|
; rechargenextturn
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_RECHARGE, [hl]
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EndRechargeOpp:
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_RECHARGE, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
2013-09-08 19:44:20 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rage.asm"
|
2013-09-08 19:44:20 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DoubleFlyingDamage:
|
2018-01-26 08:36:00 -08:00
|
|
|
; doubleflyingdamage
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_FLYING, a
|
|
|
|
ret z
|
|
|
|
jr DoubleDamage
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DoubleUndergroundDamage:
|
2018-01-26 08:36:00 -08:00
|
|
|
; doubleundergrounddamage
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
|
|
|
ret z
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DoubleDamage:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2018-01-26 08:36:00 -08:00
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
jr nc, .quit
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
.quit
|
|
|
|
ret
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mimic.asm"
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/leech_seed.asm"
|
2013-09-08 19:30:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/splash.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/disable.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/pay_day.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/conversion.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ResetStats:
|
2018-01-26 08:36:00 -08:00
|
|
|
; resetstats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 7 ; neutral
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
call .Fill
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
call .Fill
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
push af
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call SetPlayerTurn
|
|
|
|
call CalcPlayerStats
|
|
|
|
call SetEnemyTurn
|
|
|
|
call CalcEnemyStats
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBattleTurn], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateCurrentMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, EliminatedStatsText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.Fill:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld b, wPlayerStatLevelsEnd - wPlayerStatLevels
|
2018-01-26 08:36:00 -08:00
|
|
|
.next
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
|
|
|
jr nz, .next
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Heal:
|
2018-01-26 08:36:00 -08:00
|
|
|
; heal
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonHP
|
|
|
|
ld hl, wBattleMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_hp
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonHP
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
|
|
|
call GetBattleVar
|
|
|
|
ld b, a
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld c, 2
|
2018-07-22 21:25:53 -07:00
|
|
|
call CompareBytes
|
2018-01-26 08:36:00 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jp z, .hp_full
|
|
|
|
ld a, b
|
|
|
|
cp REST
|
|
|
|
jr nz, .not_rest
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push af
|
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
|
|
|
call GetBattleVarAddr
|
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
|
|
|
call GetBattleVarAddr
|
|
|
|
ld a, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [hl], REST_SLEEP_TURNS + 1
|
|
|
|
ld hl, WentToSleepText
|
|
|
|
jr z, .no_status_to_heal
|
|
|
|
ld hl, RestedText
|
|
|
|
.no_status_to_heal
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .calc_enemy_stats
|
|
|
|
call CalcPlayerStats
|
|
|
|
jr .got_stats
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.calc_enemy_stats
|
|
|
|
call CalcEnemyStats
|
|
|
|
.got_stats
|
|
|
|
pop af
|
|
|
|
pop de
|
|
|
|
pop hl
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.not_rest
|
|
|
|
jr z, .restore_full_hp
|
|
|
|
ld hl, GetHalfMaxHP
|
|
|
|
call CallBattleCore
|
|
|
|
jr .finish
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.restore_full_hp
|
|
|
|
ld hl, GetMaxHP
|
|
|
|
call CallBattleCore
|
|
|
|
.finish
|
|
|
|
call AnimateCurrentMove
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
ld hl, RestoreHP
|
|
|
|
call CallBattleCore
|
|
|
|
call BattleCommand_SwitchTurn
|
|
|
|
call UpdateUserInParty
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, RegainedHealthText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.hp_full
|
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, HPIsFullText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/transform.asm"
|
2013-04-19 00:50:45 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleEffect_ButItFailed:
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintButItFailed
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearLastMove:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_LAST_MOVE
|
|
|
|
call GetBattleVarAddr
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetActorDisable:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .player
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyDisableCount], a
|
|
|
|
ld [wEnemyDisabledMove], a
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wPlayerDisableCount], a
|
|
|
|
ld [wDisabledMove], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Screen:
|
2018-01-26 08:36:00 -08:00
|
|
|
; screen
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wPlayerScreens
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wPlayerLightScreenCount
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_screens_pointer
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyScreens
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wEnemyLightScreenCount
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_screens_pointer
|
|
|
|
ld a, BATTLE_VARS_MOVE_EFFECT
|
|
|
|
call GetBattleVar
|
|
|
|
cp EFFECT_LIGHT_SCREEN
|
|
|
|
jr nz, .Reflect
|
|
|
|
|
|
|
|
bit SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
jr nz, .failed
|
|
|
|
set SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
ld a, 5
|
|
|
|
ld [bc], a
|
|
|
|
ld hl, LightScreenEffectText
|
|
|
|
jr .good
|
|
|
|
|
|
|
|
.Reflect:
|
|
|
|
bit SCREENS_REFLECT, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
jr nz, .failed
|
2018-01-26 08:36:00 -08:00
|
|
|
set SCREENS_REFLECT, [hl]
|
|
|
|
|
|
|
|
; LightScreenCount -> ReflectCount
|
|
|
|
inc bc
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 5
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [bc], a
|
|
|
|
ld hl, ReflectEffectText
|
|
|
|
|
|
|
|
.good
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintDoesntAffect:
|
2018-01-26 08:36:00 -08:00
|
|
|
; 'it doesn't affect'
|
|
|
|
ld hl, DoesntAffectText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintNothingHappened:
|
2018-01-26 08:36:00 -08:00
|
|
|
; 'but nothing happened!'
|
|
|
|
ld hl, NothingHappenedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryPrintButItFailed:
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wAlreadyFailed]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; fallthrough
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintButItFailed:
|
2018-01-26 08:36:00 -08:00
|
|
|
; 'but it failed!'
|
|
|
|
ld hl, ButItFailedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
FailMove:
|
|
|
|
call AnimateFailedMove
|
|
|
|
; fallthrough
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FailMimic:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, ButItFailedText ; 'but it failed!'
|
|
|
|
ld de, ItFailedText ; 'it failed!'
|
|
|
|
jp FailText_CheckOpponentProtect
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintDidntAffect:
|
2018-01-26 08:36:00 -08:00
|
|
|
; 'it didn't affect'
|
|
|
|
ld hl, DidntAffect1Text
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintDidntAffect2:
|
2018-01-26 08:36:00 -08:00
|
|
|
call AnimateFailedMove
|
|
|
|
ld hl, DidntAffect1Text ; 'it didn't affect'
|
|
|
|
ld de, DidntAffect2Text ; 'it didn't affect'
|
|
|
|
jp FailText_CheckOpponentProtect
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PrintParalyze:
|
2018-01-26 08:36:00 -08:00
|
|
|
; 'paralyzed! maybe it can't attack!'
|
|
|
|
ld hl, ParalyzedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckSubstituteOpp:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4_OPP
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/selfdestruct.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mirror_move.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/metronome.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckUserMove:
|
2018-01-26 08:36:00 -08:00
|
|
|
; Return z if the user has move a.
|
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wBattleMonMoves
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .ok
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wEnemyMonMoves
|
2018-01-26 08:36:00 -08:00
|
|
|
.ok
|
|
|
|
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
cp b
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, 1
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
ret
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResetTurn:
|
2018-01-26 08:36:00 -08:00
|
|
|
ld hl, wPlayerCharging
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .player
|
|
|
|
ld hl, wEnemyCharging
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.player
|
|
|
|
ld [hl], 1
|
2013-03-26 17:39:44 -07:00
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAlreadyDisobeyed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call DoMove
|
|
|
|
jp EndMoveEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/thief.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ArenaTrap:
|
2018-01-26 08:36:00 -08:00
|
|
|
; arenatrap
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Doesn't work on an absent opponent.
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
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.
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
set SUBSTATUS_CANT_RUN, [hl]
|
|
|
|
call AnimateCurrentMove
|
|
|
|
ld hl, CantEscapeNowText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.failed
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-27 15:50:10 -07:00
|
|
|
jp PrintButItFailed
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/nightmare.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Defrost:
|
2018-01-26 08:36:00 -08:00
|
|
|
; defrost
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Thaw the user.
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, BATTLE_VARS_STATUS
|
2014-06-14 00:34:57 -07:00
|
|
|
call GetBattleVarAddr
|
2018-01-26 08:36:00 -08:00
|
|
|
bit FRZ, [hl]
|
|
|
|
ret z
|
|
|
|
res FRZ, [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
; Don't update the enemy's party struct in a wild battle.
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .party
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr z, .done
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.party
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call UserPartyAttr
|
|
|
|
res FRZ, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.done
|
|
|
|
call RefreshBattleHuds
|
|
|
|
ld hl, WasDefrostedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/curse.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/protect.asm"
|
2013-03-27 15:50:10 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/endure.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/spikes.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/foresight.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/perish_song.asm"
|
2014-01-01 05:09:15 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sandstorm.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rollout.asm"
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand5d:
|
2018-01-26 08:36:00 -08:00
|
|
|
; unused
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/fury_cutter.asm"
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/attract.asm"
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/return.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/present.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/frustration.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/safeguard.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SafeCheckSafeguard:
|
2018-01-26 08:36:00 -08:00
|
|
|
push hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyScreens
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_turn
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerScreens
|
2014-06-10 23:08:07 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_turn
|
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_CheckSafeguard:
|
2018-01-26 08:36:00 -08:00
|
|
|
; checksafeguard
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyScreens
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_turn
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPlayerScreens
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_turn
|
|
|
|
bit SCREENS_SAFEGUARD, [hl]
|
2013-03-26 17:39:44 -07:00
|
|
|
ret z
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, 1
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wAttackMissed], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call BattleCommand_MoveDelay
|
|
|
|
ld hl, SafeguardProtectText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
jp EndMoveEffect
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/magnitude.asm"
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/baton_pass.asm"
|
|
|
|
|
|
|
|
INCLUDE "engine/battle/move_effects/pursuit.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rapid_spin.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_HealMorn:
|
2013-03-26 17:39:44 -07:00
|
|
|
; healmorn
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, MORN_F
|
2015-12-23 17:46:23 -08:00
|
|
|
jr BattleCommand_TimeBasedHealContinue
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_HealDay:
|
2013-03-26 17:39:44 -07:00
|
|
|
; healday
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, DAY_F
|
2015-12-23 17:46:23 -08:00
|
|
|
jr BattleCommand_TimeBasedHealContinue
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_HealNite:
|
2013-03-26 17:39:44 -07:00
|
|
|
; healnite
|
2017-12-10 22:02:28 -08:00
|
|
|
ld b, NITE_F
|
2013-03-26 17:39:44 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_TimeBasedHealContinue:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Time- and weather-sensitive heal.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
|
|
|
ld de, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .start
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonMaxHP
|
|
|
|
ld de, wEnemyMonHP
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
.start
|
|
|
|
; Index for .Multipliers
|
|
|
|
; Default restores half max HP.
|
|
|
|
ld c, 2
|
|
|
|
|
|
|
|
; Don't bother healing if HP is already full.
|
|
|
|
push bc
|
2018-07-22 21:25:53 -07:00
|
|
|
call CompareBytes
|
2013-03-26 17:39:44 -07:00
|
|
|
pop bc
|
|
|
|
jr z, .Full
|
|
|
|
|
|
|
|
; Don't factor in time of day in link battles.
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr nz, .Weather
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp b
|
|
|
|
jr z, .Weather
|
2015-12-23 17:46:23 -08:00
|
|
|
dec c ; double
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Weather:
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .Heal
|
|
|
|
|
|
|
|
; x2 in sun
|
|
|
|
; /2 in rain/sandstorm
|
|
|
|
inc c
|
|
|
|
cp WEATHER_SUN
|
|
|
|
jr z, .Heal
|
|
|
|
dec c
|
2015-12-26 18:59:03 -08:00
|
|
|
dec c
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Heal:
|
2013-03-26 17:39:44 -07:00
|
|
|
ld b, 0
|
|
|
|
ld hl, .Multipliers
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, bc
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, BANK(GetMaxHP)
|
|
|
|
rst FarCall
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateCurrentMove
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar RestoreHP
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-05-02 21:22:28 -07:00
|
|
|
call UpdateUserInParty
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; 'regained health!'
|
|
|
|
ld hl, RegainedHealthText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Full:
|
2014-01-01 05:09:15 -08:00
|
|
|
call AnimateFailedMove
|
2013-03-26 17:39:44 -07:00
|
|
|
|
|
|
|
; 'hp is full!'
|
|
|
|
ld hl, HPIsFullText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Multipliers:
|
2013-03-26 17:39:44 -07:00
|
|
|
dw GetEighthMaxHP
|
|
|
|
dw GetQuarterMaxHP
|
|
|
|
dw GetHalfMaxHP
|
|
|
|
dw GetMaxHP
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/hidden_power.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/rain_dance.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/sunny_day.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/belly_drum.asm"
|
2014-01-05 05:24:27 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/psych_up.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/mirror_coat.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_DoubleMinimizeDamage:
|
2013-03-26 22:52:04 -07:00
|
|
|
; doubleminimizedamage
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wEnemyMinimized
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
2014-06-10 23:08:07 -07:00
|
|
|
jr z, .ok
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, wPlayerMinimized
|
2014-06-10 23:08:07 -07:00
|
|
|
.ok
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wCurDamage + 1
|
2013-03-26 17:39:44 -07:00
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
ret nc
|
|
|
|
ld a, $ff
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_SkipSunCharge:
|
2015-11-09 13:41:09 -08:00
|
|
|
; mimicsuncharge
|
2018-01-23 13:45:34 -08:00
|
|
|
ld a, [wBattleWeather]
|
2013-03-26 17:39:44 -07:00
|
|
|
cp WEATHER_SUN
|
|
|
|
ret nz
|
2015-04-13 21:39:54 -07:00
|
|
|
ld b, charge_command
|
2013-03-26 22:52:04 -07:00
|
|
|
jp SkipToBattleCommand
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/future_sight.asm"
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
INCLUDE "engine/battle/move_effects/thunder.asm"
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckHiddenOpponent:
|
2018-07-26 14:24:58 -07:00
|
|
|
; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2014-06-10 23:08:07 -07:00
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2013-03-26 17:39:44 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetUserItem:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return the effect of the user's item in bc, and its id at hl.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .go
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
.go
|
|
|
|
ld b, [hl]
|
2015-11-10 08:05:26 -08:00
|
|
|
jp GetItemHeldEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetOpponentItem:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return the effect of the opponent's item in bc, and its id at hl.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wEnemyMonItem
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-26 17:39:44 -07:00
|
|
|
and a
|
|
|
|
jr z, .go
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wBattleMonItem
|
2013-03-26 17:39:44 -07:00
|
|
|
.go
|
|
|
|
ld b, [hl]
|
2015-11-10 08:05:26 -08:00
|
|
|
jp GetItemHeldEffect
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetItemHeldEffect:
|
2013-03-26 17:39:44 -07:00
|
|
|
; Return the effect of item b in bc.
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
2017-12-14 09:19:26 -08:00
|
|
|
ld hl, ItemAttributes + ITEMATTR_EFFECT
|
2013-03-26 17:39:44 -07:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2017-12-12 17:15:07 -08:00
|
|
|
ld a, ITEMATTR_STRUCT_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
2013-04-29 23:01:54 -07:00
|
|
|
ld a, BANK(ItemAttributes)
|
2013-03-26 17:39:44 -07:00
|
|
|
call GetFarHalfword
|
|
|
|
ld b, l
|
|
|
|
ld c, h
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AnimateCurrentMoveEitherSide:
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-27 13:19:51 -07:00
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop af
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call PlayDamageAnim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AnimateCurrentMove:
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, [wKickCounter]
|
2013-03-27 13:19:51 -07:00
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop af
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call LoadMoveAnim
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_RaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayDamageAnim:
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-27 13:19:51 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2013-03-27 13:19:51 -07:00
|
|
|
and a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_ENEMY_DAMAGE
|
2015-11-06 17:55:16 -08:00
|
|
|
jr z, .player
|
2015-11-09 13:41:09 -08:00
|
|
|
ld a, BATTLEANIM_PLAYER_DAMAGE
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
.player
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
jp PlayUserBattleAnim
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadMoveAnim:
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2013-10-11 00:04:21 -07:00
|
|
|
call GetBattleVar
|
2013-03-27 13:19:51 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2013-03-27 15:50:10 -07:00
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadAnim:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayUserBattleAnim:
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-16 11:30:10 -08:00
|
|
|
callfar PlayBattleAnim
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayOpponentBattleAnim:
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID], a
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2013-03-27 13:19:51 -07:00
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wNumHits], a
|
2013-03-27 13:19:51 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2018-01-16 11:30:10 -08:00
|
|
|
callfar PlayBattleAnim
|
2013-03-27 13:19:51 -07:00
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
call BattleCommand_SwitchTurn
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CallBattleCore:
|
2018-06-12 20:29:15 -07:00
|
|
|
ld a, BANK("Battle Core")
|
2013-03-27 13:19:51 -07:00
|
|
|
rst FarCall
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AnimateFailedMove:
|
2015-11-06 13:42:38 -08:00
|
|
|
call BattleCommand_LowerSub
|
2015-11-06 11:45:10 -08:00
|
|
|
call BattleCommand_MoveDelay
|
2015-11-06 13:42:38 -08:00
|
|
|
jp BattleCommand_RaiseSub
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_MoveDelay:
|
2013-09-30 22:02:33 -07:00
|
|
|
; movedelay
|
2013-03-26 17:39:44 -07:00
|
|
|
; Wait 40 frames.
|
|
|
|
ld c, 40
|
|
|
|
jp DelayFrames
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_ClearText:
|
2013-03-26 22:52:04 -07:00
|
|
|
; cleartext
|
|
|
|
|
2013-03-26 17:39:44 -07:00
|
|
|
; Used in multi-hit moves.
|
|
|
|
ld hl, .text
|
2019-04-08 05:15:10 -07:00
|
|
|
jp BattleTextbox
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-11-17 10:33:03 -08:00
|
|
|
.text:
|
|
|
|
text_end
|
2013-03-26 17:39:44 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SkipToBattleCommand:
|
2013-03-26 22:52:04 -07:00
|
|
|
; Skip over commands until reaching command b.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress + 1]
|
2013-03-26 22:52:04 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wBattleScriptBufferAddress]
|
2013-03-26 22:52:04 -07:00
|
|
|
ld l, a
|
2015-11-09 13:41:09 -08:00
|
|
|
.loop
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
2015-11-09 13:41:09 -08:00
|
|
|
jr nz, .loop
|
2013-03-26 22:52:04 -07:00
|
|
|
|
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress + 1], a
|
2013-03-26 22:52:04 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleScriptBufferAddress], a
|
2013-03-26 22:52:04 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMoveAttr:
|
2013-03-27 13:19:51 -07:00
|
|
|
; Assuming hl = Moves + x, return attribute x of move a.
|
|
|
|
push bc
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-03-27 13:19:51 -07:00
|
|
|
call AddNTimes
|
|
|
|
call GetMoveByte
|
|
|
|
pop bc
|
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMoveData:
|
2013-03-27 13:19:51 -07:00
|
|
|
; Copy move struct a to de.
|
2013-03-26 17:39:44 -07:00
|
|
|
ld hl, Moves
|
2014-06-10 23:23:55 -07:00
|
|
|
ld bc, MOVE_LENGTH
|
2013-03-26 17:39:44 -07:00
|
|
|
call AddNTimes
|
2018-06-12 20:29:15 -07:00
|
|
|
ld a, BANK(Moves)
|
2013-03-26 17:39:44 -07:00
|
|
|
jp FarCopyBytes
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMoveByte:
|
2013-03-27 13:19:51 -07:00
|
|
|
ld a, BANK(Moves)
|
|
|
|
jp GetFarByte
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DisappearUser:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _DisappearUser
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AppearUserLowerSub:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _AppearUserLowerSub
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AppearUserRaiseSub:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _AppearUserRaiseSub
|
2013-03-27 13:19:51 -07:00
|
|
|
ret
|
2015-12-26 15:11:55 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_CheckBattleScene:
|
2015-11-06 19:36:06 -08:00
|
|
|
; Checks the options. Returns carry if battle animations are disabled.
|
2013-03-27 13:19:51 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall CheckBattleScene
|
2013-03-27 13:19:51 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|