2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Substitute:
|
2018-01-26 08:36:00 -08:00
|
|
|
; substitute
|
|
|
|
|
|
|
|
call BattleCommand_MoveDelay
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMaxHP
|
|
|
|
ld de, wPlayerSubstituteHP
|
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
|
|
|
|
ld de, wEnemySubstituteHP
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_hp
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
|
|
|
call GetBattleVar
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
|
|
|
jr nz, .already_has_sub
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld b, [hl]
|
|
|
|
srl a
|
|
|
|
rr b
|
|
|
|
srl a
|
|
|
|
rr b
|
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
ld a, [hld]
|
|
|
|
sub b
|
|
|
|
ld e, a
|
|
|
|
ld a, [hl]
|
|
|
|
sbc 0
|
|
|
|
ld d, a
|
|
|
|
jr c, .too_weak_to_sub
|
|
|
|
ld a, d
|
|
|
|
or e
|
|
|
|
jr z, .too_weak_to_sub
|
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
|
|
|
call GetBattleVarAddr
|
|
|
|
set SUBSTATUS_SUBSTITUTE, [hl]
|
|
|
|
|
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
ld de, wPlayerTrappingMove
|
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, wEnemyWrapCount
|
|
|
|
ld de, wEnemyTrappingMove
|
|
|
|
.player
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
ld [de], a
|
|
|
|
call _CheckBattleScene
|
|
|
|
jr c, .no_anim
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld [wNumHits], a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wFXAnimID + 1], a
|
2020-08-29 17:35:49 -07:00
|
|
|
ld [wBattleAnimParam], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, SUBSTITUTE
|
|
|
|
call LoadAnim
|
|
|
|
jr .finish
|
|
|
|
|
|
|
|
.no_anim
|
|
|
|
call BattleCommand_RaiseSubNoAnim
|
|
|
|
.finish
|
|
|
|
ld hl, MadeSubstituteText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
jp RefreshBattleHuds
|
|
|
|
|
|
|
|
.already_has_sub
|
|
|
|
call CheckUserIsCharging
|
|
|
|
call nz, BattleCommand_RaiseSub
|
|
|
|
ld hl, HasSubstituteText
|
|
|
|
jr .jp_stdbattletextbox
|
|
|
|
|
|
|
|
.too_weak_to_sub
|
|
|
|
call CheckUserIsCharging
|
|
|
|
call nz, BattleCommand_RaiseSub
|
|
|
|
ld hl, TooWeakSubText
|
|
|
|
.jp_stdbattletextbox
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|