1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
BattleCommand_Encore:
; encore
ld hl, wEnemyMonMoves
ld de, wEnemyEncoreCount
ldh a, [hBattleTurn]
and a
jr z, .ok
ld hl, wBattleMonMoves
ld de, wPlayerEncoreCount
.ok
ld a, BATTLE_VARS_LAST_MOVE_OPP
call GetBattleVar
and a
jp z, .failed
cp STRUGGLE
jp z, .failed
cp ENCORE
jp z, .failed
cp MIRROR_MOVE
jp z, .failed
ld b, a
.got_move
ld a, [hli]
cp b
jr nz, .got_move
ld bc, wBattleMonPP - wBattleMonMoves - 1
add hl, bc
ld a, [hl]
and PP_MASK
jp z, .failed
ld a, [wAttackMissed]
and a
jp nz, .failed
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVarAddr
bit SUBSTATUS_ENCORED, [hl]
jp nz, .failed
set SUBSTATUS_ENCORED, [hl]
call BattleRandom
and $3
inc a
inc a
inc a
ld [de], a
call CheckOpponentWentFirst
jr nz, .finish_move
ldh a, [hBattleTurn]
and a
jr z, .force_last_enemy_move
push hl
ld a, [wLastPlayerMove]
ld b, a
ld c, 0
ld hl, wBattleMonMoves
.find_player_move
ld a, [hli]
cp b
jr z, .got_player_move
inc c
ld a, c
cp NUM_MOVES
jr c, .find_player_move
pop hl
res SUBSTATUS_ENCORED, [hl]
xor a
ld [de], a
jr .failed
.got_player_move
pop hl
ld a, c
ld [wCurMoveNum], a
ld a, b
ld [wCurPlayerMove], a
dec a
ld de, wPlayerMoveStruct
call GetMoveData
jr .finish_move
.force_last_enemy_move
push hl
ld a, [wLastEnemyMove]
ld b, a
ld c, 0
ld hl, wEnemyMonMoves
.find_enemy_move
ld a, [hli]
cp b
jr z, .got_enemy_move
inc c
ld a, c
cp NUM_MOVES
jr c, .find_enemy_move
pop hl
res SUBSTATUS_ENCORED, [hl]
xor a
ld [de], a
jr .failed
.got_enemy_move
pop hl
ld a, c
ld [wCurEnemyMoveNum], a
ld a, b
ld [wCurEnemyMove], a
dec a
ld de, wEnemyMoveStruct
call GetMoveData
.finish_move
call AnimateCurrentMove
ld hl, GotAnEncoreText
jp StdBattleTextbox
.failed
jp PrintDidntAffect2
|