summaryrefslogtreecommitdiff
path: root/data/scripts/trainer_tower.inc
blob: 94f1c72632377a63a54d047d1e6eaf800b47771f (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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
@ Local IDs apply to all floors (not lobby or roof)
.equ LOCALID_TRAINER_DOUBLES1, 2
.equ LOCALID_TRAINER_SINGLES,  3
.equ LOCALID_TRAINER_KNOCKOUT, 4
.equ LOCALID_TRAINER_DOUBLES2, 5

.equ HIDE_TRAINER_DOUBLES1, FLAG_TEMP_2
.equ HIDE_TRAINER_SINGLES,  FLAG_TEMP_3
.equ HIDE_TRAINER_KNOCKOUT, FLAG_TEMP_4
.equ HIDE_TRAINER_DOUBLES2, FLAG_TEMP_5
.equ HIDE_OWNER,            FLAG_TEMP_6

.equ DISABLE_SINGLES_TRIGGER,  VAR_TEMP_E
.equ DISABLE_DOUBLES_TRIGGER,  VAR_TEMP_F


@@ Map scripts

TrainerTower_OnResume:: @ 81C4F54
	setvar VAR_TEMP_2, 0
	ttower_resumetimer
	end

TrainerTower_OnTransition:: @ 81C4F62
	ttower_initfloor
	switch VAR_RESULT
	case CHALLENGE_TYPE_SINGLE, TrainerTower_EventScript_SetObjectsSingles
	case CHALLENGE_TYPE_DOUBLE, TrainerTower_EventScript_SetObjectsDoubles
	case CHALLENGE_TYPE_KNOCKOUT, TrainerTower_EventScript_SetObjectsKnockout
	setflag HIDE_TRAINER_DOUBLES1
	setflag HIDE_TRAINER_SINGLES
	setflag HIDE_TRAINER_KNOCKOUT
	setflag HIDE_TRAINER_DOUBLES2
	setvar DISABLE_SINGLES_TRIGGER, TRUE
	setvar DISABLE_DOUBLES_TRIGGER, TRUE
	end

TrainerTower_EventScript_SetObjectsSingles:: @ 81C4FA7
	setflag HIDE_TRAINER_DOUBLES1
	setflag HIDE_TRAINER_KNOCKOUT
	setflag HIDE_TRAINER_DOUBLES2
	setvar DISABLE_DOUBLES_TRIGGER, TRUE
	setobjectxyperm       LOCALID_TRAINER_SINGLES, 15, 13
	setobjectmovementtype LOCALID_TRAINER_SINGLES, MOVEMENT_TYPE_FACE_LEFT
	goto TrainerTower_EventScript_HideOwner

TrainerTower_EventScript_SetObjectsDoubles:: @ 81C4FC5
	setflag HIDE_TRAINER_SINGLES
	setflag HIDE_TRAINER_KNOCKOUT
	setvar DISABLE_SINGLES_TRIGGER, TRUE
	ttower_isfloorcleared
	compare VAR_RESULT, TRUE
	goto_if_eq TrainerTower_EventScript_SetObjectsDoublesAlreadyBeaten
	setobjectxyperm       LOCALID_TRAINER_DOUBLES1, 10, 12
	setobjectmovementtype LOCALID_TRAINER_DOUBLES1, MOVEMENT_TYPE_FACE_LEFT
	setobjectxyperm       LOCALID_TRAINER_DOUBLES2, 10, 13
	setobjectmovementtype LOCALID_TRAINER_DOUBLES2, MOVEMENT_TYPE_FACE_LEFT
	goto TrainerTower_EventScript_HideOwner

TrainerTower_EventScript_SetObjectsDoublesAlreadyBeaten:: @ 81C4FFE
	setobjectxyperm       LOCALID_TRAINER_DOUBLES1, 10, 12
	setobjectmovementtype LOCALID_TRAINER_DOUBLES1, MOVEMENT_TYPE_FACE_DOWN
	setobjectxyperm       LOCALID_TRAINER_DOUBLES2, 11, 12
	setobjectmovementtype LOCALID_TRAINER_DOUBLES2, MOVEMENT_TYPE_FACE_DOWN
	goto TrainerTower_EventScript_HideOwner

@ Knockout challenge re-uses trainer objects
TrainerTower_EventScript_SetObjectsKnockout:: @ 81C5019
	setflag HIDE_TRAINER_DOUBLES2
	setvar DISABLE_DOUBLES_TRIGGER, TRUE
	setobjectxyperm       LOCALID_TRAINER_DOUBLES1, 10, 10
	setobjectmovementtype LOCALID_TRAINER_DOUBLES1, MOVEMENT_TYPE_FACE_DOWN
	setobjectxyperm       LOCALID_TRAINER_SINGLES, 14, 13
	setobjectmovementtype LOCALID_TRAINER_SINGLES, MOVEMENT_TYPE_FACE_LEFT
	setobjectxyperm       LOCALID_TRAINER_KNOCKOUT, 10, 16
	setobjectmovementtype LOCALID_TRAINER_KNOCKOUT, MOVEMENT_TYPE_FACE_UP
TrainerTower_EventScript_HideOwner:
	setflag HIDE_OWNER
	end

TrainerTower_OnFrame:: @ 81C5046
	map_script_2 VAR_TEMP_2, 0, TrainerTower_EventScript_EnterFloor
	.2byte 0

TrainerTower_EventScript_EnterFloor:: @ 81C5050
	setvar VAR_TEMP_2, 1
	ttower_isfloorcleared
	compare VAR_RESULT, FALSE
	goto_if_eq TrainerTower_EventScript_EndEnterFloor
	setvar DISABLE_SINGLES_TRIGGER, TRUE
	setvar DISABLE_DOUBLES_TRIGGER, TRUE
TrainerTower_EventScript_EndEnterFloor:
	ttower_shouldexit
	compare VAR_RESULT, TRUE
	goto_if_eq TrainerTower_EventScript_WarpToLobby
	end

@ Never reached
TrainerTower_EventScript_WarpToLobby:: @ 81C5086
	warp MAP_TRAINER_TOWER_LOBBY, 255, 9, 7
	waitstate


@@ Battle scripts

TrainerTower_EventScript_TriggerBattle::
	ttower_getchallengetype
	switch VAR_RESULT
	case CHALLENGE_TYPE_SINGLE, TrainerTower_EventScript_DoSingleBattle
	case CHALLENGE_TYPE_DOUBLE, TrainerTower_EventScript_DoDoubleBattle
	case CHALLENGE_TYPE_KNOCKOUT, TrainerTower_EventScript_DoKnockoutBattle

TrainerTower_EventScript_DoSingleBattle:
	ttower_encountermusic
	applymovement LOCALID_TRAINER_SINGLES, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_SINGLES, Movement_Delay48
	waitmovement 0
	setvar DISABLE_SINGLES_TRIGGER, TRUE
	applymovement LOCALID_TRAINER_SINGLES, TrainerTower_Movement_SingleTrainerApproach
	waitmovement 0
	ttower_getspeech TRAINER_TOWER_TEXT_INTRO, 0
	msgbox gStringVar4
	closemessage
	goto TrainerTower_EventScript_DoBattle

TrainerTower_EventScript_DoDoubleBattle:: @ 81C510D
	ttower_getspeech TRAINER_TOWER_TEXT_INTRO, VAR_TEMP_3
	msgbox gStringVar4
	setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_SPEECH
	setvar VAR_0x8005, TRAINER_TOWER_TEXT_INTRO
	addvar VAR_TEMP_3, 1
	compare VAR_TEMP_3, 1
	goto_if_eq TrainerTower_EventScript_DoSecondTrainerIntro
	setvar VAR_TEMP_3, 0
TrainerTower_EventScript_DoSecondTrainerIntro:
	copyvar VAR_0x8006, VAR_TEMP_3
	special CallTrainerTowerFunc
	msgbox gStringVar4
	closemessage
	goto TrainerTower_EventScript_DoBattle

TrainerTower_EventScript_DoKnockoutBattle:: @ 81C515C
	switch VAR_TEMP_1
	case 0, TrainerTower_EventScript_DoKnockoutBattle1
	case 1, TrainerTower_EventScript_DoKnockoutBattle2
	case 2, TrainerTower_EventScript_DoKnockoutBattle3

TrainerTower_EventScript_DoKnockoutBattle1:
	ttower_encountermusic
	applymovement LOCALID_TRAINER_KNOCKOUT, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_KNOCKOUT, Movement_Delay48
	waitmovement 0
	applymovement LOCALID_TRAINER_KNOCKOUT, TrainerTower_Movement_BottomKnockoutTrainerApproach
	waitmovement 0
	goto TrainerTower_EventScript_DoKnockoutBattleIntro

TrainerTower_EventScript_DoKnockoutBattle2:: @ 81C51AD
	ttower_encountermusic
	applymovement LOCALID_TRAINER_DOUBLES1, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_DOUBLES1, Movement_Delay48
	waitmovement 0
	applymovement LOCALID_TRAINER_DOUBLES1, TrainerTower_Movement_TopKnockoutTrainerApproach
	waitmovement 0
	goto TrainerTower_EventScript_DoKnockoutBattleIntro

TrainerTower_EventScript_DoKnockoutBattle3:: @ 81C51D8
	ttower_encountermusic
	applymovement LOCALID_TRAINER_SINGLES, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_SINGLES, Movement_Delay48
	waitmovement 0
	applymovement LOCALID_TRAINER_SINGLES, TrainerTower_Movement_RightKnockoutTrainerApproach
	waitmovement 0
TrainerTower_EventScript_DoKnockoutBattleIntro:
	ttower_getspeech TRAINER_TOWER_TEXT_INTRO, VAR_TEMP_1
	msgbox gStringVar4
	closemessage
TrainerTower_EventScript_DoBattle:
	ttower_dobattle
	waitstate
	switch VAR_RESULT
	case B_OUTCOME_WON, TrainerTower_EventScript_WonBattle
	case B_OUTCOME_LOST, TrainerTower_EventScript_WarpToLobbyLost
	case B_OUTCOME_DREW, TrainerTower_EventScript_WarpToLobbyLost
TrainerTower_EventScript_WonBattle:
	ttower_getchallengetype
	switch VAR_RESULT
	case CHALLENGE_TYPE_SINGLE, TrainerTower_EventScript_SetFloorCleared
	case CHALLENGE_TYPE_DOUBLE, TrainerTower_EventScript_MoveDoublesTrainers
	case CHALLENGE_TYPE_KNOCKOUT, TrainerTower_EventScript_CheckNextKnockoutBattle

TrainerTower_EventScript_CheckNextKnockoutBattle:
	switch VAR_TEMP_1
	case 0, TrainerTower_EventScript_DoSecondKnockoutBattle
	case 1, TrainerTower_EventScript_DoThirdKnockoutBattle
	case 2, TrainerTower_EventScript_MoveLastKnockoutTrainer

TrainerTower_EventScript_DoSecondKnockoutBattle:
	addvar VAR_TEMP_1, 1
	goto TrainerTower_EventScript_DoKnockoutBattle

TrainerTower_EventScript_DoThirdKnockoutBattle:: @ 81C52B0
	addvar VAR_TEMP_1, 1
	goto TrainerTower_EventScript_DoKnockoutBattle

TrainerTower_EventScript_MoveDoublesTrainers:: @ 81C52BA
	applymovement LOCALID_TRAINER_DOUBLES2, TrainerTower_Movement_DoublesTrainer2OutOfWay
	waitmovement 0
	applymovement LOCALID_TRAINER_DOUBLES1, TrainerTower_Movement_DoublesTrainer1FaceDown
	goto TrainerTower_EventScript_SetFloorCleared

TrainerTower_EventScript_MoveLastKnockoutTrainer:: @ 81C52D0
	applymovement LOCALID_TRAINER_SINGLES, TrainerTower_Movement_LastKnockoutTrainerOutOfWay
TrainerTower_EventScript_SetFloorCleared:
	ttower_clearedfloor
	end

TrainerTower_EventScript_WarpToLobbyLost:: @ 81C52E0
	special HealPlayerParty
	ttower_setlost
	warp MAP_TRAINER_TOWER_LOBBY, 255, 9, 7
	waitstate


@@ Speaking to trainers after battle

TrainerTower_EventScript_SpeakToDoublesTrainer1:: @ 81C52F4
	ttower_getchallengetype
	switch VAR_RESULT
	case CHALLENGE_TYPE_SINGLE, TrainerTower_EventScript_DoublesTrainer1PostBattle
	case CHALLENGE_TYPE_DOUBLE, TrainerTower_EventScript_DoublesTrainer1PostBattle
	case CHALLENGE_TYPE_KNOCKOUT, TrainerTower_EventScript_KnockoutTrainer2PostBattle
TrainerTower_EventScript_DoublesTrainer1PostBattle:
	setvar VAR_0x8006, 0
	goto TrainerTower_EventScript_DoPostBattleText

TrainerTower_EventScript_KnockoutTrainer2PostBattle:: @ 81C5331
	setvar VAR_0x8006, 1
	goto TrainerTower_EventScript_DoPostBattleText

TrainerTower_EventScript_SpeakToSinglesTrainer:: @ 81C533B
	ttower_getchallengetype
	switch VAR_RESULT
	case CHALLENGE_TYPE_SINGLE, TrainerTower_EventScript_SinglesTrainerPostBattle
	case CHALLENGE_TYPE_DOUBLE, TrainerTower_EventScript_SinglesTrainerPostBattle
	case CHALLENGE_TYPE_KNOCKOUT, TrainerTower_EventScript_KnockoutTrainer3PostBattle
TrainerTower_EventScript_SinglesTrainerPostBattle:
	setvar VAR_0x8006, 0
	goto TrainerTower_EventScript_DoPostBattleText

TrainerTower_EventScript_KnockoutTrainer3PostBattle:: @ 81C5378
	setvar VAR_0x8006, 2
	goto TrainerTower_EventScript_DoPostBattleText

TrainerTower_EventScript_SpeakToKnockoutTrainer:: @ 81C5382
	setvar VAR_0x8006, 0
	goto TrainerTower_EventScript_DoPostBattleText

TrainerTower_EventScript_SpeakToDoublesTrainer2:: @ 81C538C
	setvar VAR_0x8006, 1
TrainerTower_EventScript_DoPostBattleText:
	ttower_getspeech TRAINER_TOWER_TEXT_AFTER
	lock
	faceplayer
	msgbox gStringVar4
	release
	return


@@ Speaking to owner

TrainerTower_EventScript_SpeakToOwner:: @ 81C53AA
	lock
	faceplayer
	ttower_getownerstate
	switch VAR_RESULT
	case 0, TrainerTower_Roof_EventScript_Arrived
	case 1, TrainerTower_Roof_EventScript_GivePrize
	case 2, TrainerTower_Roof_EventScript_OwnerEnd

TrainerTower_Roof_EventScript_Arrived:
	msgbox TrainerTower_Roof_Text_ImOwnerBattledPerfectly
TrainerTower_Roof_EventScript_GivePrize:
	ttower_giveprize
	switch VAR_RESULT
	case 0, TrainerTower_Roof_EventScript_ReceivePrize
	case 1, TrainerTower_Roof_EventScript_NoRoomForPrize
	case 2, TrainerTower_Roof_EventScript_CheckFinalTime

TrainerTower_Roof_EventScript_ReceivePrize:
	msgbox TrainerTower_Roof_Text_ThisIsForYou
	textcolor 3
	playfanfare MUS_LEVEL_UP
	message Text_ObtainedTheX
	waitfanfare
	waitmessage
	getstdstring 2, STDSTRING_ITEMS_POCKET
	msgbox Text_PutItemAway
	call EventScript_RestorePrevTextColor
	goto TrainerTower_Roof_EventScript_CheckFinalTime

TrainerTower_Roof_EventScript_NoRoomForPrize:: @ 81C543A
	msgbox TrainerTower_Roof_Text_ThisIsForYou
	msgbox Text_BagIsFull
	goto TrainerTower_Roof_EventScript_CheckFinalTime

TrainerTower_Roof_EventScript_CheckFinalTime:: @ 81C544F
	ttower_checkfinaltime
	switch VAR_RESULT
	case 0, TrainerTower_Roof_EventScript_NewRecord
	case 1, TrainerTower_Roof_EventScript_NoNewRecord
	case 2, TrainerTower_Roof_EventScript_OwnerEnd

TrainerTower_Roof_EventScript_NewRecord:
	msgbox TrainerTower_Roof_Text_DoneItInRecordTime
	goto TrainerTower_Roof_EventScript_OwnerEnd

TrainerTower_Roof_EventScript_NoNewRecord:: @ 81C548A
	msgbox TrainerTower_Roof_Text_TookSweetTimeGettingHere
TrainerTower_Roof_EventScript_OwnerEnd:
	msgbox TrainerTower_Roof_Text_IdLikeToSeeBetterTime
	release
	return

TrainerTower_EventScript_ShowTime:: @ 81C549C
	lockall
	ttower_gettime
	msgbox TrainerTower_Text_XMinYZSec
	releaseall
	end


@@ Battle triggers

TrainerTower_EventScript_SingleBattleTrigger:: @ 81C54AF
	goto TrainerTower_EventScript_TriggerBattle

TrainerTower_EventScript_DoubleBattleTriggerTop:: @ 81C54B4
	setvar VAR_TEMP_3, 0
	ttower_checkdoubles
	compare VAR_RESULT, PLAYER_HAS_TWO_USABLE_MONS
	goto_if_ne TrainerTower_EventScript_IneligibleForDoubleBattle
	ttower_encountermusic
	applymovement LOCALID_TRAINER_DOUBLES1, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_DOUBLES1, Movement_Delay48
	goto TrainerTower_EventScript_TriggerDoubleBattle

TrainerTower_EventScript_DoubleBattleTriggerBottom:: @ 81C54EA
	setvar VAR_TEMP_3, 1
	ttower_checkdoubles
	compare VAR_RESULT, PLAYER_HAS_TWO_USABLE_MONS
	goto_if_ne TrainerTower_EventScript_IneligibleForDoubleBattle
	ttower_encountermusic
	applymovement LOCALID_TRAINER_DOUBLES2, Movement_ExclamationMark
	waitmovement 0
	applymovement LOCALID_TRAINER_DOUBLES2, Movement_Delay48
TrainerTower_EventScript_TriggerDoubleBattle:
	waitmovement 0
	setvar DISABLE_DOUBLES_TRIGGER, TRUE
	goto TrainerTower_EventScript_TriggerBattle

TrainerTower_EventScript_IneligibleForDoubleBattle:: @ 81C5528
	lockall
	playse SE_DING_DONG
	msgbox TrainerTower_Lobby_Text_NeedTwoMonsForDouble
	closemessage
	applymovement OBJ_EVENT_ID_PLAYER, TrainerTower_Movement_PushPlayerBack
	waitmovement 0
	releaseall
	end

TrainerTower_Movement_SingleTrainerApproach:
	walk_left
TrainerTower_Movement_RightKnockoutTrainerApproach:: @ 81C5542
	walk_left
	walk_left
TrainerTower_Movement_PushPlayerBack:
	walk_left
	step_end

TrainerTower_Movement_BottomKnockoutTrainerApproach:: @ 81C5546
	walk_up
	walk_up
	step_end

TrainerTower_Movement_TopKnockoutTrainerApproach:: @ 81C5549
	walk_down
	walk_down
	step_end

TrainerTower_Movement_DoublesTrainer2OutOfWay:: @ 81C554C
	walk_right
TrainerTower_Movement_LastKnockoutTrainerOutOfWay:
	walk_up
	face_down
	step_end

TrainerTower_Movement_DoublesTrainer1FaceDown:: @ 81C5550
	face_down
	step_end