Alchemy
Loading...
Searching...
No Matches

events.c

Go to the documentation of this file.
1/// @file
2/// Finding and running a scene's events: talking, touching, searching.
3/// Part of object.c, the field object, compiled only through it.
4
6
7/// Returns the placement of actor id in the scene's placement tables, or NULL:
8/// for a party character (0 to 7) the row with its sprite, and for a placed
9/// actor (8 on) the row it was created from, counting the placed rows in order.
10///
11/// Called by Scene_TalkToActor for the talk facing, and by the field Psynergy
12/// effects that read an actor's placement (Mind Read, the Djinni effect, the
13/// event messages and the view).
15 struct ScenePlacement *placement;
16 s32 tableIndex;
17 s32 placedActor = ACTOR_FIRST_PLACED;
18
19 for (tableIndex = 0; tableIndex < 4; tableIndex++) {
20 placement = ((struct FieldWork *)gEventWork)->tables[tableIndex];
21 if (placement == NULL)
22 continue;
23 if (id <= 7) {
24 for (; (s16)placement->sprite != -1; placement++) {
25 if ((s16)placement->sprite == id) {
26#ifdef UBFIX
27 return placement;
28#else
29 goto found;
30#endif
31 }
32 }
33 } else {
34 for (; (s16)placement->sprite != -1; placement++) {
35 if ((s16)placement->sprite > 7) {
36 if (placedActor == id) {
37#ifdef UBFIX
38 return placement;
39#else
40 goto found;
41#endif
42 }
43 placedActor++;
44 }
45 }
46 }
47 }
48#ifdef UBFIX
49 return NULL;
50#else
51found:
52 // BUG: a missing actor leaves entry NULL if the final table is absent.
53 if ((s16)placement->sprite == -1)
54 return NULL;
55 return placement;
56#endif
57}
58
59/// Returns whether an event condition holds: -1 always holds; a condition with
60/// bit 0x1000 holds while that flag is set, any other while its flag is clear.
61///
62/// Used for every condition column of a scene's tables: events
63/// (Scene_FindEvent, Field_SearchTile), placements (Event_SpawnObjectTable),
64/// exit regions (Field_CheckExitRegions) and item events.
66 s32 flagSet;
67
68 if (condition == -1) {
69 return 1;
70 }
71 if (0x1000 & condition) {
72 return GameFlag_TestFar(condition);
73 }
74 flagSet = GameFlag_TestFar(condition);
75 return flagSet == 0;
76}
77
78/// Returns 1 for a search event (kind 3) that holds whatever its condition: one
79/// with more flags than its kind, unless its result is a mimic battle (type
80/// 0x005 in its top 12 bits).
81///
82/// Called by Scene_FindEvent. Field_SearchTile tests such an event's condition
83/// itself (a chest's flag is set once it is opened), so the event is found
84/// either way and the leader still checks the spot; a mimic is found only
85/// while its condition holds.
87 u32 mimicDifference;
88 s32 searchFlags;
89 u32 ignoresCondition;
90
91 if ((flags & 0xf) != EVENT_SEARCH)
92 return 0;
93 searchFlags = flags & 0x1ff;
94 ignoresCondition = 0;
95 if (searchFlags != EVENT_SEARCH) {
96 mimicDifference = (result & 0xfff00000) ^ 0x500000;
97 ignoresCondition = mimicDifference | (0U - mimicDifference);
98 // 1 when mimicDifference is not 0.
99 ignoresCondition >>= 31;
100 }
101 return ignoresCondition;
102}
103
104/// Returns the first of the scene's events of kind for target whose condition
105/// holds, or NULL. Flag 0x200 also needs the leader to have pushed against it
106/// for more than 12 frames (2 with flag 0x800); flag 0x400 needs the leader to
107/// face within an eighth of a turn of the direction in the top four bits.
108///
109/// Called by every lookup of a scene's events in this part and by
110/// Object_GetTriggerTileAheadOfCurrent. Changes nothing.
112 struct FieldWork *work = (struct FieldWork *)gEventWork;
113 struct EffectDescriptor *event = (struct EffectDescriptor *)work->events;
114 s32 flags;
115 u32 facing =
117
118 flags = event->flags;
119 // Preserve the full control word: direction and push-delay bits refine kind.
120 while (flags != -1) {
121 if ((flags & 0xf) == kind && event->value == target &&
122 (Event_SearchIgnoresCondition(flags, event->result) != 0 ||
123 (GameFlag_IsConditionActive(event->condition) != 0 &&
124 (flags = event->flags, 1)))) {
125 s32 matches = 0;
126 s32 minimumPushFrames = 12;
127 s32 touchRequirements;
128
129 if ((flags & 0x800) != 0)
130 minimumPushFrames = 2;
131 touchRequirements = flags & (EVENT_TOUCH_WALKING | EVENT_TOUCH_FACING);
132
133 switch (touchRequirements) {
134 case 0:
135 matches = 1;
136 break;
138 if (work->blockedSteps > minimumPushFrames) {
139 matches = 1;
140 }
141 break;
143 // Bits 15 to 12 are a facing in sixteenths of a turn; the leader's
144 // facing must be within 0x1fff (an eighth of a turn) of it.
145 flags &= 0xf000;
146 matches = (u16)((flags - facing) + 0x1fff) <= 0x3ffe;
147 break;
149 if (work->blockedSteps > minimumPushFrames) {
150 flags &= 0xf000;
151 matches = (u16)((flags - facing) + 0x1fff) <= 0x3ffe;
152 }
153 break;
154 }
155 if (matches) {
156 return event;
157 }
158 }
159 event++;
160 if (event->flags == -1)
161 break;
162 flags = event->flags;
163 }
164 return 0;
165}
166
167/// Nothing calls this.
169
170/// Returns the talk event of actor id: for the actor the party has stopped, its
171/// kind 7 event if it has one.
172///
173/// Called by Field_RunScene for the A button, to choose between talking and
174/// searching, and by the field Psynergy dispatch.
176 struct EffectDescriptor *talkEvent = Scene_FindEvent(EVENT_TALK, id);
177 s32 pausedActor = gGameState.pausedObject;
178
179 if (pausedActor == id) {
180 struct EffectDescriptor *pausedEvent = Scene_FindEvent(7, pausedActor);
181
182 if (pausedEvent != 0) {
183 return (s32)pausedEvent;
184 }
185 }
186 return (s32)talkEvent;
187}
188
189/// Talks to actor id: shows its event's message or calls its event function,
190/// with the actor stopped and turned as its placement says. For the actor the
191/// party has stopped, its kind 7 event comes first; without one, a talk event
192/// that is a function gives a random line from MsgPonderEllipsis ("...")
193/// instead. Returns 0 when an event ran, -1 when there was none.
194///
195/// Called by Field_RunScene for its talk request (work->descriptor). Resumes
196/// the stopped actor and sets gGameState.pausedObject back to -1 afterwards.
198 struct ScenePlacement *placement = Scene_FindActorPlacement(id);
199 s32 result = -1;
200 struct ObjectRuntime *actor = (struct ObjectRuntime *)Object_GetById(id);
201 struct EffectDescriptor *event;
202 s32 actorPaused = 0;
203 u32 savedAngle;
204 u32 talkFacing;
205 s32 usePausedDialogue = 0;
206
207 if (gGameState.pausedObject == id) {
208 actorPaused = 1;
209 event = Scene_FindEvent(7, id);
210 if (event == 0) {
211 event = Scene_FindEvent(EVENT_TALK, id);
212 usePausedDialogue = 1;
213 if (event == 0) {
214 return -1;
215 }
216 // A function talk event is not run for a stopped actor: it says one of
217 // two lines picked at random from the pair its definition flags choose.
218 if (event->result >= 0x10000) {
219 s32 definitionFlags = BattleFx_GetFlags(id);
220 u32 random = Random16();
221 s32 message =
222 MsgPonderEllipsis + definitionFlags * 2 + (random * 2 >> 16);
224 Event_SetMessageId(message);
227 goto finish;
228 }
229 }
230 } else {
231 event = Scene_FindEvent(EVENT_TALK, id);
232 }
233
234 if (event != 0 && event->result != 0) {
235 if (!actorPaused) {
236 // Stop the actor; with talk facing 0, 1 or 3, also stop the leader and
237 // link the two.
238 u8 *movementState = &actor->movementState;
239
240 *movementState = 1;
242 savedAngle = actor->angle;
243 talkFacing = (u8)placement->talkFacing << 24;
244 if (talkFacing <= (1 << 24) || talkFacing == (3 << 24)) {
245 struct ObjectRuntime *leader =
247
248 leader->targetX = leader->x;
249 leader->targetY = leader->y;
250 leader->targetZ = leader->z;
251 SET_VELOCITY(leader, 0, 0, 0);
253 }
254 }
255 // A result below 0x10000 is a message; above, a function to call.
256 if (event->result < 0x10000) {
257 UiWork_SetBusyFlagsFar(usePausedDialogue);
262 } else {
264 ((void (*)(s32))event->result)(id);
265 }
266 if (!actorPaused) {
267 // An actor left idle (script command 16) goes back to what its talk
268 // facing says: following the leader (3) or its old angle (1).
269 if (actor->script[actor->step] == 16) {
270 if ((s8)placement->talkFacing == 3) {
271 actor->linkedObject =
273 actor->actionFlags |= 1;
276 } else if ((s8)placement->talkFacing == 1) {
277 actor->action = savedAngle;
279 (struct DispatchObject *)actor,
281 }
282 }
283 actor->movementState = 0;
285 }
286 result = 0;
287 }
288finish:
289 // Both a normal event and the paused actor's fallback line release the pause.
290 if (actorPaused) {
293 }
294 return result;
295}
296
297/// Runs the scene's raised event (kind 6) for value: its message or its
298/// function. Returns 0 when an event ran, -1 when there was none.
299///
300/// Called by Field_RunScene for a positive event request (work->event).
302 s32 result;
303 s32 handled;
304 struct EffectDescriptor *event;
305
307 handled = -1;
308 if (event != NULL) {
309 result = event->result;
310 if (result != 0) {
311 if (result < 0x10000) {
315 handled = 0;
317 } else {
318 ((void (*)(s32))result)(value);
319 handled = 0;
320 }
321 }
322 }
323 return handled;
324}
325
326/// Runs the touch event (kind 2) of what the leader touched, or else takes its
327/// exit (kind 1): plays the exit's sound (and effect) and records where it
328/// leads. Returns 0 when something ran, -1 when there was nothing.
329///
330/// Called by Field_RunScene for its step request (work->action), which
331/// Field_ProcessStep raises for collision codes 1 to 239. Sets work->exit for
332/// an exit, and clears work->blockedSteps after a touch that needs pushing.
334 struct EffectDescriptor *touch;
335 struct EffectDescriptor *exit;
336 s32 exitKind;
337 s32 handled;
338 struct FieldWork *work;
339
340 touch = Scene_FindEvent(EVENT_TOUCH, value);
341 handled = -1;
342 work = (struct FieldWork *)gEventWork;
343 if ((touch != 0) && (touch->result != 0)) {
344 if (touch->flags & EVENT_TOUCH_WALKING) {
345 work->blockedSteps = 0;
346 }
347 if (touch->result < 0x10000) {
351 handled = 0;
353 } else {
354 ((void (*)(s32))touch->result)(value);
355 handled = 0;
356 }
357 } else {
359 if (exit != 0) {
360 // Bits 5 and 4 choose the exit's sound: 0 the usual one, 32 and 48
361 // their own sound and context effect, 16 none.
362 exitKind = exit->flags & 0x30;
363 switch (exitKind) {
364 case 0:
366 break;
367 case 32:
370 break;
371 case 48:
374 break;
375 }
376 work->exit = exit->result;
377 handled = 0;
378 }
379 }
380 return handled;
381}
382
383/// Runs the event of a tile the leader pushes against (codes 0xf9 and 0xfc to
384/// 0xfe), once it has pushed for more than 12 frames; the count then restarts.
385///
386/// Called by Field_RunScene for its push request (work->input), which
387/// Field_ProcessStep raises for codes 252 to 254; nothing raises 0xf9 there.
388/// Clears work->blockedSteps when it acts.
390 struct FieldWork *work = (struct FieldWork *)gEventWork;
392
393 switch (collisionCode) {
394 case 0xfc: // a ledge, jumped down with Down held
395 if (work->blockedSteps > 12 && (gKeysHeld & KEY_DOWN)) {
396 Actor_JumpDownLedge(leader, 6, 0);
397 work->blockedSteps = 0;
398 }
399 break;
400 case 0xf9:
401 case 0xfe: // jump forward
402 if (work->blockedSteps > 12) {
404 work->blockedSteps = 0;
405 }
406 break;
407 case 0xfd: // a climbing spot: Down climbs down, Up climbs up
408 if (work->blockedSteps > 12) {
409 if (gKeysHeld & KEY_DOWN) {
411 } else if (gKeysHeld & KEY_UP) {
413 }
414 work->blockedSteps = 0;
415 }
416 break;
417 }
418 return 0;
419}
420
421/// Searches the tile ahead with the given collision code. Codes 242 to 247 show
422/// their two messages. Otherwise the scene's search event for the tile runs: a
423/// function, a message, or a chest holding a Psynergy stone, a mimic, coins or
424/// an item; with no event, "checked the ground" and "found nothing".
425///
426/// Called by Field_RunScene for its search request (work->tile). Opening a
427/// chest sets its condition flag, and it may raise a mimic battle
428/// (work->battle), give coins or an item, or restore all PP.
430 const struct SceneEvent *event;
431 s32 leader;
432 u32 messageOffset;
434 u32 searchResult;
435 s32 rewardType;
436 s32 canOpen;
437
438 leader = gGameState.selectedActor;
439 // Codes 242 to 247 are fixed kinds of spot, each with its own pair of lines
440 // chosen through gField_TileMessageOffsets; the unsigned compare also
441 // rejects codes below 242.
442 messageOffset = tile - 242;
443 if (messageOffset <= 5) {
445 tile = gField_TileMessageOffsets[messageOffset];
446 UiText_ShowPositionedMessageAndWaitFar(MsgTileChecked + tile, 1);
447 UiText_ShowPositionedMessageAndWaitFar(MsgTileResult + tile, 1);
448 } else {
449 event = (const struct SceneEvent *)Scene_FindEvent(EVENT_SEARCH, tile);
450 if (event != NULL) {
451 s32 flags = event->control;
452
453 // Bits 4 to 8 choose what the leader says on checking; if the event
454 // leaves FLAG_NOTHING_HAPPENS set, the matching result line follows.
455 condition = event->condition;
456 messageOffset = (flags >> 4) & 31;
457 if ((event->trigger & 0x400) == 0 && messageOffset != 0) {
459 UiText_ShowPositionedMessageAndWaitFar(MsgTileChecked + messageOffset,
460 1);
462 } else {
464 }
465 // The value is a function address (bits 27 to 24 set) or a FIND_ value
466 // whose top 12 bits give its type: 1 an item, 2 coins, 3 a Psynergy
467 // stone, 4 a message, 5 a mimic.
468 searchResult = event->value;
469 if ((searchResult & 0x0f000000) != 0 ||
470 (searchResult & 0xfff00000) == 0x400000) {
471 if ((searchResult & 0x0f000000) != 0) {
472 // A function.
474 ((void (*)(s32))event->value)(gGameState.selectedActor);
477 MsgTileResult + messageOffset, 1);
478 } else {
479 // A message (type 0x004).
482 else
483 UiText_ShowPositionedMessageAndWaitFar(MsgButFoundNothing, 1);
484 }
485 } else {
486 // A chest; its condition flag is set once it has been opened.
489 // Bit 16 of the value marks a chest the party's own characters
490 // cannot open ("Can't open it").
491 searchResult = event->value;
492 canOpen = 1;
493 if ((searchResult & 0xf0000) == 0x10000 && leader <= 7)
494 canOpen = 0;
495 if (canOpen != 0) {
496 // Control 19, SEARCH(1), is a chest the map shows as a marker.
497 if ((event->control & 0x1ff) == 19)
498 Marker_OpenChest(tile);
499 rewardType = event->value & 0xfff00000;
500 if (rewardType == 0x300000) {
501 // A Psynergy stone: restores all PP.
502 void *object;
503
504 if ((event->control & 0x1ff) == 19)
505 Marker_ShowOpened(tile);
506 object = Marker_GetActor(tile);
510 UiText_ShowPositionedMessageAndWaitFar(MsgGotPsynergyStone, 3);
514 UiText_ShowPositionedMessageAndWaitFar(MsgGotPsynergyStone + 1,
515 1);
520 UiText_ShowPositionedMessageAndWaitFar(MsgGotPsynergyStone + 2,
521 1);
522 Marker_Hide(tile);
523 if (condition != -1)
525 } else if (rewardType == 0x500000) {
526 // A mimic: a battle with enemy group slot of zone 99.
527 struct FieldWork *work = (struct FieldWork *)gEventWork;
528
529 if ((event->control & 0x1ff) == 19)
531 // The chest's flag (with 0x1000) waits in pendingDjinnEvent,
532 // which Field_RunScene resolves when the scene is entered again
533 // after the battle.
534 if (condition != -1) {
535 condition = gGameState.pendingDjinnEvent = condition | 0x1000;
536 }
537 work->battle =
542 UiText_ShowPositionedMessageAndWaitFar(MsgChestWasMimic, 1);
543 } else if (rewardType == 0x200000) {
544 // Coins.
545 void *object;
546
549 WaitFrames(30);
550 if ((event->control & 0x1ff) == 19)
557 if (condition != -1)
558 GameFlag_SetBitFar(condition);
560 } else {
561 // An item, which stays in the chest when nobody can carry it.
562 void *object;
563 s32 recipient;
564
566 gGameState.selectedActor, event->value & 0xfff);
567 WaitFrames(30);
568 recipient = PartyInventory_AddFar((u16)event->value);
569 // messageOffset is reused here as the item id's 0xffff mask.
570 messageOffset = 0xffff;
571 if (recipient == -1) {
572 UiWork_PushValueSlotFar(event->value & 0xfff, 2);
574 UiText_ShowPositionedMessageAndWaitFar(MsgFoundItem + 4, 1);
576 if ((event->control & 0x1ff) == 19)
578 } else {
579 if ((event->control & 0x1ff) == 19)
583 UiWork_PushValueSlotFar(event->value & messageOffset, 2);
584 if (recipient == gGameState.selectedActor) {
585 UiText_ShowPositionedMessageAndWaitFar(MsgColossoIsaacGotItem,
586 3);
587 } else {
588 UiWork_PushValueSlotFar(recipient, 1);
589 UiText_ShowPositionedMessageAndWaitFar(MsgGaveItemToMember,
590 3);
591 }
592 if (condition != -1)
593 GameFlag_SetBitFar(condition);
595 }
596 }
597 } else {
599 }
600 } else {
601 // Already opened: the result line for the check message.
602 UiText_ShowPositionedMessageAndWaitFar(MsgTileResult + messageOffset,
603 1);
604 }
607 }
608 } else {
609 UiText_ShowPositionedMessageAndWaitFar(MsgCheckedGround, 1);
610 UiText_ShowPositionedMessageAndWaitFar(MsgGroundDidntFindAnything, 1);
611 }
613 }
614 return 0;
615}
void Object_LinkPair(s32 firstId, s32 secondId, s32 wait)
The event command "actors face each other": turns two actors toward each other, then waits wait frame...
void Actor_JumpDownLedge(s32 actor, s32 pose, s32 param)
Makes an actor jump down off a ledge in front of it (the field runs it for the leader when the player...
void Event_SetMessageId(s32 message)
The event command "set message": the number of the event's next message, written to work->message.
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void ObjectMotion_SetActionCallback(struct ObjectRuntime *object, s32 action)
Starts an actor's action script: 1 to 4 the fixed action scripts, 5 follow the linked object,...
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition actors.c:462
const u8 gObjectMotion_LinkedActionScript[]
s32 Field_ClimbUp(void)
Climbing up (the player presses up at a climbable wall).
Definition climbing.c:196
s32 Field_ClimbDown(void)
Climbing down (the player presses down at a climbable wall).
Definition climbing.c:119
s32 Field_TryJumpForward(void)
Makes the leader jump two tiles forward, over the tile in front, when the map allows it (Map_CheckObj...
Definition climbing.c:25
void ObjectEffect_BeginContextEffect25(void)
Leaves through an exit of kind 0x30 (animation 25), recorded in flag 0x121.
Definition context.c:138
void ObjectEffect_BeginContextEffect26(void)
Leaves through an exit of kind 0x20 (animation 26); flag 0x120 makes the next scene play the matching...
Definition context.c:131
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_InitializeFar(struct DispatchObject *obj, const s32 *script)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
s32 GameFlag_TestFar(s32 flag)
s32 GameFlag_SetBitFar(s32 flag)
s32 PartyInventory_AddFar(s32 item_id)
void GameFlag_ClearBitFar(s32 flag)
s32 Party_AdjustCoinsFar(s32 amount)
void AudioCommand_PlayFar(s32 id)
void UiWork_SetBusyFlagsFar(s32 flags)
void UiWindow_CreateWithLayoutBoundsFar(s32 flags)
void PartyStatus_CloseFar(void)
void UiText_ShowPositionedMessageAndWaitFar(s32 no, s32 flags)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
const u8 gObjectMotion_StepAngleScript[]
void Object_DestroyIfPresent(void *object)
Releases object unless it is NULL.
Definition field_fx.c:212
struct EffectObj * BattleFx_StartRandomParticleEmitter(s32 actor, s32 item)
Shows the picture of item (0 for none) at the centre of the cell 16 pixels in front of character acto...
Definition field_fx.c:132
void ItemDisplay_RaiseAboveLeader(struct ObjectRuntime *object)
Raises a found item's picture to 36 pixels above the party leader, who holds it up (animation 28) fac...
Definition field_fx.c:221
struct SceneEntries gOverlayArea
@ EVENT_SEARCH
@ EVENT_TOUCH
@ EVENT_EXIT
@ EVENT_TALK
@ EVENT_RAISED
#define EVENT_TOUCH_FACING
@ ACTOR_FIRST_PLACED
#define EVENT_TOUCH_WALKING
#define FLAG_NOTHING_HAPPENS
Set before an action on the field; still set afterwards, nothing came of it and the game says so.
Definition flags.h:51
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
const u8 gField_TileMessageOffsets[6]
The message of each searchable tile code from 242 to 247, as an offset from MsgTileChecked and MsgTil...
Definition fxdata.c:24
#define Battle_SetStart(mode)
Sets the battle start type.
Definition game_state.h:164
struct GameState gGameState
void BattleFx_ResumeObject(s32 actorId)
Resumes object id with the update and param kept by BattleEffect_PauseObject.
Definition halt.c:199
@ KEY_UP
Definition io_reg.h:249
@ KEY_DOWN
Definition io_reg.h:250
volatile u32 gKeysHeld
Keys down now.
#define SET_VELOCITY(p, vx, vy, vz)
Definition macros.h:18
struct ObjectRuntime * Marker_GetActor(s32 id)
Returns the actor of marker id, or NULL when no slot has it.
Definition markers.c:226
void Marker_CloseChest(s32 id)
Closes the chest of marker id again (its item could not be carried), with SE_125.
Definition markers.c:176
void Marker_ShowOpened(s32 id)
Shows the chest of marker id open (animation 2), with no sound.
Definition markers.c:209
void Marker_OpenChest(s32 id)
Opens the chest of marker id (animation 4) with SE_124, and waits 12 frames.
Definition markers.c:205
void Marker_LaunchMimic(s32 id)
Makes the chest of marker id jump up as a mimic: after 18 frames it takes animation 7,...
Definition markers.c:183
void Marker_Hide(s32 id)
Hides the actor of marker id by clearing its animationKind.
Definition markers.c:238
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
u16 Encounter_GetEnemyGroupAtSlot(s32 zone, s32 slot)
Returns the enemy group in slot (0 to 7) of zone; 14 halfwords make a zone.
Definition encounter.c:244
void BattleFx_SelectBattleCue(s32 zone, s32 slot)
Chooses the battle music for slot of zone (gGameState.sceneCue).
Definition encounter.c:439
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
Definition events.c:65
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.
Definition events.c:111
s32 Scene_TalkToActor(s32 id)
Talks to actor id: shows its event's message or calls its event function, with the actor stopped and ...
Definition events.c:197
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 ...
Definition events.c:333
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 o...
Definition events.c:175
s32 Field_SearchTile(s32 tile)
Searches the tile ahead with the given collision code.
Definition events.c:429
UNUSED void Runtime_CallWorkBlockEntry(void)
Nothing calls this.
Definition events.c:168
s32 Scene_RunRaisedEvent(s32 value)
Runs the scene's raised event (kind 6) for value: its message or its function.
Definition events.c:301
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 ...
Definition events.c:14
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 ...
Definition events.c:389
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...
Definition events.c:86
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
Definition events.c:67
void FieldEvent_End(void)
Ends an event: stops the debug fast-forward callback, gives the camera back to the leader and refresh...
Definition events.c:120
void FieldEvent_WaitFrames(s32 frames)
The event command "wait": waits the requested frames, unless debug fast forward (Event_UpdateDebugSki...
Definition events.c:55
void FieldEvent_Begin(void)
The event command "begin event": closes any timed notice, stops the leader, resets the message and ti...
Definition events.c:91
void FieldEvent_ShowMessageAndWait(s32 actor, s32 flags)
The event command "show message": opens the current message at actor (UiText_OpenMessageAtObject) and...
Definition messages.c:248
What every part of object.c shares: its includes and the macros and types more than one part uses.
void BattleFx_PlayQueuedSound(void)
Plays the sound BattleFx_SetQueuedSoundAndPlay remembered, if any.
Definition requests.c:102
#define SE_RECOVERY
Definition songs.h:119
#define SE_129
Definition songs.h:122
#define MUS_TREASURE_FOUND
Definition songs.h:82
#define SE_128
Definition songs.h:121
#define SE_MAP_EXIT
Definition songs.h:116
#define SE_246
Definition songs.h:241
s32 BattleFx_GetFlags(s32 id)
Returns the definition flags of actor id's sprite, which choose its line when it has nothing to say.
Definition speakers.c:52
struct EventWork * gEventWork
#define NULL
Definition bilibin.h:6
void BattleParty_ApplyDrain(s32 amount, s32 unused)
Gives each character in the party amount PP (PP regenerates as the party walks).
Definition step.c:362
A field object as the object dispatcher's far calls take it.
One of the scene's events (the same 12 bytes as struct SceneEvent).
Definition object.h:62
u8 value
the target (an actor or a tile code)
Definition object.h:65
s32 result
below 0x10000 a message, else a function to call
Definition object.h:68
s32 flags
the low 4 bits are the kind (SceneEventKind; 7 talks to the actor the party stopped)
Definition object.h:63
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
u16 facing
1/65536 turns
Definition field_obj.h:34
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
s16 event
A raised event for Scene_RunRaisedEvent, or -1 when characters fell to poison or hazard damage,...
const struct SceneEvent * events
the scene's event table
s16 tile
a tile's collision code, for Field_SearchTile
s16 battle
the enemy group of a random encounter
struct ScenePlacement * tables[4]
The placement tables placed so far, recorded by Event_SpawnObjectTable.
s16 blockedSteps
Frames the leader has pushed against something, counted by the player controls; touch events and push...
s16 sceneCue
the battle music chosen for the encounter
Definition game_state.h:55
s16 pendingDjinnEvent
The Djinni battle pending (DJINNI_0 plus its number, flags in bits 15 to 11), resolved on returning t...
Definition game_state.h:103
s16 pausedObject
Halt: the stopped object; -1 for none.
Definition game_state.h:113
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 targetZ
16.16 fixed-point pixels; 0x80000000 when unset
u8 actionFlags
FieldActor.steeringFlags: bit 0 faces its motion.
s32 targetY
16.16 fixed-point pixels; 0x80000000 when unset
u8 movementState
nonzero skips its script and motion (paused)
s32 z
16.16 fixed-point pixels
s32 targetX
16.16 fixed-point pixels; 0x80000000 when unset
s32 * script
the object script it runs; null when the object is free
s32 x
16.16 fixed-point pixels
s16 step
the script cursor, in words
s32 y
16.16 fixed-point pixels
struct ObjectRuntime * linkedObject
The object its action script follows or faces.
s16 action
The parameter its action script reads (a follow distance or an angle), or the player's frames to its ...
s32(*) initialize(void)
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear
s16 trigger
What the event answers: an actor id, a tile's collision code, a marker id or a raised value.
u32 value
A message below 0x10000, else an event function; for an exit, the exit kind its scene's exit table ma...
u32 control
The kind and its detail, read by Scene_FindEvent and the item, Psynergy and search lookups; -1 ends t...
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
Definition field_scene.h:81
u8 talkFacing
enum ActorTalkFacing; 3 follows the leader afterwards
Definition field_scene.h:95
s16 sprite
The actor's sprite; 0 to 7 are the party's characters, each in its own actor slot,...
Definition field_scene.h:84
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed char s8
Definition types.h:10
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
#define UNUSED
Definition types.h:22
unsigned char u8
Definition types.h:11