pokered/scripts/LancesRoom.asm

158 lines
3.7 KiB
NASM
Raw Normal View History

LancesRoom_Script:
call LanceShowOrHideEntranceBlocks
2014-05-18 18:19:10 +00:00
call EnableAutoTextBoxDrawing
ld hl, LancesRoomTrainerHeaders
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
bit BIT_CUR_MAP_LOADED_1, [hl]
res BIT_CUR_MAP_LOADED_1, [hl]
2014-05-18 18:19:10 +00:00
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:
xor a ; SCRIPT_LANCESROOM_DEFAULT
ld [wLancesRoomCurScript], a
2014-05-18 18:19:10 +00:00
ret
LancesRoom_ScriptPointers:
def_script_pointers
dw_const LancesRoomDefaultScript, SCRIPT_LANCESROOM_DEFAULT
dw_const DisplayEnemyTrainerTextAndStartBattle, SCRIPT_LANCESROOM_LANCE_START_BATTLE
dw_const LancesRoomLanceEndBattleScript, SCRIPT_LANCESROOM_LANCE_END_BATTLE
dw_const LancesRoomPlayerIsMovingScript, SCRIPT_LANCESROOM_PLAYER_IS_MOVING
dw_const LancesRoomNoopScript, SCRIPT_LANCESROOM_NOOP
LancesRoomNoopScript:
2014-05-18 18:19:10 +00:00
ret
LancesRoomDefaultScript:
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
ld a, TEXT_LANCESROOM_LANCE
ldh [hTextID], 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
set BIT_CUR_MAP_LOADED_1, [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
LancesRoomLanceEndBattleScript:
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
ld a, TEXT_LANCESROOM_LANCE
ldh [hTextID], 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.
ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN
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
ld a, SCRIPT_LANCESROOM_PLAYER_IS_MOVING
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
LancesRoomPlayerIsMovingScript:
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 ; SCRIPT_LANCESROOM_DEFAULT
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:
def_text_pointers
dw_const LancesRoomLanceText, TEXT_LANCESROOM_LANCE
2014-05-18 18:19:10 +00:00
LancesRoomTrainerHeaders:
def_trainers
LancesRoomTrainerHeader0:
trainer EVENT_BEAT_LANCES_ROOM_TRAINER_0, 0, LancesRoomLanceBeforeBattleText, LancesRoomLanceEndBattleText, LancesRoomLanceAfterBattleText
db -1 ; end
2014-05-18 18:19:10 +00:00
LancesRoomLanceText:
text_asm
ld hl, LancesRoomTrainerHeader0
2014-05-18 18:19:10 +00:00
call TalkToTrainer
jp TextScriptEnd
LancesRoomLanceBeforeBattleText:
text_far _LancesRoomLanceBeforeBattleText
text_end
2014-05-18 18:19:10 +00:00
LancesRoomLanceEndBattleText:
text_far _LancesRoomLanceEndBattleText
text_end
2014-05-18 18:19:10 +00:00
LancesRoomLanceAfterBattleText:
text_far _LancesRoomLanceAfterBattleText
text_asm
2015-07-21 17:36:03 +00:00
SetEvent EVENT_BEAT_LANCE
2014-05-18 18:19:10 +00:00
jp TextScriptEnd