mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
9dec80b07e
Introduce MONICON_* constants Introduce BATTLEPLAYERACTION_* constants
118 lines
2.0 KiB
NASM
118 lines
2.0 KiB
NASM
BattleCommand_Sketch:
|
|
; 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.
|
|
ld hl, wBattleMonMoves
|
|
ld a, [hBattleTurn]
|
|
and a
|
|
jr z, .get_last_move
|
|
ld hl, wEnemyMonMoves
|
|
.get_last_move
|
|
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
|
|
call GetBattleVar
|
|
ld [wNamedObjectIndexBuffer], a
|
|
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
|
|
ld bc, wBattleMonPP - wBattleMonMoves
|
|
add hl, bc
|
|
ld [hl], a
|
|
pop bc
|
|
|
|
ld a, [hBattleTurn]
|
|
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
|
|
jp StdBattleTextBox
|
|
|
|
.fail
|
|
call AnimateFailedMove
|
|
jp PrintDidntAffect
|