2018-06-24 14:09:41 +00:00
|
|
|
BattleCommand_Substitute:
|
2018-01-26 16:36:00 +00:00
|
|
|
call BattleCommand_MoveDelay
|
2018-02-03 23:21:53 +00:00
|
|
|
ld hl, wBattleMonMaxHP
|
|
|
|
ld de, wPlayerSubstituteHP
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 16:36:00 +00:00
|
|
|
and a
|
|
|
|
jr z, .got_hp
|
2018-02-03 23:21:53 +00:00
|
|
|
ld hl, wEnemyMonMaxHP
|
|
|
|
ld de, wEnemySubstituteHP
|
2018-01-26 16:36:00 +00: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 18:28:22 +00:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 16:36:00 +00: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 23:21:53 +00:00
|
|
|
ld [wFXAnimID + 1], a
|
2020-08-30 00:35:49 +00:00
|
|
|
ld [wBattleAnimParam], a
|
2018-01-26 16:36:00 +00:00
|
|
|
ld a, SUBSTITUTE
|
|
|
|
call LoadAnim
|
|
|
|
jr .finish
|
|
|
|
|
|
|
|
.no_anim
|
|
|
|
call BattleCommand_RaiseSubNoAnim
|
|
|
|
.finish
|
|
|
|
ld hl, MadeSubstituteText
|
2019-04-08 12:15:10 +00:00
|
|
|
call StdBattleTextbox
|
2018-01-26 16:36:00 +00: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 12:15:10 +00:00
|
|
|
jp StdBattleTextbox
|