pokered/scripts/LancesRoom.asm

154 lines
2.9 KiB
NASM
Raw Normal View History

LancesRoom_Script:
call LanceShowOrHideEntranceBlocks
2014-05-18 18:19:10 +00:00
call EnableAutoTextBoxDrawing
ld hl, LanceTrainerHeader0
ld de, LancesRoom_ScriptPointers
ld a, [wLancesRoomCurScript]
2014-05-18 18:19:10 +00:00
call ExecuteCurMapScriptInTable
ld [wLancesRoomCurScript], a
2014-05-18 18:19:10 +00:00
ret
2016-06-12 00:24:04 +00:00
LanceShowOrHideEntranceBlocks:
2016-01-03 19:17:10 +00:00
ld hl, wCurrentMapScriptFlags
2014-05-18 18:19:10 +00:00
bit 5, [hl]
res 5, [hl]
ret z
2015-07-21 17:36:03 +00:00
CheckEvent EVENT_LANCES_ROOM_LOCK_DOOR
jr nz, .closeEntrance
; open entrance
2014-05-18 18:19:10 +00:00
ld a, $31
ld b, $32
2020-11-06 15:33:58 +00:00
jp .setEntranceBlocks
.closeEntrance
2014-05-18 18:19:10 +00:00
ld a, $72
ld b, $73
2020-11-06 15:33:58 +00:00
.setEntranceBlocks
; Replaces the tile blocks so the player can't leave.
2014-05-18 18:19:10 +00:00
push bc
2015-07-24 21:39:45 +00:00
ld [wNewTileBlockID], a
2015-08-05 21:20:29 +00:00
lb bc, 6, 2
2020-11-06 15:33:58 +00:00
call .SetEntranceBlock
2014-05-18 18:19:10 +00:00
pop bc
ld a, b
2015-07-24 21:39:45 +00:00
ld [wNewTileBlockID], a
2015-08-05 21:20:29 +00:00
lb bc, 6, 3
2020-11-06 15:33:58 +00:00
.SetEntranceBlock:
2014-09-14 18:29:18 +00:00
predef_jump ReplaceTileBlock
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
ResetLanceScript:
2014-05-18 18:19:10 +00:00
xor a
ld [wLancesRoomCurScript], a
2014-05-18 18:19:10 +00:00
ret
LancesRoom_ScriptPointers:
2014-05-18 18:19:10 +00:00
dw LanceScript0
2014-09-14 18:29:18 +00:00
dw DisplayEnemyTrainerTextAndStartBattle
2014-05-18 18:19:10 +00:00
dw LanceScript2
dw LanceScript3
dw LanceScript4
2016-06-12 00:24:04 +00:00
LanceScript4:
2014-05-18 18:19:10 +00:00
ret
2016-06-12 00:24:04 +00:00
LanceScript0:
2015-07-21 17:36:03 +00:00
CheckEvent EVENT_BEAT_LANCE
2014-05-18 18:19:10 +00:00
ret nz
ld hl, LanceTriggerMovementCoords
2014-05-18 18:19:10 +00:00
call ArePlayerCoordsInArray
jp nc, CheckFightingMapTrainers
xor a
ldh [hJoyHeld], a
2015-07-19 03:49:52 +00:00
ld a, [wCoordIndex]
cp $3 ; Is player standing next to Lance's sprite?
jr nc, .notStandingNextToLance
2014-05-18 18:19:10 +00:00
ld a, $1
ldh [hSpriteIndexOrTextID], a
2014-05-18 18:19:10 +00:00
jp DisplayTextID
.notStandingNextToLance
cp $5 ; Is player standing on the entrance staircase?
jr z, WalkToLance
2015-07-21 17:36:03 +00:00
CheckAndSetEvent EVENT_LANCES_ROOM_LOCK_DOOR
2014-05-18 18:19:10 +00:00
ret nz
2016-01-03 19:17:10 +00:00
ld hl, wCurrentMapScriptFlags
2014-05-18 18:19:10 +00:00
set 5, [hl]
2015-07-19 08:46:12 +00:00
ld a, SFX_GO_INSIDE
2014-05-18 18:19:10 +00:00
call PlaySound
jp LanceShowOrHideEntranceBlocks
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceTriggerMovementCoords:
dbmapcoord 5, 1
dbmapcoord 6, 2
dbmapcoord 5, 11
dbmapcoord 6, 11
dbmapcoord 24, 16
db -1 ; end
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceScript2:
2014-05-18 18:19:10 +00:00
call EndTrainerBattle
2015-08-31 02:38:41 +00:00
ld a, [wIsInBattle]
2014-05-18 18:19:10 +00:00
cp $ff
jp z, ResetLanceScript
2014-05-18 18:19:10 +00:00
ld a, $1
ldh [hSpriteIndexOrTextID], a
2014-05-18 18:19:10 +00:00
jp DisplayTextID
2016-06-12 00:24:04 +00:00
WalkToLance:
; Moves the player down the hallway to Lance's room.
2014-05-18 18:19:10 +00:00
ld a, $ff
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
ld hl, wSimulatedJoypadStatesEnd
ld de, WalkToLance_RLEList
2014-05-18 18:19:10 +00:00
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
2014-05-18 18:19:10 +00:00
ld a, $3
ld [wLancesRoomCurScript], a
2015-08-31 02:38:41 +00:00
ld [wCurMapScript], a
2014-05-18 18:19:10 +00:00
ret
2016-06-12 00:24:04 +00:00
WalkToLance_RLEList:
db D_UP, 12
db D_LEFT, 12
db D_DOWN, 7
db D_LEFT, 6
db -1 ; end
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceScript3:
2020-07-16 16:48:42 +00:00
ld a, [wSimulatedJoypadStatesIndex]
and a
2014-05-18 18:19:10 +00:00
ret nz
call Delay3
xor a
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
ld [wLancesRoomCurScript], a
2015-08-31 02:38:41 +00:00
ld [wCurMapScript], a
2014-05-18 18:19:10 +00:00
ret
LancesRoom_TextPointers:
2014-05-18 18:19:10 +00:00
dw LanceText1
2016-06-12 00:24:04 +00:00
LanceTrainerHeader0:
trainer EVENT_BEAT_LANCES_ROOM_TRAINER_0, 0, LanceBeforeBattleText, LanceEndBattleText, LanceAfterBattleText
db -1 ; end
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceText1:
text_asm
2014-05-18 18:19:10 +00:00
ld hl, LanceTrainerHeader0
call TalkToTrainer
jp TextScriptEnd
2016-06-12 00:24:04 +00:00
LanceBeforeBattleText:
text_far _LanceBeforeBattleText
text_end
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceEndBattleText:
text_far _LanceEndBattleText
text_end
2014-05-18 18:19:10 +00:00
2016-06-12 00:24:04 +00:00
LanceAfterBattleText:
text_far _LanceAfterBattleText
text_asm
2015-07-21 17:36:03 +00:00
SetEvent EVENT_BEAT_LANCE
2014-05-18 18:19:10 +00:00
jp TextScriptEnd