2018-06-24 14:09:41 +00:00
|
|
|
BattleCommand_Sketch:
|
2018-01-26 16:36:00 +00: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 23:21:53 +00:00
|
|
|
ld hl, wBattleMonMoves
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 16:36:00 +00:00
|
|
|
and a
|
|
|
|
jr z, .get_last_move
|
2018-02-03 23:21:53 +00:00
|
|
|
ld hl, wEnemyMonMoves
|
2018-01-26 16:36:00 +00:00
|
|
|
.get_last_move
|
|
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
|
|
|
call GetBattleVar
|
2018-07-28 23:27:34 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2018-01-26 16:36:00 +00: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 23:21:53 +00:00
|
|
|
ld bc, wBattleMonPP - wBattleMonMoves
|
2018-01-26 16:36:00 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
pop bc
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 16:36:00 +00: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 12:15:10 +00:00
|
|
|
jp StdBattleTextbox
|
2018-01-26 16:36:00 +00:00
|
|
|
|
|
|
|
.fail
|
|
|
|
call AnimateFailedMove
|
|
|
|
jp PrintDidntAffect
|