Implement talker events [commit 2] (#30)

This commit is contained in:
xCrystal
2023-11-28 18:02:00 +01:00
parent 88b6810a18
commit 933fca3b4b
12 changed files with 111 additions and 44 deletions

View File

@@ -20,12 +20,22 @@ BoardMenuScript::
; save after opentext to reanchor map first
; save before processing variables like wCurTurn due to BoardMenuScript reentry after game reset
farcall AutoSaveGameInOverworld
; reset turn-scoped variables (wDieRoll, wSpacesLeft) and update wCurTurn
ld hl, wTurnData
ld bc, wTurnDataEnd - wTurnData
xor a
call ByteFill
ld hl, wCurTurn
inc [hl]
; reset turn-scoped event flags
ld hl, wEventFlags + EVENT_LEVEL_SCOPED_FLAGS_START / 8
ld c, (EVENT_LEVEL_SCOPED_FLAGS_END / 8) - (EVENT_LEVEL_SCOPED_FLAGS_START / 8)
xor a
.loop
ld [hli], a
dec c
jr nz, .loop
; load the data for the current space to wCurSpaceStruct
jp LoadCurSpaceData
.Die:

View File

@@ -1,6 +1,6 @@
TalkToTrainerScript::
faceplayer
trainerflagaction CHECK_FLAG
trainerortalkerflagaction CHECK_FLAG
iftrue AlreadyBeatenTrainerScript
loadtemptrainer
encountermusic
@@ -25,7 +25,7 @@ StartBattleWithMapTrainerScript:
loadtemptrainer
startbattle
reloadmapafterbattle
trainerflagaction SET_FLAG
trainerortalkerflagaction SET_FLAG
loadmem wRunningTrainerBattleScript, -1
AlreadyBeatenTrainerScript:
@@ -34,8 +34,30 @@ AlreadyBeatenTrainerScript:
SeenByTalkerScript::
waitsfx ; wait for any pending space-related sfx
showemote EMOTE_TALK, LAST_TALKED, 20
callasm .TalkOrSkipTalker
iffalse .skipped
callasm TrainerOrTalkerWalkToPlayer
applymovementlasttalked wMovementBuffer
writeobjectxy LAST_TALKED
faceobject PLAYER, LAST_TALKED
.skipped
end
.TalkOrSkipTalker:
ld a, [wTempTalkerType]
and %1
cp TALKEREVENTTYPE_MANDATORY
jr z, .skip
call WaitButton
call PlayClickSFX
call WaitSFX
ldh a, [hJoyPressed]
bit A_BUTTON_F, a
jr z, .skip ; jump if b was pressed
ld a, TRUE
jr .done
.skip
xor a ; FALSE
.done
ld [hScriptVar], a
ret

View File

@@ -459,7 +459,7 @@ CheckTrainerOrTalkerEvent:
call CheckTrainerBattleOrTalkerPrompt
jr nc, .nope
ld a, [wTrainerOrTalkerIsTalker]
ld a, [wSeenTrainerOrTalkerIsTalker]
and a ; cp FALSE
ld a, PLAYEREVENT_SEENBYTRAINER
jr z, .done

View File

@@ -163,7 +163,7 @@ ScriptCommandTable:
dw Script_reloadmapafterbattle ; 60
dw Script_catchtutorial ; 61
dw Script_trainertext ; 62
dw Script_trainerflagaction ; 63
dw Script_trainerortalkerflagaction ; 63
dw Script_winlosstext ; 64
dw Script_scripttalkafter ; 65
dw Script_endifjustbattled ; 66
@@ -685,10 +685,10 @@ Script_scripttalkafter:
ld b, a
jp ScriptJump
Script_trainerflagaction:
Script_trainerortalkerflagaction:
xor a
ldh [hScriptVar], a
ld hl, wTempTrainerEventFlag
ld hl, wTempTrainerEventFlag ; wTempTalkerEventFlag
ld e, [hl]
inc hl
ld d, [hl]