lance.asm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. LanceScript:
  2. call LanceShowOrHideEntranceBlocks
  3. call EnableAutoTextBoxDrawing
  4. ld hl, LanceTrainerHeader0
  5. ld de, LanceScriptPointers
  6. ld a, [wLanceCurScript]
  7. call ExecuteCurMapScriptInTable
  8. ld [wLanceCurScript], a
  9. ret
  10. LanceShowOrHideEntranceBlocks:
  11. ld hl, wCurrentMapScriptFlags
  12. bit 5, [hl]
  13. res 5, [hl]
  14. ret z
  15. CheckEvent EVENT_LANCES_ROOM_LOCK_DOOR
  16. jr nz, .closeEntrance
  17. ; open entrance
  18. ld a, $31
  19. ld b, $32
  20. jp LanceSetEntranceBlocks
  21. .closeEntrance
  22. ld a, $72
  23. ld b, $73
  24. LanceSetEntranceBlocks:
  25. ; Replaces the tile blocks so the player can't leave.
  26. push bc
  27. ld [wNewTileBlockID], a
  28. lb bc, 6, 2
  29. call LanceSetEntranceBlock
  30. pop bc
  31. ld a, b
  32. ld [wNewTileBlockID], a
  33. lb bc, 6, 3
  34. LanceSetEntranceBlock:
  35. predef_jump ReplaceTileBlock
  36. ResetLanceScript:
  37. xor a
  38. ld [wLanceCurScript], a
  39. ret
  40. LanceScriptPointers:
  41. dw LanceScript0
  42. dw DisplayEnemyTrainerTextAndStartBattle
  43. dw LanceScript2
  44. dw LanceScript3
  45. dw LanceScript4
  46. LanceScript4:
  47. ret
  48. LanceScript0:
  49. CheckEvent EVENT_BEAT_LANCE
  50. ret nz
  51. ld hl, LanceTriggerMovementCoords
  52. call ArePlayerCoordsInArray
  53. jp nc, CheckFightingMapTrainers
  54. xor a
  55. ld [hJoyHeld], a
  56. ld a, [wCoordIndex]
  57. cp $3 ; Is player standing next to Lance's sprite?
  58. jr nc, .notStandingNextToLance
  59. ld a, $1
  60. ld [hSpriteIndexOrTextID], a
  61. jp DisplayTextID
  62. .notStandingNextToLance
  63. cp $5 ; Is player standing on the entrance staircase?
  64. jr z, WalkToLance
  65. CheckAndSetEvent EVENT_LANCES_ROOM_LOCK_DOOR
  66. ret nz
  67. ld hl, wCurrentMapScriptFlags
  68. set 5, [hl]
  69. ld a, SFX_GO_INSIDE
  70. call PlaySound
  71. jp LanceShowOrHideEntranceBlocks
  72. LanceTriggerMovementCoords:
  73. db $01,$05
  74. db $02,$06
  75. db $0B,$05
  76. db $0B,$06
  77. db $10,$18
  78. db $FF
  79. LanceScript2:
  80. call EndTrainerBattle
  81. ld a, [wIsInBattle]
  82. cp $ff
  83. jp z, ResetLanceScript
  84. ld a, $1
  85. ld [hSpriteIndexOrTextID], a
  86. jp DisplayTextID
  87. WalkToLance:
  88. ; Moves the player down the hallway to Lance's room.
  89. ld a, $ff
  90. ld [wJoyIgnore], a
  91. ld hl, wSimulatedJoypadStatesEnd
  92. ld de, WalkToLance_RLEList
  93. call DecodeRLEList
  94. dec a
  95. ld [wSimulatedJoypadStatesIndex], a
  96. call StartSimulatingJoypadStates
  97. ld a, $3
  98. ld [wLanceCurScript], a
  99. ld [wCurMapScript], a
  100. ret
  101. WalkToLance_RLEList:
  102. db D_UP, $0C
  103. db D_LEFT, $0C
  104. db D_DOWN, $07
  105. db D_LEFT, $06
  106. db $FF
  107. LanceScript3:
  108. ld a, [wSimulatedJoypadStatesIndex]
  109. and a
  110. ret nz
  111. call Delay3
  112. xor a
  113. ld [wJoyIgnore], a
  114. ld [wLanceCurScript], a
  115. ld [wCurMapScript], a
  116. ret
  117. LanceTextPointers:
  118. dw LanceText1
  119. LanceTrainerHeader0:
  120. dbEventFlagBit EVENT_BEAT_LANCES_ROOM_TRAINER_0
  121. db ($0 << 4) ; trainer's view range
  122. dwEventFlagAddress EVENT_BEAT_LANCES_ROOM_TRAINER_0
  123. dw LanceBeforeBattleText ; TextBeforeBattle
  124. dw LanceAfterBattleText ; TextAfterBattle
  125. dw LanceEndBattleText ; TextEndBattle
  126. dw LanceEndBattleText ; TextEndBattle
  127. db $ff
  128. LanceText1:
  129. TX_ASM
  130. ld hl, LanceTrainerHeader0
  131. call TalkToTrainer
  132. jp TextScriptEnd
  133. LanceBeforeBattleText:
  134. TX_FAR _LanceBeforeBattleText
  135. db "@"
  136. LanceEndBattleText:
  137. TX_FAR _LanceEndBattleText
  138. db "@"
  139. LanceAfterBattleText:
  140. TX_FAR _LanceAfterBattleText
  141. TX_ASM
  142. SetEvent EVENT_BEAT_LANCE
  143. jp TextScriptEnd