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> ## `$64`: <code>winlosstext <i>win_text_pointer</i>, <i>loss_text_pointer</i></code>
## `$65`: `scripttalkafter` ## `$65`: `jumptrainerafterbattlescript`
## `$66`: `endifjustbattled` ## `$66`: `endifjustbattled`

View File

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

View File

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

View File

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

View File

@ -645,9 +645,9 @@ MACRO winlosstext
dw \2 ; loss_text_pointer dw \2 ; loss_text_pointer
ENDM ENDM
const scripttalkafter_command ; $65 const jumptrainerafterbattlescript_command ; $65
MACRO scripttalkafter MACRO jumptrainerafterbattlescript
db scripttalkafter_command db jumptrainerafterbattlescript_command
ENDM ENDM
const endifjustbattled_command ; $66 const endifjustbattled_command ; $66
@ -1076,4 +1076,9 @@ MACRO reloadmapafterviewmapmode
db reloadmapafterviewmapmode_command db reloadmapafterviewmapmode_command
ENDM ENDM
const jumptalkerscript_command ; $ac
MACRO jumptalkerscript
db jumptalkerscript_command
ENDM
DEF NUM_EVENT_COMMANDS EQU const_value 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 trainer YOUNGSTER, MIKEY, EVENT_LEVEL_SCOPED_2, .YoungsterMikeySeenText, .YoungsterMikeyBeatenText, 0, .Script
.DebugLevel5_Map1Talker1: .DebugLevel5_Map1Talker1:
talker EVENT_TURN_SCOPED_1, OPTIONAL, TEXT, .Text talker EVENT_TURN_SCOPED_1, OPTIONAL, SCRIPT, .Script
.Text: .Text:
text "I'm a talker!" text "I'm a talker!"