Alchemy

events.c

Finding and running a scene's events: talking, touching, searching.

games/tbs/src/object/object/events.c on GitHub

Finding and running a scene's events: talking, touching, searching. Part of object.c, the field object, compiled only through it.

Functions

Scene_FindActorPlacement

struct ScenePlacement *Scene_FindActorPlacement(s32 id)

Returns the placement of actor id in the scene's 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.

Called by Scene_TalkToActor for the talk facing, and by the field Psynergy effects that read an actor's placement (Mind Read, the Djinni effect, the event messages and the view).

Used by Djinn_ResolvePendingEvent, Event_AskYesNoWithActorAnimation, FieldEvent_ShowMessageAndWait, FieldFx_UpdateMindReadWave, FieldObject_PlaceSceneActors, Scene_TalkToActor.

Line 14

GameFlag_IsConditionActive

s32 GameFlag_IsConditionActive(s32 condition)

Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while that flag is set, any other while its flag is clear.

Used for every condition column of a scene's tables: events (Scene_FindEvent, Field_SearchTile), placements (Event_SpawnObjectTable), exit regions (Field_CheckExitRegions) and item events.

Used by BattleFx_FindMatchingEvent, Event_SpawnObjectTable, Field_CheckExitRegions, Field_FindItemEvent, Field_SearchTile, Scene_FindEvent.

Line 65

Event_SearchIgnoresCondition

u32 Event_SearchIgnoresCondition(s32 flags, s32 result)

Returns 1 for a search event (kind 3) that holds whatever its condition: one with more flags than its kind, unless its result is a mimic battle (type 0x005 in its top 12 bits).

Called by Scene_FindEvent. Field_SearchTile tests such an event's condition itself (a chest's flag is set once it is opened), so the event is found either way and the leader still checks the spot; a mimic is found only while its condition holds.

Used by Scene_FindEvent.

Line 86

Scene_FindEvent

struct EffectDescriptor *Scene_FindEvent(s32 kind, s32 target)

Returns the first of the scene's events of kind for target whose condition holds, or NULL. Flag 0x200 also needs the leader to have pushed against it for more than 12 frames (2 with flag 0x800); flag 0x400 needs the leader to face within an eighth of a turn of the direction in the top four bits.

Called by every lookup of a scene's events in this part and by Object_GetTriggerTileAheadOfCurrent. Changes nothing.

Used by Field_SearchTile, Object_GetTriggerTileAheadOfCurrent, Scene_FindActorTalkEvent, Scene_RunRaisedEvent, Scene_RunTouchOrExit, Scene_TalkToActor.

Line 111

Runtime_CallWorkBlockEntry

UNUSED void Runtime_CallWorkBlockEntry(void)

Nothing calls this.

Line 168

Scene_FindActorTalkEvent

s32 Scene_FindActorTalkEvent(s32 id)

Returns the talk event of actor id: for the actor the party has stopped, its kind 7 event if it has one.

Called by Field_RunScene for the A button, to choose between talking and searching, and by the field Psynergy dispatch.

Used by BattleFx_Run, Field_RunScene.

Line 175

Scene_TalkToActor

s32 Scene_TalkToActor(s32 id)

Talks to actor id: shows its event's message or calls its event function, with the actor stopped and turned as its placement says. For the actor the party has stopped, its kind 7 event comes first; without one, a talk event that is a function gives a random line from MsgPonderEllipsis ("...") instead. Returns 0 when an event ran, -1 when there was none.

Called by Field_RunScene for its talk request (work->descriptor). Resumes the stopped actor and sets gGameState.pausedObject back to -1 afterwards.

Used by Field_RunScene.

Line 197

Scene_RunRaisedEvent

s32 Scene_RunRaisedEvent(s32 value)

Runs the scene's raised event (kind 6) for value: its message or its function. Returns 0 when an event ran, -1 when there was none.

Called by Field_RunScene for a positive event request (work->event).

Used by Field_RunScene.

Line 301

Scene_RunTouchOrExit

s32 Scene_RunTouchOrExit(s32 value)

Runs the touch event (kind 2) of what the leader touched, or else takes its exit (kind 1): plays the exit's sound (and effect) and records where it leads. Returns 0 when something ran, -1 when there was nothing.

Called by Field_RunScene for its step request (work->action), which Field_ProcessStep raises for collision codes 1 to 239. Sets work->exit for an exit, and clears work->blockedSteps after a touch that needs pushing.

Used by Field_RunScene.

Line 333

Field_RunPushTileEvent

s32 Field_RunPushTileEvent(s32 collisionCode)

Runs the event of a tile the leader pushes against (codes 0xf9 and 0xfc to 0xfe), once it has pushed for more than 12 frames; the count then restarts.

Called by Field_RunScene for its push request (work->input), which Field_ProcessStep raises for codes 252 to 254; nothing raises 0xf9 there. Clears work->blockedSteps when it acts.

Used by Field_RunScene.

Line 389

Field_SearchTile

s32 Field_SearchTile(s32 tile)

Searches the tile ahead with the given collision code. Codes 242 to 247 show their two messages. Otherwise the scene's search event for the tile runs: a function, a message, or a chest holding a Psynergy stone, a mimic, coins or an item; with no event, "checked the ground" and "found nothing".

Called by Field_RunScene for its search request (work->tile). Opening a chest sets its condition flag, and it may raise a mimic battle (work->battle), give coins or an item, or restore all PP.

Used by Field_RunScene.

Line 429

On this page