mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Implement talker events [commit 1] (#30)
This commit is contained in:
parent
93dad5959f
commit
88b6810a18
@ -89,6 +89,7 @@ DEF RETVAR_EXECUTE EQU 2 << 6
|
||||
const PLAYEREVENT_WHITEOUT
|
||||
const PLAYEREVENT_HATCH
|
||||
const PLAYEREVENT_JOYCHANGEFACING
|
||||
const PLAYEREVENT_SEENBYTALKER
|
||||
DEF NUM_PLAYER_EVENTS EQU const_value
|
||||
|
||||
; PlayerMovementPointers indexes (see engine/overworld/events.asm)
|
||||
@ -137,7 +138,7 @@ DEF NUM_BGEVENTS EQU const_value
|
||||
const OBJECTTYPE_SCRIPT
|
||||
const OBJECTTYPE_ITEMBALL
|
||||
const OBJECTTYPE_TRAINER
|
||||
const OBJECTTYPE_3
|
||||
const OBJECTTYPE_TALKER
|
||||
const OBJECTTYPE_4
|
||||
const OBJECTTYPE_5
|
||||
const OBJECTTYPE_6
|
||||
@ -188,6 +189,7 @@ DEF NUM_FLOORS EQU const_value
|
||||
; Emotes indexes (see data/sprites/emotes.asm)
|
||||
const_def
|
||||
const EMOTE_SHOCK
|
||||
const EMOTE_TALK
|
||||
const EMOTE_QUESTION
|
||||
const EMOTE_HAPPY
|
||||
const EMOTE_SAD
|
||||
|
@ -45,3 +45,13 @@ DEF CONTEXT_USE EQU 1 << CONTEXT_USE_F
|
||||
const TRAINERTYPE_MOVES
|
||||
const TRAINERTYPE_ITEM
|
||||
const TRAINERTYPE_ITEM_MOVES
|
||||
|
||||
; talker events (from talker macro and high bit of wTempTalkerType)
|
||||
DEF TALKER_OPTIONAL EQU %0
|
||||
DEF TALKER_MANDATORY EQU %1
|
||||
|
||||
; talker types (from talker macro and low seven bits of wTempTalkerType)
|
||||
const_def
|
||||
const TALKERTYPE_TEXT
|
||||
const TALKERTYPE_MODAL_TEXT
|
||||
const TALKERTYPE_SCRIPT
|
||||
|
@ -9,6 +9,7 @@ Emotes:
|
||||
; entries correspond to EMOTE_* constants
|
||||
table_width EMOTE_LENGTH, Emotes
|
||||
emote ShockEmote, 4, $f8
|
||||
emote TalkEmote, 4, $f8
|
||||
emote QuestionEmote, 4, $f8
|
||||
emote HappyEmote, 4, $f8
|
||||
emote SadEmote, 4, $f8
|
||||
|
@ -11,7 +11,7 @@ SeenByTrainerScript::
|
||||
waitsfx ; wait for any pending space-related sfx
|
||||
encountermusic
|
||||
showemote EMOTE_SHOCK, LAST_TALKED, 30
|
||||
callasm TrainerWalkToPlayer
|
||||
callasm TrainerOrTalkerWalkToPlayer
|
||||
applymovementlasttalked wMovementBuffer
|
||||
writeobjectxy LAST_TALKED
|
||||
faceobject PLAYER, LAST_TALKED
|
||||
@ -30,3 +30,12 @@ StartBattleWithMapTrainerScript:
|
||||
|
||||
AlreadyBeatenTrainerScript:
|
||||
scripttalkafter
|
||||
|
||||
SeenByTalkerScript::
|
||||
waitsfx ; wait for any pending space-related sfx
|
||||
showemote EMOTE_TALK, LAST_TALKED, 20
|
||||
callasm TrainerOrTalkerWalkToPlayer
|
||||
applymovementlasttalked wMovementBuffer
|
||||
writeobjectxy LAST_TALKED
|
||||
faceobject PLAYER, LAST_TALKED
|
||||
end
|
||||
|
@ -285,7 +285,7 @@ PlayerEvents:
|
||||
call DisableSpaceEffects ; doesn't alter f
|
||||
jr c, .ok
|
||||
|
||||
call CheckTrainerEvent
|
||||
call CheckTrainerOrTalkerEvent
|
||||
jr c, .ok
|
||||
|
||||
call CheckTileEvent
|
||||
@ -451,15 +451,20 @@ CheckBoardEvent:
|
||||
dw UnionSpaceScript ; COLL_UNION_SPACE
|
||||
assert_table_length NUM_COLL_SPACES
|
||||
|
||||
CheckTrainerEvent:
|
||||
CheckTrainerOrTalkerEvent:
|
||||
ldh a, [hCurBoardEvent]
|
||||
cp BOARDEVENT_VIEW_MAP_MODE
|
||||
ret z
|
||||
|
||||
call CheckTrainerBattle
|
||||
call CheckTrainerBattleOrTalkerPrompt
|
||||
jr nc, .nope
|
||||
|
||||
ld a, [wTrainerOrTalkerIsTalker]
|
||||
and a ; cp FALSE
|
||||
ld a, PLAYEREVENT_SEENBYTRAINER
|
||||
jr z, .done
|
||||
ld a, PLAYEREVENT_SEENBYTALKER
|
||||
.done
|
||||
scf
|
||||
ret
|
||||
|
||||
@ -748,7 +753,7 @@ ObjectEventTypeArray:
|
||||
dbw OBJECTTYPE_ITEMBALL, .itemball
|
||||
dbw OBJECTTYPE_TRAINER, .trainer
|
||||
; the remaining four are dummy events
|
||||
dbw OBJECTTYPE_3, .three
|
||||
dbw OBJECTTYPE_TALKER, .three
|
||||
dbw OBJECTTYPE_4, .four
|
||||
dbw OBJECTTYPE_5, .five
|
||||
dbw OBJECTTYPE_6, .six
|
||||
@ -1158,6 +1163,7 @@ PlayerEventScriptPointers:
|
||||
dba OverworldWhiteoutScript ; PLAYEREVENT_WHITEOUT
|
||||
dba HatchEggScript ; PLAYEREVENT_HATCH
|
||||
dba ChangeDirectionScript ; PLAYEREVENT_JOYCHANGEFACING
|
||||
dba SeenByTalkerScript ; PLAYEREVENT_SEENBYTALKER
|
||||
dba InvalidEventScript ; (NUM_PLAYER_EVENTS)
|
||||
assert_table_length NUM_PLAYER_EVENTS + 1
|
||||
|
||||
|
@ -514,12 +514,12 @@ CopyTempObjectToObjectStruct:
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
TrainerWalkToPlayer:
|
||||
TrainerOrTalkerWalkToPlayer:
|
||||
ldh a, [hLastTalked]
|
||||
call InitMovementBuffer
|
||||
ld a, movement_step_sleep
|
||||
call AppendToMovementBuffer
|
||||
ld a, [wSeenTrainerDistance]
|
||||
ld a, [wSeenTrainerOrTalkerDistance]
|
||||
dec a
|
||||
jr z, .TerminateStep
|
||||
ldh a, [hLastTalked]
|
||||
|
@ -671,7 +671,7 @@ Script_trainertext:
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld a, [wSeenTrainerBank]
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
ld b, a
|
||||
call MapTextbox
|
||||
ret
|
||||
@ -681,7 +681,7 @@ Script_scripttalkafter:
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld a, [wSeenTrainerBank]
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
ld b, a
|
||||
jp ScriptJump
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
ShockEmote: INCBIN "gfx/emotes/shock.2bpp"
|
||||
TalkEmote: INCBIN "gfx/emotes/talk.2bpp"
|
||||
QuestionEmote: INCBIN "gfx/emotes/question.2bpp"
|
||||
HappyEmote: INCBIN "gfx/emotes/happy.2bpp"
|
||||
SadEmote: INCBIN "gfx/emotes/sad.2bpp"
|
||||
|
BIN
gfx/emotes/talk.png
Executable file
BIN
gfx/emotes/talk.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 250 B |
@ -1,17 +1,17 @@
|
||||
CheckTrainerBattle::
|
||||
CheckTrainerBattleOrTalkerPrompt::
|
||||
ldh a, [hROMBank]
|
||||
push af
|
||||
|
||||
call SwitchToMapScriptsBank
|
||||
call _CheckTrainerBattle
|
||||
call _CheckTrainerBattleOrTalkerPrompt
|
||||
|
||||
pop bc
|
||||
ld a, b
|
||||
rst Bankswitch
|
||||
ret
|
||||
|
||||
_CheckTrainerBattle::
|
||||
; Check if any trainer on the map sees the player and wants to battle.
|
||||
_CheckTrainerBattleOrTalkerPrompt::
|
||||
; Check if any trainer or talker on the map sees the player and wants to battle or talk.
|
||||
|
||||
; Skip the player object.
|
||||
ld a, 1
|
||||
@ -30,14 +30,25 @@ _CheckTrainerBattle::
|
||||
and a
|
||||
jr z, .next
|
||||
|
||||
; Is a trainer
|
||||
; Is a trainer or a talker
|
||||
ld hl, MAPOBJECT_TYPE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
and MAPOBJECT_TYPE_MASK
|
||||
cp OBJECTTYPE_TRAINER
|
||||
jr z, .is_trainer
|
||||
cp OBJECTTYPE_TALKER
|
||||
jr nz, .next
|
||||
; also set wTrainerOrTalkerIsTalker accordingly (flag is only relevant if there's actually an event)
|
||||
;.is_talker
|
||||
ld a, TRUE
|
||||
ld [wTrainerOrTalkerIsTalker], a
|
||||
jr .go
|
||||
.is_trainer
|
||||
xor a ; FALSE
|
||||
ld [wTrainerOrTalkerIsTalker], a
|
||||
|
||||
.go
|
||||
; Is visible on the map
|
||||
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
|
||||
add hl, de
|
||||
@ -57,7 +68,38 @@ _CheckTrainerBattle::
|
||||
cp b
|
||||
jr c, .next
|
||||
|
||||
; And hasn't already been beaten
|
||||
ld a, [wTrainerOrTalkerIsTalker]
|
||||
and a ; TRUE?
|
||||
jr z, .trainer_battle
|
||||
|
||||
;.talker_prompt
|
||||
pop de
|
||||
pop af
|
||||
ldh [hLastTalked], a
|
||||
ld a, b
|
||||
ld [wSeenTrainerOrTalkerDistance], a
|
||||
ld a, c
|
||||
ld [wSeenTrainerOrTalkerDirection], a
|
||||
call GetMapScriptsBank
|
||||
ld [wSeenTrainerOrTalkerBank], a
|
||||
|
||||
ldh a, [hLastTalked]
|
||||
call GetMapObject
|
||||
|
||||
ld hl, MAPOBJECT_SCRIPT_POINTER
|
||||
add hl, bc
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
call GetFarWord
|
||||
ld de, wTempTalker
|
||||
ld bc, wTempTalkerEnd - wTempTalker
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
call FarCopyBytes
|
||||
|
||||
scf
|
||||
ret
|
||||
|
||||
.trainer_battle
|
||||
; And hasn't already been beaten if it's a trainer
|
||||
push bc
|
||||
push de
|
||||
ld hl, MAPOBJECT_SCRIPT_POINTER
|
||||
@ -86,7 +128,7 @@ _CheckTrainerBattle::
|
||||
pop af
|
||||
inc a
|
||||
cp NUM_OBJECTS
|
||||
jr nz, .loop
|
||||
jp nz, .loop
|
||||
xor a
|
||||
ret
|
||||
|
||||
@ -95,31 +137,31 @@ _CheckTrainerBattle::
|
||||
pop af
|
||||
ldh [hLastTalked], a
|
||||
ld a, b
|
||||
ld [wSeenTrainerDistance], a
|
||||
ld [wSeenTrainerOrTalkerDistance], a
|
||||
ld a, c
|
||||
ld [wSeenTrainerDirection], a
|
||||
ld [wSeenTrainerOrTalkerDirection], a
|
||||
jr LoadTrainer_continue
|
||||
|
||||
TalkToTrainer::
|
||||
ld a, 1
|
||||
ld [wSeenTrainerDistance], a
|
||||
ld [wSeenTrainerOrTalkerDistance], a
|
||||
ld a, -1
|
||||
ld [wSeenTrainerDirection], a
|
||||
ld [wSeenTrainerOrTalkerDirection], a
|
||||
|
||||
LoadTrainer_continue::
|
||||
call GetMapScriptsBank
|
||||
ld [wSeenTrainerBank], a
|
||||
ld [wSeenTrainerOrTalkerBank], a
|
||||
|
||||
ldh a, [hLastTalked]
|
||||
call GetMapObject
|
||||
|
||||
ld hl, MAPOBJECT_SCRIPT_POINTER
|
||||
add hl, bc
|
||||
ld a, [wSeenTrainerBank]
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
call GetFarWord
|
||||
ld de, wTempTrainer
|
||||
ld bc, wTempTrainerEnd - wTempTrainer
|
||||
ld a, [wSeenTrainerBank]
|
||||
ld a, [wSeenTrainerOrTalkerBank]
|
||||
call FarCopyBytes
|
||||
xor a
|
||||
ld [wRunningTrainerBattleScript], a
|
||||
|
@ -232,7 +232,7 @@ ENDM
|
||||
MACRO trainer
|
||||
;\1: trainer group
|
||||
;\2: trainer id
|
||||
;\3: flag: an EVENT_BEAT_* constant
|
||||
;\3: flag: an EVENT_* constant
|
||||
;\4: seen text
|
||||
;\5: win text
|
||||
;\6: loss text
|
||||
@ -242,6 +242,16 @@ MACRO trainer
|
||||
dw \4, \5, \6, \7
|
||||
ENDM
|
||||
|
||||
MACRO talker
|
||||
;\1: flag: an EVENT_* constant
|
||||
;\2: OPTIONAL or MANDATORY
|
||||
;\3: talker type: TEXT, MODAL_TEXT, SCRIPT
|
||||
;\4: pointer to talker data
|
||||
dw \1
|
||||
db \2 | \3
|
||||
dw \4
|
||||
ENDM
|
||||
|
||||
MACRO itemball
|
||||
;\1: item: from constants/item_constants.asm
|
||||
;\2: quantity: default 1
|
||||
|
@ -28,6 +28,16 @@ DebugLevel5_Map1_MapEvents:
|
||||
.DebugLevel5_Map1TrainerYoungsterMikey2:
|
||||
trainer YOUNGSTER, MIKEY, EVENT_LEVEL_SCOPED_2, .YoungsterMikeySeenText, .YoungsterMikeyBeatenText, 0, .Script
|
||||
|
||||
; talker EVENT_STEP_SCOPED_*, OPTIONAL/MANDATORY | TEXT/MODAL_TEXT/SCRIPT, .Data
|
||||
; .Data: ; Text
|
||||
; db .Text
|
||||
; .Data: ; Modal text
|
||||
; dw EVENT_*, .Text1
|
||||
; dw EVENT_*, .Text2
|
||||
; dw DEFAULT_TEXT, .DefaultText
|
||||
; .Data: ; Script
|
||||
; end
|
||||
|
||||
.Script:
|
||||
endifjustbattled
|
||||
opentext
|
||||
|
22
ram/wram.asm
22
ram/wram.asm
@ -1550,10 +1550,15 @@ SECTION UNION "Miscellaneous WRAM 1", WRAMX
|
||||
ds 60
|
||||
|
||||
UNION
|
||||
; trainer and talker data
|
||||
wTrainerOrTalkerIsTalker:: db ; TRUE means talker; FALSE means trainer
|
||||
wSeenTrainerOrTalkerBank:: db
|
||||
wSeenTrainerOrTalkerDistance:: db
|
||||
wSeenTrainerOrTalkerDirection:: db
|
||||
|
||||
NEXTU
|
||||
; trainer data
|
||||
wSeenTrainerBank:: db
|
||||
wSeenTrainerDistance:: db
|
||||
wSeenTrainerDirection:: db
|
||||
ds 4
|
||||
wTempTrainer::
|
||||
wTempTrainerEventFlag:: dw
|
||||
wTempTrainerClass:: db
|
||||
@ -1565,6 +1570,15 @@ wScriptAfterPointer:: dw
|
||||
wRunningTrainerBattleScript:: db
|
||||
wTempTrainerEnd::
|
||||
|
||||
NEXTU
|
||||
; talker data
|
||||
ds 4
|
||||
wTempTalker::
|
||||
wTempTalkerEventFlag:: dw
|
||||
wTempTalkerType:: db
|
||||
wTempTalkerDataPointer:: dw
|
||||
wTempTalkerEnd::
|
||||
|
||||
NEXTU
|
||||
; menu items list
|
||||
wMenuItemsList:: ds 16
|
||||
@ -1642,7 +1656,7 @@ wFacingDirection:: db
|
||||
wWalkingX:: db
|
||||
wWalkingY:: db
|
||||
wWalkingTile:: db
|
||||
ds 6
|
||||
ds 7
|
||||
wPlayerTurningDirection:: db
|
||||
|
||||
NEXTU
|
||||
|
Loading…
Reference in New Issue
Block a user