Skip to Content
The Alchemy Project

src/field/field_engine_cues.c

Finding and running a scene's cues: talking, step cues, examine cues. More…

Included by field_engine.c.

Macros

NameDescription
#defineEXAMINE_TARGET (kind) (((kind) >> 4) & 0x1f)EXAMINE_CUE() packs it into.
#defineFIND_ITEM_MASK 0xfffThe item a FIND_ITEM search result holds.
#definePSYNERGY_STONE_PP 999The PP a Psynergy Stone gives each party member, enough to fill it: "The party's PP is fully restored!"

Functions

NameDescription
ACTOR_PLACE *fdFindActorPlacement (Sint32 id)Returns the actor placement of actor id in the scene's actor placement tables, or NULL: for a party character (0 to 7) the row with its sprite, and for a placed actor (8 on) the row it was created from, counting the placed rows in order.
Sint32fdGameFlagIsConditionActive (Sint32 condition)Returns whether a script condition holds: -1 always holds; a condition with CONDITION_FLAG_SET holds while that flag is set, any other while its flag is clear.
Uint32fdExamineCueIgnoresCondition (Sint32 flags, Sint32 result)Returns 1 for an examine cue (CUE_EXAMINE) that holds whatever its condition: one with more flags than its kind, unless its result is a mimic battle (FIND_MIMIC).
const CUE *fdFindCue (Sint32 kind, Sint32 target)Returns the first of the scene's cues of kind for target whose condition holds, or NULL.
voidfdOverlayCallInit (void)Unused: runs the loaded overlay's initialize entry.
const CUE *fdFindActorTalkCue (Sint32 id)Returns the talk cue of actor id, or 0: for the actor stopped with Halt (MainRoutineStateWork.haltedActor), its CUE_TALK_HALTED script if it has one, the script for talking to it while it is stopped (Crossbone Isle's Bane has one).
Sint32fdTalkToActor (Sint32 id)Talks to actor id: shows its script's message or calls its script function, with the actor stopped and turned as its placement says.
Sint32fdRunRaisedCue (Sint32 value)Runs the scene's raised cue (CUE_RAISED) for value: its message or its function.
Sint32fdRunStepCueOrExit (Sint32 value)Runs the step cue (CUE_STEP) of what the leader touched, or else takes its exit (CUE_EXIT): plays the exit's sound (and effect) and records where it leads.
Sint32fdRunPushMetatile (Sint32 behavior)Runs the script of a metatile the leader pushes against (METATILE_BEHAVIOR_LEDGE to METATILE_BEHAVIOR_JUMP_FORWARD, and METATILE_BEHAVIOR_JUMP_FORWARD_UNREACHED), once it has pushed for more than FIELD_PUSH_TICKS ticks; the count then restarts.
Sint32fdExamineMetatile (Sint32 tile)Searches the metatile ahead with the given metatile behavior.

Description

Finding and running a scene's cues: talking, step cues, examine cues. Part of field_engine.c.

Macros in detail

EXAMINE_TARGET

#define EXAMINE_TARGET(kind) (((kind) >> 4) & 0x1f)

EXAMINE_CUE() packs it into.

Referenced by fdExamineMetatile().

Definition at line 9 of file field_engine_cues.c.

FIND_ITEM_MASK

#define FIND_ITEM_MASK 0xfff

The item a FIND_ITEM search result holds.

Referenced by fdExamineMetatile().

Definition at line 11 of file field_engine_cues.c.

PSYNERGY_STONE_PP

#define PSYNERGY_STONE_PP 999

The PP a Psynergy Stone gives each party member, enough to fill it: "The party's PP is fully restored!"

Referenced by fdExamineMetatile().

Definition at line 14 of file field_engine_cues.c.

Functions in detail

fdFindActorPlacement

ACTOR_PLACE *fdFindActorPlacement(Sint32 id)

Returns the actor placement of actor id in the scene's actor placement tables, or NULL: for a party character (0 to 7) the row with its sprite, and for a placed actor (8 on) the row it was created from, counting the placed rows in order.

References Sint32.

Referenced by fdDjinnResolvePending(), fdDjinnRestoreActorAfterBattle(), fdEffectCopyWatchedActorPos(), fdPsynergyUpdateMindReadWave(), fdScriptAskYesNoWithActorAnimation(), fdScriptShowMessageAndWait() and fdTalkToActor().

Definition at line 20 of file field_engine_cues.c.

fdGameFlagIsConditionActive

Sint32 fdGameFlagIsConditionActive(Sint32 condition)

Returns whether a script condition holds: -1 always holds; a condition with CONDITION_FLAG_SET holds while that flag is set, any other while its flag is clear.

References gmFlagGetStub() and Sint32.

Referenced by fdCheckExitRegions(), fdExamineMetatile(), fdFindCue(), fdFindItemCue(), fdFindPsynergyCue() and fdScriptSpawnActorPlacements().

Definition at line 81 of file field_engine_cues.c.

fdExamineCueIgnoresCondition

Uint32 fdExamineCueIgnoresCondition(Sint32 flags, Sint32 result)

Returns 1 for an examine cue (CUE_EXAMINE) that holds whatever its condition: one with more flags than its kind, unless its result is a mimic battle (FIND_MIMIC).

References Sint32.

Referenced by fdFindCue().

Definition at line 100 of file field_engine_cues.c.

fdFindCue

const CUE *fdFindCue(Sint32 kind, Sint32 target)

Returns the first of the scene's cues of kind for target whose condition holds, or NULL.

References fdActorLookup(), fdExamineCueIgnoresCondition(), fdGameFlagIsConditionActive(), MainRoutineStateWork, Sint32 and state.

Referenced by fdActorGetCueMetatileAheadOfCurrent(), fdExamineMetatile(), fdFindActorTalkCue(), fdRunRaisedCue(), fdRunStepCueOrExit() and fdTalkToActor().

Definition at line 113 of file field_engine_cues.c.

fdOverlayCallInit

void fdOverlayCallInit(void)

Unused: runs the loaded overlay's initialize entry.

References OverlayArea.

Definition at line 180 of file field_engine_cues.c.

fdFindActorTalkCue

const CUE *fdFindActorTalkCue(Sint32 id)

Returns the talk cue of actor id, or 0: for the actor stopped with Halt (MainRoutineStateWork.haltedActor), its CUE_TALK_HALTED script if it has one, the script for talking to it while it is stopped (Crossbone Isle's Bane has one).

References fdFindCue(), MainRoutineStateWork and Sint32.

Referenced by fdEngineRun() and fdPsynergyRun().

Definition at line 189 of file field_engine_cues.c.

fdTalkToActor

Sint32 fdTalkToActor(Sint32 id)

Talks to actor id: shows its script's message or calls its script function, with the actor stopped and turned as its placement says. The actor Halt has stopped answers its CUE_TALK_HALTED script if it has one; else it says its talk message in halting speech, or, in place of a talk function, one of its sprite's two Halted lines.

References ActorFaceWatchedScript, ActorStepAngleScript, fdActorGetById(), fdActorSetAnimationSpeedStub(), fdActorSetMovementType(), fdActorStartScriptStub(), fdActorTurnToFaceEachOther(), fdFindActorPlacement(), fdFindCue(), fdLeaderStopMoving(), fdPsynergyResumeHaltedActor(), fdScriptEnd(), fdScriptSetMessageId(), fdScriptShowMessageAndWait(), fdScriptStart(), fdSpeakerGetHaltedLines(), MainRoutineStateWork, mnMessageSetDecodeFlagsStub(), Sint32 and syRandom().

Referenced by fdEngineRun().

Definition at line 211 of file field_engine_cues.c.

fdRunRaisedCue

Sint32 fdRunRaisedCue(Sint32 value)

Runs the scene's raised cue (CUE_RAISED) for value: its message or its function. Returns 0 when a script ran, -1 when there was none.

References fdFindCue(), fdScriptEnd(), fdScriptSetMessageId(), fdScriptShowMessageAndWait(), fdScriptStart() and Sint32.

Referenced by fdEngineRun().

Definition at line 332 of file field_engine_cues.c.

fdRunStepCueOrExit

Sint32 fdRunStepCueOrExit(Sint32 value)

Runs the step cue (CUE_STEP) of what the leader touched, or else takes its exit (CUE_EXIT): plays the exit's sound (and effect) and records where it leads.

References fdExitStartStairsDown(), fdExitStartStairsUp(), fdFindCue(), fdScriptEnd(), fdScriptSetMessageId(), fdScriptShowMessageAndWait(), fdScriptStart(), Sint32, state and sySoundPlayStub().

Referenced by fdEngineRun().

Definition at line 366 of file field_engine_cues.c.

fdRunPushMetatile

Sint32 fdRunPushMetatile(Sint32 behavior)

Runs the script of a metatile the leader pushes against (METATILE_BEHAVIOR_LEDGE to METATILE_BEHAVIOR_JUMP_FORWARD, and METATILE_BEHAVIOR_JUMP_FORWARD_UNREACHED), once it has pushed for more than FIELD_PUSH_TICKS ticks; the count then restarts.

References fdActorJumpDownLedge(), fdClimbDown(), fdClimbUp(), fdTryJumpForward(), MainRoutineStateWork, PerData, Sint32 and state.

Referenced by fdEngineRun().

Definition at line 428 of file field_engine_cues.c.

fdExamineMetatile

Sint32 fdExamineMetatile(Sint32 tile)

Searches the metatile ahead with the given metatile behavior. The fixed search spots, METATILE_BEHAVIOR_JAR to METATILE_BEHAVIOR_WELL, show their two messages.

References fdActorReleaseIfPresent(), fdActorReleaseStub(), fdActorSelectAnimationStub(), fdEncounterGetFormationAtSlot(), fdEncounterSelectBattleMusic(), fdFindCue(), fdGameFlagIsConditionActive(), fdItemDisplayRaiseAboveLeader(), fdItemDisplayShowItemInFront(), fdLeaderStopMoving(), fdPartyAddPp(), fdPlayQueuedMusic(), fdScriptEnd(), fdScriptStart(), fdScriptWait(), fdTreasureSpotCloseChest(), fdTreasureSpotGetActor(), fdTreasureSpotHide(), fdTreasureSpotLaunchMimic(), fdTreasureSpotOpenChest(), fdTreasureSpotShowOpened(), FieldExamineCueMessageOffsets, gmFlagClearStub(), gmFlagGetStub(), gmFlagSetStub(), gmPartyAdjustCoinsStub(), gmPartyInventoryAddStub(), MainRoutineStateWork, mnFieldMessageShowStub(), mnMessageArgumentPushStub(), mnPartyStatusCloseStub(), mnPartyStatusCreateWindowStub(), Sint32, state, sySoundPlayStub() and sySynch().

Referenced by fdEngineRun().

Definition at line 471 of file field_engine_cues.c.