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

@ -64,178 +64,179 @@ RunScriptCommand:
ScriptCommandTable: ScriptCommandTable:
; entries correspond to *_command constants (see macros/scripts/events.asm) ; entries correspond to *_command constants (see macros/scripts/events.asm)
table_width 2, ScriptCommandTable table_width 2, ScriptCommandTable
dw Script_scall ; 00 dw Script_scall ; 00
dw Script_farscall ; 01 dw Script_farscall ; 01
dw Script_memcall ; 02 dw Script_memcall ; 02
dw Script_sjump ; 03 dw Script_sjump ; 03
dw Script_farsjump ; 04 dw Script_farsjump ; 04
dw Script_memjump ; 05 dw Script_memjump ; 05
dw Script_ifequal ; 06 dw Script_ifequal ; 06
dw Script_ifnotequal ; 07 dw Script_ifnotequal ; 07
dw Script_iffalse ; 08 dw Script_iffalse ; 08
dw Script_iftrue ; 09 dw Script_iftrue ; 09
dw Script_ifgreater ; 0a dw Script_ifgreater ; 0a
dw Script_ifless ; 0b dw Script_ifless ; 0b
dw Script_jumpstd ; 0c dw Script_jumpstd ; 0c
dw Script_callstd ; 0d dw Script_callstd ; 0d
dw Script_callasm ; 0e dw Script_callasm ; 0e
dw Script_special ; 0f dw Script_special ; 0f
dw Script_memcallasm ; 10 dw Script_memcallasm ; 10
dw Script_checkmapscene ; 11 dw Script_checkmapscene ; 11
dw Script_setmapscene ; 12 dw Script_setmapscene ; 12
dw Script_checkscene ; 13 dw Script_checkscene ; 13
dw Script_setscene ; 14 dw Script_setscene ; 14
dw Script_setval ; 15 dw Script_setval ; 15
dw Script_addval ; 16 dw Script_addval ; 16
dw Script_random ; 17 dw Script_random ; 17
dw Script_checkver ; 18 dw Script_checkver ; 18
dw Script_readmem ; 19 dw Script_readmem ; 19
dw Script_writemem ; 1a dw Script_writemem ; 1a
dw Script_loadmem ; 1b dw Script_loadmem ; 1b
dw Script_readvar ; 1c dw Script_readvar ; 1c
dw Script_writevar ; 1d dw Script_writevar ; 1d
dw Script_loadvar ; 1e dw Script_loadvar ; 1e
dw Script_giveitem ; 1f dw Script_giveitem ; 1f
dw Script_takeitem ; 20 dw Script_takeitem ; 20
dw Script_checkitem ; 21 dw Script_checkitem ; 21
dw Script_givecoins ; 22 dw Script_givecoins ; 22
dw Script_takecoins ; 23 dw Script_takecoins ; 23
dw Script_checkcoins ; 24 dw Script_checkcoins ; 24
dw Script_givechips ; 25 dw Script_givechips ; 25
dw Script_takechips ; 26 dw Script_takechips ; 26
dw Script_checkchips ; 27 dw Script_checkchips ; 27
dw Script_addcellnum ; 28 dw Script_addcellnum ; 28
dw Script_delcellnum ; 29 dw Script_delcellnum ; 29
dw Script_checkcellnum ; 2a dw Script_checkcellnum ; 2a
dw Script_checktime ; 2b dw Script_checktime ; 2b
dw Script_checkpoke ; 2c dw Script_checkpoke ; 2c
dw Script_givepoke ; 2d dw Script_givepoke ; 2d
dw Script_giveegg ; 2e dw Script_giveegg ; 2e
dw Script_givepokemail ; 2f dw Script_givepokemail ; 2f
dw Script_checkpokemail ; 30 dw Script_checkpokemail ; 30
dw Script_checkevent ; 31 dw Script_checkevent ; 31
dw Script_clearevent ; 32 dw Script_clearevent ; 32
dw Script_setevent ; 33 dw Script_setevent ; 33
dw Script_checkflag ; 34 dw Script_checkflag ; 34
dw Script_clearflag ; 35 dw Script_clearflag ; 35
dw Script_setflag ; 36 dw Script_setflag ; 36
dw Script_wildon ; 37 dw Script_wildon ; 37
dw Script_wildoff ; 38 dw Script_wildoff ; 38
dw Script_xycompare ; 39 dw Script_xycompare ; 39
dw Script_warpmod ; 3a dw Script_warpmod ; 3a
dw Script_blackoutmod ; 3b dw Script_blackoutmod ; 3b
dw Script_warp ; 3c dw Script_warp ; 3c
dw Script_getcoins ; 3d dw Script_getcoins ; 3d
dw Script_getchips ; 3e dw Script_getchips ; 3e
dw Script_getnum ; 3f dw Script_getnum ; 3f
dw Script_getmonname ; 40 dw Script_getmonname ; 40
dw Script_getitemname ; 41 dw Script_getitemname ; 41
dw Script_getcurlandmarkname ; 42 dw Script_getcurlandmarkname ; 42
dw Script_gettrainername ; 43 dw Script_gettrainername ; 43
dw Script_getstring ; 44 dw Script_getstring ; 44
dw Script_itemnotify ; 45 dw Script_itemnotify ; 45
dw Script_pocketisfull ; 46 dw Script_pocketisfull ; 46
dw Script_opentext ; 47 dw Script_opentext ; 47
dw Script_refreshscreen ; 48 dw Script_refreshscreen ; 48
dw Script_closetext ; 49 dw Script_closetext ; 49
dw Script_writeunusedbyte ; 4a dw Script_writeunusedbyte ; 4a
dw Script_farwritetext ; 4b dw Script_farwritetext ; 4b
dw Script_writetext ; 4c dw Script_writetext ; 4c
dw Script_repeattext ; 4d dw Script_repeattext ; 4d
dw Script_yesorno ; 4e dw Script_yesorno ; 4e
dw Script_loadmenu ; 4f dw Script_loadmenu ; 4f
dw Script_closewindow ; 50 dw Script_closewindow ; 50
dw Script_jumptextfaceplayer ; 51 dw Script_jumptextfaceplayer ; 51
dw Script_farjumptext ; 52 dw Script_farjumptext ; 52
dw Script_jumptext ; 53 dw Script_jumptext ; 53
dw Script_waitbutton ; 54 dw Script_waitbutton ; 54
dw Script_promptbutton ; 55 dw Script_promptbutton ; 55
dw Script_pokepic ; 56 dw Script_pokepic ; 56
dw Script_closepokepic ; 57 dw Script_closepokepic ; 57
dw Script__2dmenu ; 58 dw Script__2dmenu ; 58
dw Script_verticalmenu ; 59 dw Script_verticalmenu ; 59
dw Script_loadpikachudata ; 5a dw Script_loadpikachudata ; 5a
dw Script_randomwildmon ; 5b dw Script_randomwildmon ; 5b
dw Script_loadtemptrainer ; 5c dw Script_loadtemptrainer ; 5c
dw Script_loadwildmon ; 5d dw Script_loadwildmon ; 5d
dw Script_loadtrainer ; 5e dw Script_loadtrainer ; 5e
dw Script_startbattle ; 5f dw Script_startbattle ; 5f
dw Script_reloadmapafterbattle ; 60 dw Script_reloadmapafterbattle ; 60
dw Script_catchtutorial ; 61 dw Script_catchtutorial ; 61
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
dw Script_applymovement ; 69 dw Script_applymovement ; 69
dw Script_applymovementlasttalked ; 6a dw Script_applymovementlasttalked ; 6a
dw Script_faceplayer ; 6b dw Script_faceplayer ; 6b
dw Script_faceobject ; 6c dw Script_faceobject ; 6c
dw Script_variablesprite ; 6d dw Script_variablesprite ; 6d
dw Script_disappear ; 6e dw Script_disappear ; 6e
dw Script_appear ; 6f dw Script_appear ; 6f
dw Script_follow ; 70 dw Script_follow ; 70
dw Script_stopfollow ; 71 dw Script_stopfollow ; 71
dw Script_moveobject ; 72 dw Script_moveobject ; 72
dw Script_writeobjectxy ; 73 dw Script_writeobjectxy ; 73
dw Script_loademote ; 74 dw Script_loademote ; 74
dw Script_showemote ; 75 dw Script_showemote ; 75
dw Script_turnobject ; 76 dw Script_turnobject ; 76
dw Script_follownotexact ; 77 dw Script_follownotexact ; 77
dw Script_earthquake ; 78 dw Script_earthquake ; 78
dw Script_changemapblocks ; 79 dw Script_changemapblocks ; 79
dw Script_changeblock ; 7a dw Script_changeblock ; 7a
dw Script_reloadmap ; 7b dw Script_reloadmap ; 7b
dw Script_reloadmappart ; 7c dw Script_reloadmappart ; 7c
dw Script_writecmdqueue ; 7d dw Script_writecmdqueue ; 7d
dw Script_delcmdqueue ; 7e dw Script_delcmdqueue ; 7e
dw Script_playmusic ; 7f dw Script_playmusic ; 7f
dw Script_encountermusic ; 80 dw Script_encountermusic ; 80
dw Script_musicfadeout ; 81 dw Script_musicfadeout ; 81
dw Script_playmapmusic ; 82 dw Script_playmapmusic ; 82
dw Script_dontrestartmapmusic ; 83 dw Script_dontrestartmapmusic ; 83
dw Script_cry ; 84 dw Script_cry ; 84
dw Script_playsound ; 85 dw Script_playsound ; 85
dw Script_waitsfx ; 86 dw Script_waitsfx ; 86
dw Script_warpsound ; 87 dw Script_warpsound ; 87
dw Script_specialsound ; 88 dw Script_specialsound ; 88
dw Script_autoinput ; 89 dw Script_autoinput ; 89
dw Script_newloadmap ; 8a dw Script_newloadmap ; 8a
dw Script_pause ; 8b dw Script_pause ; 8b
dw Script_deactivatefacing ; 8c dw Script_deactivatefacing ; 8c
dw Script_sdefer ; 8d dw Script_sdefer ; 8d
dw Script_warpcheck ; 8e dw Script_warpcheck ; 8e
dw Script_stopandsjump ; 8f dw Script_stopandsjump ; 8f
dw Script_endcallback ; 90 dw Script_endcallback ; 90
dw Script_end ; 91 dw Script_end ; 91
dw Script_reloadend ; 92 dw Script_reloadend ; 92
dw Script_endall ; 93 dw Script_endall ; 93
dw Script_pokemart ; 94 dw Script_pokemart ; 94
dw Script_elevator ; 95 dw Script_elevator ; 95
dw Script_trade ; 96 dw Script_trade ; 96
dw Script_askforphonenumber ; 97 dw Script_askforphonenumber ; 97
dw Script_phonecall ; 98 dw Script_phonecall ; 98
dw Script_hangup ; 99 dw Script_hangup ; 99
dw Script_describedecoration ; 9a dw Script_describedecoration ; 9a
dw Script_fruittree ; 9b dw Script_fruittree ; 9b
dw Script_specialphonecall ; 9c dw Script_specialphonecall ; 9c
dw Script_checkphonecall ; 9d dw Script_checkphonecall ; 9d
dw Script_verbosegiveitem ; 9e dw Script_verbosegiveitem ; 9e
dw Script_verbosegiveitemvar ; 9f dw Script_verbosegiveitemvar ; 9f
dw Script_swarm ; a0 dw Script_swarm ; a0
dw Script_halloffame ; a1 dw Script_halloffame ; a1
dw Script_credits ; a2 dw Script_credits ; a2
dw Script_warpfacing ; a3 dw Script_warpfacing ; a3
dw Script_battletowertext ; a4 dw Script_battletowertext ; a4
dw Script_getlandmarkname ; a5 dw Script_getlandmarkname ; a5
dw Script_gettrainerclassname ; a6 dw Script_gettrainerclassname ; a6
dw Script_getname ; a7 dw Script_getname ; a7
dw Script_wait ; a8 dw Script_wait ; a8
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!"