Alchemy
Loading...
Searching...
No Matches

events.c

Go to the documentation of this file.
1/// @file
2/// Event commands: waits, received items, questions and destinations.
3/// Part of psynergy_effects.c, compiled only through it.
4
6
7// Edition-specific text and window layout values.
8#if (LANGUAGE == LANGUAGE_GERMAN)
9#define GIFT_RECEIVED_MESSAGE MsgGaveItemToMember
10#define GIFT_RECEIVED_MESSAGE_MODE 1
11#elif (LANGUAGE == LANGUAGE_SPANISH) || (LANGUAGE == LANGUAGE_FRENCH) || \
12 (LANGUAGE == LANGUAGE_ITALIAN)
13#define GIFT_RECEIVED_MESSAGE (MsgColossoIsaacGotItem + 1)
14#define GIFT_RECEIVED_MESSAGE_MODE 1
15#else
16#define GIFT_RECEIVED_MESSAGE (MsgColossoIsaacGotItem + 1)
17#define GIFT_RECEIVED_MESSAGE_MODE 3
18#endif
19
20/// Shows the message for an item the party has just received. The message is
21/// `Isaac got <item>.`; the German release has its own sentence for the Black
22/// Orb. flags are the message window flags of
23/// UiText_ShowPositionedMessageAndWait.
24static inline void ItemGift_ShowGotItem(s32 item, s32 flags) {
25#if (LANGUAGE == LANGUAGE_GERMAN)
26 if (item == ITEM_BLACK_ORB) {
27 UiText_ShowPositionedMessageAndWaitFar(MsgGotBlackOrb, flags);
28 return;
29 }
30#endif
32 UiText_ShowPositionedMessageAndWaitFar(MsgColossoIsaacGotItem, flags);
33}
34
35/// Debug only: while debug mode is on, R makes every event wait
36/// (FieldEvent_WaitFrames) end at once and L restores normal waits. Runs as a
37/// scheduler callback for the length of an event (FieldEvent_Begin).
39 struct FieldWork *runtime = (struct FieldWork *)gEventWork;
40
41 if (gDebugMode != 0) {
42 if (gKeysPressed & KEY_L) {
43 runtime->fastForward = 0;
44 }
45 if (gKeysPressed & KEY_R) {
46 runtime->fastForward = -1;
47 }
48 }
49}
50
51/// The event command "wait": waits the requested frames, unless debug fast
52/// forward (Event_UpdateDebugSkip) is on. Scene scripts reach it as
53/// Engine_EventWait (the WAIT command); this object's actor, message, camera
54/// and climbing commands wait through it too.
56 if (((struct FieldWork *)gEventWork)->fastForward == 0 && frames != 0) {
57 WaitFrames(frames);
58 }
59}
60
61/// Stops the leader where it stands: no horizontal velocity, the normal walking
62/// speed (1.0) and acceleration (0.5), no destination, and the standing pose,
63/// or the climbing pose (12) while the leader is on a climbable wall. Called by
64/// FieldEvent_Begin, by Field_RunScene before it handles several requests, by
65/// Field_UsePsynergy, Scene_TalkToActor, Field_CheckExitRegions and the world
66/// map's zoom (BattleFx_RunVisibilityTransition).
68 struct ObjectRuntime *object;
69
71 object->speedLimit = 0x10000;
72 object->acceleration = 0x8000;
73 object->targetX = ACTOR_NO_TARGET;
74 object->targetZ = ACTOR_NO_TARGET;
75 object->velocityX = 0;
76 object->velocityZ = 0;
77 if (gGameState.movementMode == 1) {
79 return;
80 }
82}
83
84/// The event command "begin event": closes any timed notice, stops the leader,
85/// resets the message and timing state, and starts the debug fast-forward
86/// callback with the leader as the message speaker. Scene scripts reach it as
87/// Engine_EventBegin (EV_BEGIN); the field's item, Psynergy, Djinni, Retreat
88/// and climbing events open with it too. Clears the field work's name window,
89/// fastForward and messageWindow, sets transitionFrames to 16 and the speaker
90/// to the leader.
91void FieldEvent_Begin(void) {
92 struct FieldWork *runtime = (struct FieldWork *)gEventWork;
93
96 // Keep the event reset's signed halfword read.
97 if ((s16)runtime->busy != 0) {
99 }
100 // Every event starts with no name window and normal waits.
101 runtime->nameMessage = 0;
102 runtime->nameWidth = 0;
103 runtime->transitionFrames = 0x10;
104 runtime->fastForward = 0;
105 runtime->unk1da = 0xFFFF;
106 runtime->unk1dc = -1;
107 runtime->unk1de = -1;
109 // XXX: flag 0x132 is cleared at every event and nothing in ☀️ names it; the
110 // scene scripts or overlays that set or test 0x132 would settle its meaning.
113 runtime->messageWindow = 0;
114}
115
116/// Ends an event: stops the debug fast-forward callback, gives the camera back
117/// to the leader and refreshes FLAG_LURE_CAP (GameFlag_RefreshLureCap). Scene
118/// scripts reach it as Engine_EventEnd (EV_END), and every event that opens
119/// with FieldEvent_Begin closes with it.
120void FieldEvent_End(void) {
124}
125
126/// Nothing calls it.
128
129/// An empty hook; it does nothing in the released game. Only
130/// Event_RunObjectHookAndWait calls it.
131void Event_NoOpHook(void) {}
132
133/// Respawns the scene's actors from a placement table and waits one frame for
134/// them to appear. Reached only through an unnamed veneer in the object bank's
135/// far-call table; nothing in ☀️ names it.
139 WaitFrames(1);
140 // XXX: the leader's object is fetched and not used; a caller in an overlay
141 // that reads the result would show whether this returned it once.
143}
144
145/// Spawns the actors of a placement table after the last actor in use. Called
146/// by the Kolima, Kalay and Tolbi ship scene scripts to bring actors in during
147/// a scene.
150}
151
152/// Sets the scene's event table, which the field checks as the leader moves:
153/// writes work->events. Altin Peak's scene script calls it as
154/// Event_LoadAreaScript.
156 struct FieldWork *work = (struct FieldWork *)gEventWork;
157
158 work->events = events;
159}
160
161/// Adds unit to the party. With announce nonzero it also shows
162/// `<name> joined your party.` (Party_ShowJoinedMessage, which receives
163/// announce too). Called by six scene scripts as a character joins (Vale,
164/// the Vault, Goma Cave and Mercury Lighthouse among them).
166 UnitGetFar(unit);
168 if (announce != 0) {
169 Party_ShowJoinedMessageFar(unit, announce);
170 }
171}
172
173/// Adds two units to the party and announces them together. Vale's scene
174/// script calls it twice, as Engine_PartyAddMembers.
178 Party_ShowPairJoinedMessageFar(first, second);
179}
180
181/// Checks an L or R button shortcut, packed as the member in bits 10 to 13 and
182/// the Psynergy in bits 0 to 9. Returns 0 if it can still be cast, -1 for no
183/// such party member, -2 when that member is not in the party and -3 when the
184/// member no longer knows the Psynergy. Only Event_ClearInvalidPackedValues
185/// calls it.
187 s32 member = (shortcut >> 10) & 0xf;
188 s32 ability = shortcut & 0x3ff;
189
190 if (member > 7)
191 return -1;
192 if (GameFlag_TestFar(member) == 0)
193 return -2;
194 if (Unit_KnowsActionFar(member, ability) == 0)
195 return -3;
196 return 0;
197}
198
199/// Clears each button shortcut whose Psynergy can no longer be cast: zeroes
200/// gGameState.firstShortcut or secondShortcut. Called whenever the party or
201/// what it knows may have changed: by Party_RemoveOwnerRestored,
202/// Inventory_Discard, and the field menu's item, Psynergy and Djinn screens.
208}
209
210/// Takes unit out of the party, fully restoring its HP and PP and curing its
211/// poison. If no member left standing has HP, the leader is given 1 HP so the
212/// party is never left all down. Called by the scene scripts where a member
213/// leaves: Vale in the storm, the Vault, and Sol Sanctum.
215 struct BattleUnit *vitals;
216 s32 partyIndex;
217 s32 partyCount;
218 s32 survivingMembers;
219
222 vitals = UnitGetFar(unit);
223 vitals->hp = vitals->maxHp;
224 vitals->pp = vitals->maxPp;
225 Unit_UpdateGauges(vitals);
226 vitals->poison = 0;
227 // Count the members who remain and still have HP.
228 survivingMembers = 0;
229 partyCount = Party_CountActiveOwnersFar();
230 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
231 vitals = UnitGetFar(gGameState.activeOwners[partyIndex]);
232 if (vitals->hp != 0)
233 survivingMembers++;
234 }
235 if (survivingMembers == 0) {
237 vitals->hp = 1;
238 Unit_UpdateGauges(vitals);
239 }
240}
241
242/// Checks whether the party can carry one more of item: each member carries at
243/// most 30 of one item. When they are all full, says
244/// `Isaac's party cannot carry any more <item>s...` and
245/// `Isaac threw the <item> as far away as possible.` and returns -1; otherwise
246/// returns 0. Field_RunScene calls it before it gives gGameState.pendingItem
247/// with PartyInventory_GiveItem.
249 s32 partyCount;
250 s32 heldQuantity = 0;
251 s32 partyIndex;
252
253 partyCount = Party_CountActiveOwnersFar();
254 for (partyIndex = 0; partyIndex < partyCount; partyIndex++)
255 heldQuantity +=
257
258 if (heldQuantity >= partyCount * 30) {
260 UiText_ShowPositionedMessageAndWaitFar(MsgCannotCarryMore, 1);
262 UiText_ShowPositionedMessageAndWaitFar(MsgCannotCarryMore + 1, 1);
263 return -1;
264 }
265 return 0;
266}
267
268/// The event command "give item": gives item to the first party member with
269/// room for it and says so. When every bag is full, the player picks an item
270/// to drop to make room, or drops the new item instead (not allowed for an
271/// indispensable one). Returns the member who received the item, or -1 when
272/// it was left behind. Scene scripts reach it as Engine_PartyGiveItem (about
273/// 24 of them); Field_RunScene gives the pending item and the debug test menu
274/// gives items through it. The field work's message is restored afterwards.
276 // A for/continue retry loop shrinks native English 0x1c4 -> 0x1a8;
277 // retain the original backedges until a plain form matches.
278 struct FieldWork *work;
279 s32 savedMessage;
280 s32 owner;
281 s32 result;
282 s32 discardQuantity;
283 s32 discardIndex;
284 s32 member;
285 s32 slot;
286
287 work = (struct FieldWork *)gEventWork;
288 // The messages below move the event's message on; every return puts it
289 // back, so the scene script continues where it was.
290 savedMessage = work->message;
292 if (owner == -1) {
293 // Every bag is full: "But you can't carry any more items."
295 UiText_ShowPositionedMessageAndWaitFar(MsgCannotCarryAnyMore, 1);
296 retry:
297 UiText_ShowPositionedMessageAndWaitFar(MsgWhatWillYouDrop, 1);
298 result = Shop_PickUnitItemFar(&member, &slot);
299 if (result == -1) {
300 // Cancelled: drop the new item instead, unless it is indispensable
301 // ("That <item>'s valuable! You must get it!").
304 UiText_ShowPositionedMessageAndWaitFar(MsgWhatWillYouDrop + 4, 1);
305 goto retry;
306 }
307 // "Drop the <item>?"
309 UiText_ShowPositionedMessageAndWaitFar(MsgWhatWillYouDrop + 1, 5);
310 result = Menu_AskYesNo(1);
312 if (result != 0)
313 goto retry;
314 // "Isaac drops the <item>."
317 UiText_ShowPositionedMessageAndWaitFar(MsgWhatWillYouDrop + 2, 1);
318 work->message = savedMessage;
319 return owner;
320 } else {
321 // A carried item was picked: drop it (the whole stack) and take the new
322 // one.
323 UnitGetFar(member);
324 {
325 /* FAKEMATCH(temporary): the slot copied to a block local loads before
326 * the member; as Shop_GetSelectionState(member, slot), 2 of 181
327 * instructions differ in tbs-en. */
328 s32 selectedSlot = slot;
329
330 discardQuantity = Shop_GetSelectionState(member, selectedSlot);
331 }
332 // A member who already carries 30 of the new item (the cap
333 // Party_CheckItemLimit counts) cannot take it: say so and ask again.
334 // Editions at TBS_PATCH_1 alone skip the check.
335#if !(TBS_PATCH_1 && !TBS_PATCH_2)
336 if (Inventory_CountItemFar(member, item) > 29) {
337 UiWork_PushValueSlotFar(member, 1);
339 UiText_ShowPositionedMessageAndWaitFar(MsgWhatWillYouDrop + 7, 1);
340 goto retry;
341 }
342#endif
343 for (discardIndex = 0; discardIndex < discardQuantity; discardIndex++)
344 Inventory_DiscardFar(member, slot);
347 if (owner == gGameState.selectedActor) {
349 } else {
351 UiWork_PushValueSlotFar(owner, 1);
352 UiText_ShowPositionedMessageAndWaitFar(MsgGaveItemToMember, 3);
353 }
354 work->message = savedMessage;
355 return owner;
356 }
357 } else {
358 // There was room: "Isaac got <item>.", and "Isaac gave <item> to
359 // <member>." when someone other than the leader carries it.
362 if (owner != gGameState.selectedActor) {
364 UiWork_PushValueSlotFar(owner, 1);
367 }
368 work->message = savedMessage;
369 }
370 return owner;
371}
372
373/// Gives item to one party member. Returns unit, or -1 if its bag is full.
374/// Reached only through an unnamed veneer in the object bank's far-call
375/// table; nothing in ☀️ names it.
377 if (Inventory_AddItemFar(unit, item) >= 0)
378 return unit;
379 return -1;
380}
381
382/// An empty function; nothing in ☀️ calls it.
384
385/// An empty function; nothing in ☀️ calls it.
387
388/// Waits, at most 90 frames, for an actor's animation to stop being animation:
389/// the actor has finished a one-off animation such as a nod. Only actors drawn
390/// as an animation object (animationKind 1) are waited for. Called by
391/// Event_AskYesNoWithActorAnimation.
392void Actor_WaitForAnimationEnd(s32 actor, s32 animation) {
393 struct ObjectRuntime *actorObject = ObjectTable_Get(actor);
394
395 if (actorObject != 0 && actorObject->animationKind == 1) {
396 s32 frames = 0;
397 u8 *animationNumber =
398 &((struct AnimationObject *)actorObject->animation)->lastNo;
399
400 while (frames <= 89) {
401 WaitFrames(1);
402 if (animation != *animationNumber) {
403 break;
404 }
405 frames++;
406 }
407 }
408}
409
410/// The event command "choose yes or no": once the message on screen has been
411/// read, asks yes or no below it, or above it when the message windows reach
412/// past row 15 or forceBottom is set. The speaker nods (animation 3) at yes
413/// and shakes its head (animation 4) at no. Returns 0 for yes, 1 for no.
414/// Scene scripts reach it as Engine_EventChooseYesNo (about 54 of them); the
415/// link lobby and FieldEvent_AskYesNoAndShowResponse call it too.
417 struct FieldWork *work = (struct FieldWork *)gEventWork;
419 struct UiWindow *window = (struct UiWindow *)work->messageWindow;
420 struct UiWindow *side = (struct UiWindow *)work->sideWindow;
421 s32 useBottom = 1;
422 s32 answer;
423
424 // Wait for every button to be released and the message to finish.
425 while (gKeysPressed != 0)
426 WaitFrames(1);
427
428 while (UiWork_IsCompleteFar() == 0)
429 WaitFrames(1);
430
431 WaitFrames(3);
432
433 // The question goes above the message windows when they reach past row 15,
434 // so it does not cover them.
435 if (forceBottom == 0) {
436 s32 bottom = window->y + window->height;
437
438 if (side != 0) {
439 s32 sideBottom = side->y + side->height;
440 if (bottom < sideBottom)
441 bottom = sideBottom;
442 }
443
444 if (bottom > 15)
445 useBottom = 0;
446 }
447
448 answer = Menu_RunConfirmSelectionFar(useBottom, work->nameMessage,
449 work->nameWidth, 0);
450 if (answer != 0) {
451 Object_SetModeById(actor, 4);
455 } else {
456 Object_SetModeById(actor, 3);
460 }
461
462 return answer;
463}
464
465/// Asks yes or no at the top of the screen, or at the bottom with atBottom
466/// set. Returns 0 for yes, 1 for no. Called by PartyInventory_GiveItem,
467/// Field_UseItem, Field_UsePsynergy and the cleared game's menu.
469 return Menu_RunConfirmSelectionFar(atBottom, 0, 0, 0);
470}
471
472/// Teaches unit the Psynergy ability and says so with its jingle, waiting for
473/// the player to read it. The message is `<unit> learned <ability>.` Fuchin
474/// Temple's scene script calls it.
475void Party_LearnAbility(s32 unit, s32 ability) {
476 // Declared without parameters: unit and ability pass through in r0 and r1.
480 UiWork_PushValueSlotFar(ability, 4);
481 UiText_ShowPositionedMessageAndWaitFar(MsgAbilityLearned, 3);
482}
483
484/// The event command "open screen": starts the event's screen transition and
485/// sets work->transitionActive. Scene scripts reach it as
486/// Engine_EventOpenScreen; the inn, the title, cleared-game and link lobby
487/// menus and Map_ShowWorldMap call it too.
489 struct FieldWork *runtime = (struct FieldWork *)gEventWork;
490
492 runtime->transitionActive = 1;
493}
494
495/// The event command "close screen": finishes the event's screen transition
496/// and clears work->transitionActive. Scene scripts reach it as
497/// Engine_EventCloseScreen; the inn, the cleared-game menu and
498/// Map_ShowWorldMap call it too.
500 struct FieldWork *runtime = (struct FieldWork *)gEventWork;
501
503 runtime->transitionActive = 0;
504}
505
506/// The event command "wait for screen": waits as long as the transition runs
507/// (work->transitionFrames). Scene scripts reach it as
508/// Engine_EventWaitForScreen.
511}
512
513/// Makes the event leave for the given entrance of the given scene: raises the
514/// exit request 999 and writes gGameState.scene and entrance. Called by the
515/// title, cleared-game and link lobby menus, the debug battle command and five
516/// scene scripts (the Lemurian ship and the world map among them).
517void Event_SetDestination(s32 scene, s32 entrance) {
518 ((struct FieldWork *)gEventWork)->exit = 999;
519 gGameState.scene = scene;
520 gGameState.entrance = entrance;
521}
522
523/// Makes the event leave and records scene and entrance as the saved
524/// destination. Reached only through an unnamed veneer in the object bank's
525/// far-call table; nothing in ☀️ names it.
526void Event_SetSavedDestination(u16 scene, u16 entrance) {
527 struct FieldWork *state = (struct FieldWork *)gEventWork;
528 state->exit = 999;
529 gGameState.savedScene = scene;
530 gGameState.savedEntrance = entrance;
531}
532
533/// The event command "request exit": sets the field's exit request (999 leaves
534/// for gGameState's scene and entrance). Scene scripts reach it as
535/// Engine_EventRequestExit (about 61 of them).
537 struct FieldWork *state = (struct FieldWork *)gEventWork;
538 state->exit = request;
539}
540
541#undef GIFT_RECEIVED_MESSAGE
542#undef GIFT_RECEIVED_MESSAGE_MODE
void Object_SetModeById(u32 objectId, s32 animation)
The event command "set actor animation" (1 stands, 2 walks, 3 nods, 4 shakes the head and so on).
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition actors.c:462
s32 ObjectTable_FindLastActiveId(void)
Returns the slot after the last placed actor (8 when there is none), or -1 when slot 65 is occupied.
Definition actors.c:285
void ObjectTable_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
Definition actors.c:217
void Event_SpawnObjectTable(struct ScenePlacement *entry, s32 slot)
Creates the actors of a scene's placement table (ended by sprite -1), and records the table among the...
Definition actors.c:75
#define Unit_UpdateGauges(unit)
Recalculates HP and PP gauges, keeping at least one when any points remain.
void Camera_FollowActor(s32 actor, s32 keepPosition)
The event command "camera follow actor": the camera (the event's view centre) follows actor.
Definition camera.c:10
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
s32 Party_AddActiveOwnerFar(s32 value)
struct BattleUnit * UnitGetFar(u32 owner)
struct ItemDefinition * Item_GetDirectFar(s32 item)
s32 Inventory_CountItemFar(s32 owner, s32 item_id)
s32 Item_AdjustCounterFar(s32 item_id, s32 delta)
s32 GameFlag_TestFar(s32 flag)
s32 Inventory_AddItemFar(s32 owner_id, s32 item_id)
s32 Unit_LearnPsynergyFar()
s32 Party_RemoveActiveOwnerFar(s32 value)
s32 Shop_GetSelectionState(s32 owner, s32 slot)
Far call to Inventory_GetQuantity.
s32 Unit_KnowsActionFar(s32 owner, s32 value)
void GameFlag_RefreshLureCapFar(void)
s32 PartyInventory_AddFar(s32 item_id)
s32 Party_CountActiveOwnersFar(void)
void GameFlag_ClearBitFar(s32 flag)
s32 Inventory_DiscardFar(s32 owner, s32 slot)
s32 Shop_PickUnitItemFar(s32 *selected_unit, s32 *selectedItem)
void AudioCommand_PlayFar(s32 id)
void Party_ShowPairJoinedMessageFar(s32 first, s32 second)
void Party_ShowJoinedMessageFar()
void UiText_ShowPositionedMessageAndWaitFar(s32 no, s32 flags)
void UiTimedNotice_CloseIfActiveFar(void)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiWork_FinalizeEntityMatchingLocalizedIdFar(u32 entry)
s32 UiWork_IsCompleteFar(void)
s32 Menu_RunConfirmSelectionFar(s32 low, s32 message, s32 w, s32 selection)
void UiWork_FinalizePendingCoreFar(void)
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
Definition field_obj.h:145
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
struct GameState gGameState
@ KEY_R
Definition io_reg.h:251
@ KEY_L
Definition io_reg.h:252
@ ITEM_INDISPENSABLE
Definition item.h:30
@ ITEM_BLACK_ORB
Definition item_ids.h:80
volatile u32 gKeysPressed
Keys that went down this frame.
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
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
Definition targets.c:261
void DisplayTransition_Start(s32 mode, s32 frames)
Fades the screen in over frames frames.
Definition transition.c:603
void DisplayTransition_Finish(s32 mode, s32 frames)
Fades the screen out over frames frames, as DisplayTransition_Start fades it in.
Definition transition.c:698
s32 Event_AskYesNoWithActorAnimation(s32 actor, s32 forceBottom)
The event command "choose yes or no": once the message on screen has been read, asks yes or no below ...
Definition events.c:416
void Event_SetExitRequest(u16 request)
The event command "request exit": sets the field's exit request (999 leaves for gGameState's scene an...
Definition events.c:536
void Event_SetSavedDestination(u16 scene, u16 entrance)
Makes the event leave and records scene and entrance as the saved destination.
Definition events.c:526
#define GIFT_RECEIVED_MESSAGE_MODE
Definition events.c:17
void Actor_WaitForAnimationEnd(s32 actor, s32 animation)
Waits, at most 90 frames, for an actor's animation to stop being animation: the actor has finished a ...
Definition events.c:392
s32 Menu_AskYesNo(s32 atBottom)
Asks yes or no at the top of the screen, or at the bottom with atBottom set.
Definition events.c:468
s32 PartyInventory_GiveItem(s32 item, s32 unused)
The event command "give item": gives item to the first party member with room for it and says so.
Definition events.c:275
static void ItemGift_ShowGotItem(s32 item, s32 flags)
Shows the message for an item the party has just received.
Definition events.c:24
UNUSED void Event_NoOpHookA(void)
Nothing calls it.
Definition events.c:127
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 Event_UpdateDebugSkip(void)
Debug only: while debug mode is on, R makes every event wait (FieldEvent_WaitFrames) end at once and ...
Definition events.c:38
void Event_FinishScreenTransition(void)
The event command "close screen": finishes the event's screen transition and clears work->transitionA...
Definition events.c:499
void Event_SetSceneEvents(const struct SceneEvent *events)
Sets the scene's event table, which the field checks as the leader moves: writes work->events.
Definition events.c:155
void Inventory_NoOpCallback(void)
An empty function; nothing in ☀️ calls it.
Definition events.c:383
void Event_ClearInvalidPackedValues(void)
Clears each button shortcut whose Psynergy can no longer be cast: zeroes gGameState....
Definition events.c:203
#define GIFT_RECEIVED_MESSAGE
Definition events.c:16
void Event_WaitTransitionFrames(void)
The event command "wait for screen": waits as long as the transition runs (work->transitionFrames).
Definition events.c:509
void FieldEvent_WaitFrames(s32 frames)
The event command "wait": waits the requested frames, unless debug fast forward (Event_UpdateDebugSki...
Definition events.c:55
s32 Party_CheckItemLimit(s32 item)
Checks whether the party can carry one more of item: each member carries at most 30 of one item.
Definition events.c:248
void Event_PrepareTwoObjectsAndApply(s32 first, s32 second)
Adds two units to the party and announces them together.
Definition events.c:175
void Party_RemoveOwnerRestored(s32 unit)
Takes unit out of the party, fully restoring its HP and PP and curing its poison.
Definition events.c:214
void Event_RunObjectHookAndWait(struct ScenePlacement *table)
Respawns the scene's actors from a placement table and waits one frame for them to appear.
Definition events.c:136
void Event_StartScreenTransition(void)
The event command "open screen": starts the event's screen transition and sets work->transitionActive...
Definition events.c:488
s32 Inventory_TryAddAndReturnOwner(s32 item, s32 unused, s32 unit)
Gives item to one party member.
Definition events.c:376
void Event_SetDestination(s32 scene, s32 entrance)
Makes the event leave for the given entrance of the given scene: raises the exit request 999 and writ...
Definition events.c:517
void Event_CallWithLastActiveObjectId(struct ScenePlacement *table)
Spawns the actors of a placement table after the last actor in use.
Definition events.c:148
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
s32 Event_ValidatePackedId(u32 shortcut)
Checks an L or R button shortcut, packed as the member in bits 10 to 13 and the Psynergy in bits 0 to...
Definition events.c:186
void Event_NoOpHook(void)
An empty hook; it does nothing in the released game.
Definition events.c:131
void Event_PrepareObjectAndApplyValue(s32 unit, s32 announce)
Adds unit to the party.
Definition events.c:165
void Inventory_ReservedNoOp(void)
An empty function; nothing in ☀️ calls it.
Definition events.c:386
void Party_LearnAbility(s32 unit, s32 ability)
Teaches unit the Psynergy ability and says so with its jingle, waiting for the player to read it.
Definition events.c:475
What every part of psynergy_effects.c shares: its includes and the macros and types more than one par...
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
Definition scheduler.c:102
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
Definition scheduler.c:146
#define MUS_TREASURE_FOUND
Definition songs.h:82
struct EventWork * gEventWork
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
u8 lastNo
The animation number last selected, which selecting again skips.
Definition animspr.h:124
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s16 maxPp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
s8 poison
1 poisoned, 2 deadly poison
s16 hp
current HP, 0 when downed
s16 pp
current PP
s16 maxHp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
u16 transitionActive
set once the opening transition has started
s16 unk1de
set to -1 by FieldEvent_Begin; not read by name
const struct SceneEvent * events
the scene's event table
s16 unk1dc
set to -1 by FieldEvent_Begin; not read by name
s32 transition
SCENE_TRANSITION(style, variant); 0x100 on entry.
u16 busy
Set while a raised or touch event runs; FieldEvent_Begin then resets the effect counter.
s32 fastForward
debug: skip timed event waits and actor messages
u16 unk1da
set to 0xffff by FieldEvent_Begin; not read by name
s16 nameMessage
first message of the menu's name window (0: none)
s32 speaker
the actor speaking; the leader at each event
s16 message
the next message, advanced as each window opens
s16 nameWidth
width of the name window (0: the default)
s32 sideWindow
the speaker's portrait window
s32 messageWindow
the open message window, 0 for none
s16 item
an item to use, packed as Field_UseItem reads it
s32 transitionFrames
frames; 16 on entry and at each event
u16 firstShortcut
The shortcuts' assignments.
Definition game_state.h:86
u16 secondShortcut
Definition game_state.h:87
u8 activeOwners[8]
the party in order
Definition game_state.h:60
s16 entrance
Definition game_state.h:37
u8 movementMode
1 while the leader is climbing, 0 otherwise
Definition game_state.h:57
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
s16 savedScene
where a defeat returns to without a defeat point
Definition game_state.h:38
s16 savedEntrance
where a defeat returns to without a defeat point
Definition game_state.h:39
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
void * animation
its sprite, or its list of four, by animationKind
u8 animationKind
Low four bits: 0 no sprite, 1 one sprite, 2 a group of up to four.
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
Definition field_scene.h:81
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
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
u16 y
tiles
Definition uiwindow.h:16
u16 height
tiles
Definition uiwindow.h:14
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
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