Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/scripts/CeruleanCity.asm
1270 views
1
CeruleanCity_Script:
2
call EnableAutoTextBoxDrawing
3
ld hl, CeruleanCity_ScriptPointers
4
ld a, [wCeruleanCityCurScript]
5
jp CallFunctionInTable
6
7
CeruleanCityClearScripts:
8
xor a ; SCRIPT_CERULEANCITY_DEFAULT
9
ld [wJoyIgnore], a
10
ld [wCeruleanCityCurScript], a
11
ld a, HS_CERULEAN_RIVAL
12
ld [wMissableObjectIndex], a
13
predef_jump HideObject
14
15
CeruleanCity_ScriptPointers:
16
def_script_pointers
17
dw_const CeruleanCityDefaultScript, SCRIPT_CERULEANCITY_DEFAULT
18
dw_const CeruleanCityRivalBattleScript, SCRIPT_CERULEANCITY_RIVAL_BATTLE
19
dw_const CeruleanCityRivalDefeatedScript, SCRIPT_CERULEANCITY_RIVAL_DEFEATED
20
dw_const CeruleanCityRivalCleanupScript, SCRIPT_CERULEANCITY_RIVAL_CLEANUP
21
dw_const CeruleanCityRocketDefeatedScript, SCRIPT_CERULEANCITY_ROCKET_DEFEATED
22
23
CeruleanCityRocketDefeatedScript:
24
ld a, [wIsInBattle]
25
cp $ff
26
jp z, CeruleanCityClearScripts
27
ld a, PAD_CTRL_PAD
28
ld [wJoyIgnore], a
29
SetEvent EVENT_BEAT_CERULEAN_ROCKET_THIEF
30
ld a, TEXT_CERULEANCITY_ROCKET
31
ldh [hTextID], a
32
call DisplayTextID
33
xor a ; SCRIPT_CERULEANCITY_DEFAULT
34
ld [wJoyIgnore], a
35
ld [wCeruleanCityCurScript], a
36
ret
37
38
CeruleanCityDefaultScript:
39
IF DEF(_DEBUG)
40
call DebugPressedOrHeldB
41
ret nz
42
ENDC
43
CheckEvent EVENT_BEAT_CERULEAN_ROCKET_THIEF
44
jr nz, .skipRocketThiefEncounter
45
ld hl, CeruleanCityCoords1
46
call ArePlayerCoordsInArray
47
jr nc, .skipRocketThiefEncounter
48
ld a, [wCoordIndex]
49
cp $1
50
ld a, PLAYER_DIR_UP
51
ld b, SPRITE_FACING_DOWN
52
jr nz, .playerBelowRocketThief
53
ld a, PLAYER_DIR_DOWN
54
ld b, SPRITE_FACING_UP
55
.playerBelowRocketThief
56
ld [wPlayerMovingDirection], a
57
ld a, b
58
ld [wSprite02StateData1FacingDirection], a
59
call Delay3
60
ld a, TEXT_CERULEANCITY_ROCKET
61
ldh [hTextID], a
62
jp DisplayTextID
63
.skipRocketThiefEncounter
64
CheckEvent EVENT_BEAT_CERULEAN_RIVAL
65
ret nz
66
ld hl, CeruleanCityCoords2
67
call ArePlayerCoordsInArray
68
ret nc
69
ld a, [wWalkBikeSurfState]
70
and a
71
jr z, .walking
72
ld a, SFX_STOP_ALL_MUSIC
73
ld [wNewSoundID], a
74
call PlaySound
75
.walking
76
ld c, BANK(Music_MeetRival)
77
ld a, MUSIC_MEET_RIVAL
78
call PlayMusic
79
xor a
80
ldh [hJoyHeld], a
81
ld a, PAD_CTRL_PAD
82
ld [wJoyIgnore], a
83
ld a, [wXCoord]
84
cp 20 ; is the player standing on the right side of the bridge?
85
jr z, .playerOnRightSideOfBridge
86
ld a, CERULEANCITY_RIVAL
87
ldh [hSpriteIndex], a
88
ld a, SPRITESTATEDATA2_MAPX
89
ldh [hSpriteDataOffset], a
90
call GetPointerWithinSpriteStateData2
91
ld [hl], 25
92
.playerOnRightSideOfBridge
93
ld a, HS_CERULEAN_RIVAL
94
ld [wMissableObjectIndex], a
95
predef ShowObject
96
ld de, CeruleanCityMovement1
97
ld a, CERULEANCITY_RIVAL
98
ldh [hSpriteIndex], a
99
call MoveSprite
100
ld a, SCRIPT_CERULEANCITY_RIVAL_BATTLE
101
ld [wCeruleanCityCurScript], a
102
ret
103
104
CeruleanCityCoords1:
105
dbmapcoord 30, 7
106
dbmapcoord 30, 9
107
db -1 ; end
108
109
CeruleanCityCoords2:
110
dbmapcoord 20, 6
111
dbmapcoord 21, 6
112
db -1 ; end
113
114
CeruleanCityMovement1:
115
db NPC_MOVEMENT_DOWN
116
db NPC_MOVEMENT_DOWN
117
db NPC_MOVEMENT_DOWN
118
db -1 ; end
119
120
CeruleanCityFaceRivalScript:
121
ld a, CERULEANCITY_RIVAL
122
ldh [hSpriteIndex], a
123
xor a ; SPRITE_FACING_DOWN
124
ldh [hSpriteFacingDirection], a
125
jp SetSpriteFacingDirectionAndDelay ; face object
126
127
CeruleanCityRivalBattleScript:
128
ld a, [wStatusFlags5]
129
bit BIT_SCRIPTED_NPC_MOVEMENT, a
130
ret nz
131
xor a
132
ld [wJoyIgnore], a
133
ld a, TEXT_CERULEANCITY_RIVAL
134
ldh [hTextID], a
135
call DisplayTextID
136
ld hl, wStatusFlags3
137
set BIT_TALKED_TO_TRAINER, [hl]
138
set BIT_PRINT_END_BATTLE_TEXT, [hl]
139
ld hl, CeruleanCityRivalDefeatedText
140
ld de, CeruleanCityRivalVictoryText
141
call SaveEndBattleTextPointers
142
ld a, OPP_RIVAL1
143
ld [wCurOpponent], a
144
145
; select which team to use during the encounter
146
ld a, [wRivalStarter]
147
cp STARTER2
148
jr nz, .NotSquirtle
149
ld a, $7
150
jr .done
151
.NotSquirtle
152
cp STARTER3
153
jr nz, .Charmander
154
ld a, $8
155
jr .done
156
.Charmander
157
ld a, $9
158
.done
159
ld [wTrainerNo], a
160
161
xor a
162
ldh [hJoyHeld], a
163
call CeruleanCityFaceRivalScript
164
ld a, SCRIPT_CERULEANCITY_RIVAL_DEFEATED
165
ld [wCeruleanCityCurScript], a
166
ret
167
168
CeruleanCityRivalDefeatedScript:
169
ld a, [wIsInBattle]
170
cp $ff
171
jp z, CeruleanCityClearScripts
172
call CeruleanCityFaceRivalScript
173
ld a, PAD_CTRL_PAD
174
ld [wJoyIgnore], a
175
SetEvent EVENT_BEAT_CERULEAN_RIVAL
176
ld a, TEXT_CERULEANCITY_RIVAL
177
ldh [hTextID], a
178
call DisplayTextID
179
ld a, SFX_STOP_ALL_MUSIC
180
ld [wNewSoundID], a
181
call PlaySound
182
farcall Music_RivalAlternateStart
183
ld a, CERULEANCITY_RIVAL
184
ldh [hSpriteIndex], a
185
call SetSpriteMovementBytesToFF
186
ld a, [wXCoord]
187
cp 20 ; is the player standing on the right side of the bridge?
188
jr nz, .playerOnRightSideOfBridge
189
ld de, CeruleanCityMovement4
190
jr .skip
191
.playerOnRightSideOfBridge
192
ld de, CeruleanCityMovement3
193
.skip
194
ld a, CERULEANCITY_RIVAL
195
ldh [hSpriteIndex], a
196
call MoveSprite
197
ld a, SCRIPT_CERULEANCITY_RIVAL_CLEANUP
198
ld [wCeruleanCityCurScript], a
199
ret
200
201
CeruleanCityMovement3:
202
db NPC_MOVEMENT_LEFT
203
db NPC_MOVEMENT_DOWN
204
db NPC_MOVEMENT_DOWN
205
db NPC_MOVEMENT_DOWN
206
db NPC_MOVEMENT_DOWN
207
db NPC_MOVEMENT_DOWN
208
db NPC_MOVEMENT_DOWN
209
db -1 ; end
210
211
CeruleanCityMovement4:
212
db NPC_MOVEMENT_RIGHT
213
db NPC_MOVEMENT_DOWN
214
db NPC_MOVEMENT_DOWN
215
db NPC_MOVEMENT_DOWN
216
db NPC_MOVEMENT_DOWN
217
db NPC_MOVEMENT_DOWN
218
db NPC_MOVEMENT_DOWN
219
db -1 ; end
220
221
CeruleanCityRivalCleanupScript:
222
ld a, [wStatusFlags5]
223
bit BIT_SCRIPTED_NPC_MOVEMENT, a
224
ret nz
225
ld a, HS_CERULEAN_RIVAL
226
ld [wMissableObjectIndex], a
227
predef HideObject
228
xor a
229
ld [wJoyIgnore], a
230
call PlayDefaultMusic
231
ld a, SCRIPT_CERULEANCITY_DEFAULT
232
ld [wCeruleanCityCurScript], a
233
ret
234
235
CeruleanCity_TextPointers:
236
def_text_pointers
237
dw_const CeruleanCityRivalText, TEXT_CERULEANCITY_RIVAL
238
dw_const CeruleanCityRocketText, TEXT_CERULEANCITY_ROCKET
239
dw_const CeruleanCityCooltrainerMText, TEXT_CERULEANCITY_COOLTRAINER_M
240
dw_const CeruleanCitySuperNerd1Text, TEXT_CERULEANCITY_SUPER_NERD1
241
dw_const CeruleanCitySuperNerd2Text, TEXT_CERULEANCITY_SUPER_NERD2
242
dw_const CeruleanCityGuardText, TEXT_CERULEANCITY_GUARD1
243
dw_const CeruleanCityCooltrainerF1Text, TEXT_CERULEANCITY_COOLTRAINER_F1
244
dw_const CeruleanCitySlowbroText, TEXT_CERULEANCITY_SLOWBRO
245
dw_const CeruleanCityCooltrainerF2Text, TEXT_CERULEANCITY_COOLTRAINER_F2
246
dw_const CeruleanCitySuperNerd3Text, TEXT_CERULEANCITY_SUPER_NERD3
247
dw_const CeruleanCityGuardText, TEXT_CERULEANCITY_GUARD2
248
dw_const CeruleanCitySignText, TEXT_CERULEANCITY_SIGN
249
dw_const CeruleanCityTrainerTipsText, TEXT_CERULEANCITY_TRAINER_TIPS
250
dw_const MartSignText, TEXT_CERULEANCITY_MART_SIGN
251
dw_const PokeCenterSignText, TEXT_CERULEANCITY_POKECENTER_SIGN
252
dw_const CeruleanCityBikeShopSign, TEXT_CERULEANCITY_BIKESHOP_SIGN
253
dw_const CeruleanCityGymSign, TEXT_CERULEANCITY_GYM_SIGN
254
255
CeruleanCityRivalText:
256
text_asm
257
CheckEvent EVENT_BEAT_CERULEAN_RIVAL
258
; do pre-battle text
259
jr z, .PreBattle
260
; or talk about bill
261
ld hl, CeruleanCityRivalIWentToBillsText
262
call PrintText
263
jr .end
264
.PreBattle
265
ld hl, .PreBattleText
266
call PrintText
267
.end
268
jp TextScriptEnd
269
270
.PreBattleText:
271
text_far _CeruleanCityRivalPreBattleText
272
text_end
273
274
CeruleanCityRivalDefeatedText:
275
text_far _CeruleanCityRivalDefeatedText
276
text_end
277
278
CeruleanCityRivalVictoryText:
279
text_far _CeruleanCityRivalVictoryText
280
text_end
281
282
CeruleanCityRivalIWentToBillsText:
283
text_far _CeruleanCityRivalIWentToBillsText
284
text_end
285
286
CeruleanCityRocketText:
287
text_asm
288
CheckEvent EVENT_BEAT_CERULEAN_ROCKET_THIEF
289
jr nz, .beatRocketThief
290
ld hl, .Text
291
call PrintText
292
ld hl, wStatusFlags3
293
set BIT_TALKED_TO_TRAINER, [hl]
294
set BIT_PRINT_END_BATTLE_TEXT, [hl]
295
ld hl, .IGiveUpText
296
ld de, .IGiveUpText
297
call SaveEndBattleTextPointers
298
ldh a, [hTextID]
299
ld [wSpriteIndex], a
300
call EngageMapTrainer
301
call InitBattleEnemyParameters
302
ld a, SCRIPT_CERULEANCITY_ROCKET_DEFEATED
303
ld [wCeruleanCityCurScript], a
304
jp TextScriptEnd
305
.beatRocketThief
306
ld hl, .IllReturnTheTMText
307
call PrintText
308
lb bc, TM_DIG, 1
309
call GiveItem
310
jr c, .Success
311
ld hl, .TM28NoRoomText
312
call PrintText
313
jr .Done
314
.Success
315
ld a, $1
316
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
317
ld hl, .ReceivedTM28Text
318
call PrintText
319
farcall CeruleanHideRocket
320
.Done
321
jp TextScriptEnd
322
323
.Text:
324
text_far _CeruleanCityRocketText
325
text_end
326
327
.ReceivedTM28Text:
328
text_far _CeruleanCityRocketReceivedTM28Text
329
sound_get_item_1
330
text_far _CeruleanCityRocketIBetterGetMovingText
331
text_waitbutton
332
text_end
333
334
.TM28NoRoomText:
335
text_far _CeruleanCityRocketTM28NoRoomText
336
text_end
337
338
.IGiveUpText:
339
text_far _CeruleanCityRocketIGiveUpText
340
text_end
341
342
.IllReturnTheTMText:
343
text_far _CeruleanCityRocketIllReturnTheTMText
344
text_end
345
346
CeruleanCityCooltrainerMText:
347
text_far _CeruleanCityCooltrainerMText
348
text_end
349
350
CeruleanCitySuperNerd1Text:
351
text_far _CeruleanCitySuperNerd1Text
352
text_end
353
354
CeruleanCitySuperNerd2Text:
355
text_far _CeruleanCitySuperNerd2Text
356
text_end
357
358
CeruleanCityGuardText:
359
text_far _CeruleanCityGuardText
360
text_end
361
362
CeruleanCityCooltrainerF1Text:
363
text_asm
364
ldh a, [hRandomAdd]
365
cp 180 ; 76/256 chance of 1st dialogue
366
jr c, .notFirstText
367
ld hl, .SlowbroUseSonicboomText
368
call PrintText
369
jr .end
370
.notFirstText
371
cp 100 ; 80/256 chance of 2nd dialogue
372
jr c, .notSecondText
373
ld hl, .SlowbroPunchText
374
call PrintText
375
jr .end
376
.notSecondText
377
; 100/256 chance of 3rd dialogue
378
ld hl, .SlowbroWithdrawText
379
call PrintText
380
.end
381
jp TextScriptEnd
382
383
.SlowbroUseSonicboomText:
384
text_far _CeruleanCityCooltrainerF1SlowbroUseSonicboomText
385
text_end
386
387
.SlowbroPunchText:
388
text_far _CeruleanCityCooltrainerF1SlowbroPunchText
389
text_end
390
391
.SlowbroWithdrawText:
392
text_far _CeruleanCityCooltrainerF1SlowbroWithdrawText
393
text_end
394
395
CeruleanCitySlowbroText:
396
text_asm
397
ldh a, [hRandomAdd]
398
cp 180 ; 76/256 chance of 1st dialogue
399
jr c, .notFirstText
400
ld hl, .TookASnoozeText
401
call PrintText
402
jr .end
403
.notFirstText
404
cp 120 ; 60/256 chance of 2nd dialogue
405
jr c, .notSecondText
406
ld hl, .IsLoafingAroundText
407
call PrintText
408
jr .end
409
.notSecondText
410
cp 60 ; 60/256 chance of 3rd dialogue
411
jr c, .notThirdText
412
ld hl, .TurnedAwayText
413
call PrintText
414
jr .end
415
.notThirdText
416
; 60/256 chance of 4th dialogue
417
ld hl, .IgnoredOrdersText
418
call PrintText
419
.end
420
jp TextScriptEnd
421
422
.TookASnoozeText:
423
text_far _CeruleanCitySlowbroTookASnoozeText
424
text_end
425
426
.IsLoafingAroundText:
427
text_far _CeruleanCitySlowbroIsLoafingAroundText
428
text_end
429
430
.TurnedAwayText:
431
text_far _CeruleanCitySlowbroTurnedAwayText
432
text_end
433
434
.IgnoredOrdersText:
435
text_far _CeruleanCitySlowbroIgnoredOrdersText
436
text_end
437
438
CeruleanCityCooltrainerF2Text:
439
text_far _CeruleanCityCooltrainerF2Text
440
text_end
441
442
CeruleanCitySuperNerd3Text:
443
text_far _CeruleanCitySuperNerd3Text
444
text_end
445
446
CeruleanCitySignText:
447
text_far _CeruleanCitySignText
448
text_end
449
450
CeruleanCityTrainerTipsText:
451
text_far _CeruleanCityTrainerTipsText
452
text_end
453
454
CeruleanCityBikeShopSign:
455
text_far _CeruleanCityBikeShopSign
456
text_end
457
458
CeruleanCityGymSign:
459
text_far _CeruleanCityGymSign
460
text_end
461
462