2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_Sketch:
|
2018-01-26 08:36:00 -08:00
|
|
|
; sketch
|
|
|
|
|
|
|
|
call ClearLastMove
|
|
|
|
; Don't sketch during a link battle
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr z, .not_linked
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintNothingHappened
|
|
|
|
|
|
|
|
.not_linked
|
|
|
|
; If the opponent has a substitute up, fail.
|
|
|
|
call CheckSubstituteOpp
|
|
|
|
jp nz, .fail
|
|
|
|
; If the opponent is transformed, fail.
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
|
|
|
call GetBattleVarAddr
|
|
|
|
bit SUBSTATUS_TRANSFORMED, [hl]
|
|
|
|
jp nz, .fail
|
|
|
|
; Get the user's moveset in its party struct.
|
|
|
|
; This move replacement shall be permanent.
|
|
|
|
; Pointer will be in de.
|
|
|
|
ld a, MON_MOVES
|
|
|
|
call UserPartyAttr
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
; Get the battle move structs.
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonMoves
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .get_last_move
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonMoves
|
2018-01-26 08:36:00 -08:00
|
|
|
.get_last_move
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
|
|
|
call GetBattleVar
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
|
|
|
; Fail if move is invalid or is Struggle.
|
|
|
|
and a
|
|
|
|
jr z, .fail
|
|
|
|
cp STRUGGLE
|
|
|
|
jr z, .fail
|
|
|
|
; Fail if user already knows that move
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
.does_user_already_know_move
|
|
|
|
ld a, [hli]
|
|
|
|
cp b
|
|
|
|
jr z, .fail
|
|
|
|
dec c
|
|
|
|
jr nz, .does_user_already_know_move
|
|
|
|
; Find Sketch in the user's moveset.
|
|
|
|
; Pointer in hl, and index in c.
|
|
|
|
dec hl
|
|
|
|
ld c, NUM_MOVES
|
|
|
|
.find_sketch
|
|
|
|
dec c
|
|
|
|
ld a, [hld]
|
|
|
|
cp SKETCH
|
|
|
|
jr nz, .find_sketch
|
|
|
|
inc hl
|
|
|
|
; The Sketched move is loaded to that slot.
|
|
|
|
ld a, b
|
|
|
|
ld [hl], a
|
|
|
|
; Copy the base PP from that move.
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
dec a
|
|
|
|
ld hl, Moves + MOVE_PP
|
|
|
|
call GetMoveAttr
|
|
|
|
pop hl
|
2018-02-03 15:21:53 -08:00
|
|
|
ld bc, wBattleMonPP - wBattleMonMoves
|
2018-01-26 08:36:00 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr z, .user_trainer
|
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr nz, .user_trainer
|
|
|
|
; wildmon
|
|
|
|
ld a, [hl]
|
|
|
|
push bc
|
|
|
|
ld hl, wWildMonPP
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld hl, wWildMonMoves
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
ld [hl], b
|
|
|
|
jr .done_copy
|
|
|
|
|
|
|
|
.user_trainer
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld l, c
|
|
|
|
ld h, 0
|
|
|
|
add hl, de
|
|
|
|
ld a, b
|
|
|
|
ld [hl], a
|
|
|
|
pop af
|
|
|
|
ld de, MON_PP - MON_MOVES
|
|
|
|
add hl, de
|
|
|
|
ld [hl], a
|
|
|
|
.done_copy
|
|
|
|
call GetMoveName
|
|
|
|
call AnimateCurrentMove
|
|
|
|
|
|
|
|
ld hl, SketchedText
|
2019-04-08 05:15:10 -07:00
|
|
|
jp StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.fail
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintDidntAffect
|