Implement talker events: core functionality done [commit 4] (#30)

This commit is contained in:
xCrystal 2023-11-29 20:04:08 +01:00
parent 6f4fcf580a
commit dbc0221e15
6 changed files with 220 additions and 190 deletions

View File

@ -348,7 +348,7 @@ If <code><i>item_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[hScriptVar]` i
## `$64`: <code>winlosstext <i>win_text_pointer</i>, <i>loss_text_pointer</i></code>
## `$65`: `scripttalkafter`
## `$65`: `jumptrainerafterbattlescript`
## `$66`: `endifjustbattled`

View File

@ -29,12 +29,13 @@ StartBattleWithMapTrainerScript:
loadmem wRunningTrainerBattleScript, -1
AlreadyBeatenTrainerScript:
scripttalkafter
jumptrainerafterbattlescript
SeenByTalkerScript::
waitsfx ; wait for any pending space-related sfx
; playsound SFX_
showemote EMOTE_TALK, LAST_TALKED, 20
trainerortalkerflagaction SET_FLAG
callasm .TalkOrSkipTalker
iffalse .skipped
callasm TrainerOrTalkerWalkToPlayer
@ -45,7 +46,6 @@ SeenByTalkerScript::
ifequal TALKERTYPE_TEXT, .Text
ifequal TALKERTYPE_SCRIPT, .Script
.skipped
trainerortalkerflagaction SET_FLAG
end
.Text
@ -53,12 +53,10 @@ SeenByTalkerScript::
trainerortalkertext TRAINERORTALKERTEXT_TALKER
waitbutton
closetext
trainerortalkerflagaction SET_FLAG
end
.Script
trainerortalkerflagaction SET_FLAG
end
jumptalkerscript
.TalkOrSkipTalker:
ld a, [wTempTalkerType]

View File

@ -70,6 +70,11 @@ DisableSpaceEffects:
res 4, [hl]
ret
DisableTrainerAndTalkerEvents: ; unreferenced
ld hl, wScriptFlags2
res 5, [hl]
ret
EnableWarpsConnxns: ; unreferenced
ld hl, wScriptFlags2
set 2, [hl]
@ -95,6 +100,11 @@ EnableSpaceEffects: ; unreferenced
set 4, [hl]
ret
EnableTrainerAndTalkerEvents: ; unreferenced
ld hl, wScriptFlags2
set 5, [hl]
ret
CheckWarpConnxnScriptFlag:
ld hl, wScriptFlags2
bit 2, [hl]
@ -120,6 +130,11 @@ CheckSpaceEffectsScriptFlag:
bit 4, [hl]
ret
CheckTrainerAndTalkerEvents:
ld hl, wScriptFlags2
bit 5, [hl]
ret
; on enter overworld loop
StartMap:
xor a
@ -452,9 +467,11 @@ CheckBoardEvent:
assert_table_length NUM_COLL_SPACES
CheckTrainerOrTalkerEvent:
call CheckTrainerAndTalkerEvents
jr z, .nope
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
call CheckTrainerBattleOrTalkerPrompt
jr nc, .nope
@ -483,7 +500,7 @@ CheckTileEvent:
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
call CheckWarpTile
jr c, .warp_tile
@ -491,7 +508,7 @@ CheckTileEvent:
.connections_disabled
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
call CheckCoordEventScriptFlag
jr z, .coord_events_disabled
@ -570,7 +587,7 @@ SetMinTwoStepWildEncounterCooldown: ; unreferenced
RunSceneScript:
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
ld a, [wCurMapSceneScriptCount]
and a
@ -622,7 +639,7 @@ endr
CheckTimeEvents:
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
ld a, [wLinkMode]
and a
@ -1214,11 +1231,11 @@ WarpToSpawnPoint::
RunMemScript::
ldh a, [hCurBoardEvent]
cp BOARDEVENT_VIEW_MAP_MODE
ret z
ret z ; nc
; If there is no script here, we don't need to be here.
ld a, [wMapReentryScriptQueueFlag]
and a
ret z
ret z ; nc
; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress).
ld hl, wMapReentryScriptAddress
ld a, [hli]

View File

@ -165,7 +165,7 @@ ScriptCommandTable:
dw Script_trainerortalkertext ; 62
dw Script_trainerortalkerflagaction ; 63
dw Script_winlosstext ; 64
dw Script_scripttalkafter ; 65
dw Script_jumptrainerafterbattlescript ; 65
dw Script_endifjustbattled ; 66
dw Script_checkjustbattled ; 67
dw Script_setlasttalked ; 68
@ -236,6 +236,7 @@ ScriptCommandTable:
dw Script_checksave ; a9
dw Script_exitoverworld ; aa
dw Script_reloadmapafterviewmapmode ; ab
dw Script_jumptalkerscript ; ac
assert_table_length NUM_EVENT_COMMANDS
StartScript:
@ -680,7 +681,16 @@ Script_trainerortalkertext:
call MapTextbox
ret
Script_scripttalkafter:
Script_jumptalkerscript:
ld hl, wTempTalkerTextOrScriptPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wSeenTrainerOrTalkerBank]
ld b, a
jp ScriptJump
Script_jumptrainerafterbattlescript:
ld hl, wScriptAfterPointer
ld a, [hli]
ld h, [hl]

View File

@ -645,9 +645,9 @@ MACRO winlosstext
dw \2 ; loss_text_pointer
ENDM
const scripttalkafter_command ; $65
MACRO scripttalkafter
db scripttalkafter_command
const jumptrainerafterbattlescript_command ; $65
MACRO jumptrainerafterbattlescript
db jumptrainerafterbattlescript_command
ENDM
const endifjustbattled_command ; $66
@ -1076,4 +1076,9 @@ MACRO reloadmapafterviewmapmode
db reloadmapafterviewmapmode_command
ENDM
const jumptalkerscript_command ; $ac
MACRO jumptalkerscript
db jumptalkerscript_command
ENDM
DEF NUM_EVENT_COMMANDS EQU const_value

View File

@ -29,7 +29,7 @@ DebugLevel5_Map1_MapEvents:
trainer YOUNGSTER, MIKEY, EVENT_LEVEL_SCOPED_2, .YoungsterMikeySeenText, .YoungsterMikeyBeatenText, 0, .Script
.DebugLevel5_Map1Talker1:
talker EVENT_TURN_SCOPED_1, OPTIONAL, TEXT, .Text
talker EVENT_TURN_SCOPED_1, OPTIONAL, SCRIPT, .Script
.Text:
text "I'm a talker!"