summaryrefslogtreecommitdiff
path: root/src/scripts/psychic_club_entrance.asm
blob: 46aae9275730b4226b812ca1062104f8a984f56c (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
ClubEntranceAfterDuel:
	ld hl, .after_duel_table
	jp FindEndOfDuelScript

.after_duel_table
	db NPC_RONALD2
	db NPC_RONALD2
	dw Script_BeatFirstRonaldDuel
	dw Script_LostToFirstRonaldDuel

	db NPC_RONALD3
	db NPC_RONALD3
	dw Script_BeatSecondRonaldDuel
	dw Script_LostToSecondRonaldDuel
	db $00

; A Ronald is already loaded or not loaded depending on Pre-Load scripts
; in data/npc_map_data.asm. This just starts a script if possible.
LoadClubEntrance:
	call TryFirstRonaldDuel
	call TrySecondRonaldDuel
	call TryFirstRonaldEncounter
	ret

TryFirstRonaldEncounter:
	ld a, NPC_RONALD1
	ld [wTempNPC], a
	call FindLoadedNPC
	ret c
	ld bc, Script_FirstRonaldEncounter
	jp SetNextNPCAndScript

TryFirstRonaldDuel:
	ld a, NPC_RONALD2
	ld [wTempNPC], a
	call FindLoadedNPC
	ret c
	get_event_value EVENT_RONALD_FIRST_DUEL_STATE
	or a
	ret nz ; already dueled
	ld bc, Script_FirstRonaldDuel
	jp SetNextNPCAndScript

TrySecondRonaldDuel:
	ld a, NPC_RONALD3
	ld [wTempNPC], a
	call FindLoadedNPC
	ret c
	get_event_value EVENT_RONALD_SECOND_DUEL_STATE
	or a
	ret nz ; already dueled
	ld bc, Script_SecondRonaldDuel
	jp SetNextNPCAndScript

Script_Clerk6:
	start_script
	print_text_quit_fully Text0642

Script_Lad3:
	start_script
	test_if_event_false EVENT_RECEIVED_LEGENDARY_CARDS
	print_variable_npc_text Text0643, Text0644
	quit_script_fully

Preload_Ronald1InClubEntrance:
	get_event_value EVENT_RONALD_FIRST_CLUB_ENTRANCE_ENCOUNTER
	cp TRUE
	ret

Script_FirstRonaldEncounter:
	start_script
	max_out_event_value EVENT_RONALD_FIRST_CLUB_ENTRANCE_ENCOUNTER
	move_active_npc NPCMovement_e894
	load_current_map_name_into_txram_slot 0
	print_npc_text Text0645
	close_text_box
	move_player NORTH, 1
	move_player NORTH, 1
	print_npc_text Text0646
	ask_question_jump_default_yes NULL, .ows_e882
	print_npc_text Text0647
	script_jump .ows_e885

.ows_e882
	print_npc_text Text0648
.ows_e885
	print_npc_text Text0649
	close_text_box
	set_player_direction WEST
	move_player EAST, 4
	move_active_npc NPCMovement_e894
	unload_active_npc
	play_default_song
	quit_script_fully

NPCMovement_e894:
	db SOUTH
	db SOUTH
	db SOUTH
	db SOUTH
	db SOUTH
	db $ff

Preload_Ronald2InClubEntrance:
	get_event_value EVENT_RONALD_FIRST_DUEL_STATE
	ld e, 2 ; medal requirement for ronald duel
Func_e8a0:
	cp RONALD_DUEL_WON
	jr z, .asm_e8b4
	cp RONALD_DUEL_LOST
	jr nc, .asm_e8b2
	call TryGiveMedalPCPacks
	get_event_value EVENT_MEDAL_COUNT
	cp e
	jr z, .asm_e8be
.asm_e8b2
	or a
	ret

.asm_e8b4
	ld a, $08
	ld [wLoadNPCXPos], a
	ld a, $08
	ld [wLoadNPCYPos], a
.asm_e8be
	scf
	ret

Script_FirstRonaldDuel:
	start_script
	move_active_npc NPCMovement_e905
	do_frames 60
	move_active_npc NPCMovement_e90d
	print_npc_text Text064a
	jump_if_player_coords_match 8, 2, .ows_e8d6
	set_player_direction WEST
	move_player WEST, 1
.ows_e8d6
	set_player_direction SOUTH
	move_player SOUTH, 1
	move_player SOUTH, 1
	print_npc_text Text064b
	set_event EVENT_RONALD_FIRST_DUEL_STATE, RONALD_DUEL_WON
	start_duel PRIZES_6, IM_RONALD_DECK_ID, MUSIC_RONALD
	quit_script_fully

Script_BeatFirstRonaldDuel:
	start_script
	print_npc_text Text064c
	give_card JIGGLYPUFF1
	show_card_received_screen JIGGLYPUFF1
	print_npc_text Text064d
	script_jump Script_LostToFirstRonaldDuel.ows_e8fb

Script_LostToFirstRonaldDuel:
	start_script
	print_npc_text Text064e
.ows_e8fb
	set_event EVENT_RONALD_FIRST_DUEL_STATE, RONALD_DUEL_LOST
	close_text_box
	move_active_npc NPCMovement_e90f
	unload_active_npc
	play_default_song
	quit_script_fully

NPCMovement_e905:
	db EAST
	db EAST
	db EAST
	db EAST
	db EAST
	db SOUTH
	db NORTH | NO_MOVE
	db $ff

NPCMovement_e90d:
	db NORTH
	db $ff

NPCMovement_e90f:
	db SOUTH
	db SOUTH
	db SOUTH
	db SOUTH
	db SOUTH
	db $ff

Preload_Ronald3InClubEntrance:
	get_event_value EVENT_RONALD_SECOND_DUEL_STATE
	ld e, 5 ; medal requirement for ronald duel
	jp Func_e8a0

Script_SecondRonaldDuel:
	start_script
	move_active_npc NPCMovement_e905
	do_frames 60
	move_active_npc NPCMovement_e90d
	print_npc_text Text064f
	jump_if_player_coords_match 8, 2, .ows_6934
	set_player_direction WEST
	move_player WEST, 1
.ows_6934
	set_player_direction SOUTH
	move_player SOUTH, 1
	move_player SOUTH, 1
	print_npc_text Text0650
	set_event EVENT_RONALD_SECOND_DUEL_STATE, RONALD_DUEL_WON
	start_duel PRIZES_6, POWERFUL_RONALD_DECK_ID, MUSIC_RONALD
	quit_script_fully

Script_BeatSecondRonaldDuel:
	start_script
	print_npc_text Text0651
	give_card SUPER_ENERGY_RETRIEVAL
	show_card_received_screen SUPER_ENERGY_RETRIEVAL
	print_npc_text Text0652
	script_jump Script_LostToSecondRonaldDuel.ows_e959

Script_LostToSecondRonaldDuel:
	start_script
	print_npc_text Text0653
.ows_e959
	set_event EVENT_RONALD_SECOND_DUEL_STATE, RONALD_DUEL_LOST
	close_text_box
	move_active_npc NPCMovement_e90f
	unload_active_npc
	play_default_song
	quit_script_fully