Alchemy
Loading...
Searching...
No Matches

vault.c

Go to the documentation of this file.
1/// @file
2/// Vault after the eruption, while Hammet's Shaman's Rod is missing and after
3/// the party has jailed the thieves.
4
5#include "game_state.h"
6#include "animspr.h"
7#include "window.h"
8#include "unit/scene/vault.h"
11#include "unit/object/object.h"
13#include "unit/battle/battle.h"
14#include "unit/game/game.h"
16#include "field_obj.h"
17#include "types.h"
18#include "field_event.h"
19#include "field_scene.h"
20#include "battle.h"
21#include "debug.h"
22#include "field.h"
23#include "game.h"
24#include "graphics.h"
25#include "menu.h"
26#include "minigame.h"
27#include "sound.h"
28#include "system.h"
29#include "tbs_edition.h"
30#include "battle_party.h"
31#include "text/msg_ids.h"
32#include "call.h"
34#include "iwram_call.h"
35#include "inventory.h"
36#include "b5_context.h"
37#include "ability_ids.h"
38#include "item_ids.h"
39#include "objcmd.h"
40#include "fixed_math.h"
41#include "flags.h"
42#include "character_ids.h"
43#include "songs.h"
44
45enum { VAULT_DRIFT_RATE = PIXELS(1) / 10 };
46
47/// The townspeople, named by what they say.
48enum {
49 ACTOR_GREETER = 8, ///< greets the party. "Welcome to Vault"
50 /// Asks about the eruption. "Wasn't the eruption of Mt. Aleph incredible?"
52 ACTOR_THEFT_GOSSIP = 11, ///< folks got robbed during the eruption
53 ACTOR_HAMMET_GOSSIP = 10, ///< Master Hammet had his precious rod stolen
54 ACTOR_IVAN_GOSSIP = 12, ///< Hammet's servant can't return to Kalay
55 /// Speaks of travelers. "Those travelers left in a big hurry."
57 /// The two who walk in circles.
60 /// Keeps watch. "Nobody's stealing anything on my watch!"
62 /// A thief. "Are you accusing us of stealing...?"
64 ACTOR_STRANDED_TRAVELER = 18, ///< was leaving town when the volcano erupted
66 ACTOR_ROOFER = 20, ///< a fiery rock burnt a hole through the roof
67 /// Complains of the roofer. "He should be fixing the roof now"
71};
72
73static void Vault_ShowStandingActorMessage(s32 actor);
74static void Vault_ShowMessageAndWait(s32 actor, s32 delay);
75static void Vault_FaceActorAndWait(s32 actor, s32 cue, s32 delay);
76
78#include "common/effect_spawn.h"
79
80#include "common/vault_nearby.h"
81
82// The roof complainer walks about looking for the roofer and stops to face
83// the leader when near, or while a conversation holds the field.
84// UB: calling this s32 function through a void update hook is incompatible.
85// Plain void changes 108 to 104 bytes in tbs-en.
86#ifdef UBFIX
87static void
89#else
91#endif
92 struct FieldActor *entity = (struct FieldActor *)fieldObject;
93 struct UiRenderWork *render = (struct UiRenderWork *)gWindowWork[0];
94 u8 *workspace = gWindowWork[12];
95 s32 flag = 0;
96 s32 selector = 18;
97 struct FieldActor *leader;
98
99 if (entity->targetX == ACTOR_NO_TARGET)
100#ifdef UBFIX
101 return;
102#else
103 return 0;
104#endif
105
107 if (*(s16 *)(workspace + 376) != 0 || render->mode != 0) {
108 selector = 26;
109 flag = 1;
110 }
111 Vault_StopIfFacingNear(entity, leader, selector, flag);
112#ifdef UBFIX
113 return;
114#else
115 return 0;
116#endif
117}
118
120 return gVault_Entrances;
121}
122
123const struct SceneRegion *Scene_GetRegions(void) { return NULL; }
124
125const u32 *Scene_GetExits(void) { return gVault_Exits; }
126
130 return gVault_Placements;
131}
132
133/// Counts the Venus Djinn that must leave Ivan before he leaves the party.
136}
137
138#include "common/vault_djinn.h"
139
140/// Exits 1 and 2 (triggers 20 and 21): while Ivan is helping search for the
141/// rod and the thieves are free, he walks out to the gate, says he is still
142/// worried about the rod and will wait in Vault, leaves any Venus Djinni with
143/// Isaac and leaves the party.
144static void Event_IvanStaysBehind(void) {
145 struct FieldActor *actor;
146 struct EventWork *eventWork;
147
148 eventWork = gEventWork;
152 return;
153 }
154 // Bring Ivan out beside the party at the exit they are using.
157 if (actor != 0) {
158 Actor_SetPosition(IVAN, actor->x.fixed, actor->z.fixed);
159 }
160 Actor_SetSpeed(IVAN, PIXELS(4) / 5, PIXELS(2) / 5);
161 if (eventWork->touchedTrigger == 20) {
162 Actor_WalkToAndWait(IVAN, 400, 448);
163 } else {
164 Camera_SetSpeed(PIXELS(4) / 5, PIXELS(1) / 10);
165 Camera_MoveTo(PIXELS(224), -1, PIXELS(162), 1);
166 Actor_WalkToAndWait(IVAN, 224, 162);
168 }
171 Engine_EventSetMessage(MsgVaultLeavingImStillWorriedAbout);
172 Event_ShowMessageAndWait(0x9002, 0, 20);
174 // Return any Djinn before removing Ivan from the party.
175 if (Vault_GetIvanVenusDjinnCount() != 0) {
176 Engine_EventSetMessage(MsgVaultWaitDontWantTakeYour);
179 Engine_TaskWait(20);
180 }
186}
187
188/// Isaac peers into the well and hears water rumbling down there.
189static void Event_PeerIntoWell(void) {
191 Engine_MessageShowCentered(MsgFieldPeeredWell, 1);
192 Engine_MessageShowCentered(MsgVaultCanHearWaterRumblingDown, 1);
194}
195
196const struct SceneEvent *Scene_GetEvents(void) {
199 return gVault_Events;
200}
201
202/// Asks the current question and selects its ordinary or alternate reply.
203static inline void Vault_AskYesNoAndShowReply(s32 speaker) {
204 Engine_EventOpenMessage(speaker, 0);
205 if (Engine_EventChooseYesNo(0, 0) != 0) {
206 struct EventWork *eventWork = gEventWork;
207
208 ++eventWork->message;
209 }
210 Engine_EventShowMessage(speaker, 0);
211}
212
213/// Asks about the eruption. "Wasn't the eruption of Mt. Aleph incredible?"
214/// Yes: too terrified to sleep for days. No: aren't you courageous!
215static void Event_AskAboutEruption(void) {
217 Engine_EventSetMessage(MsgVaultWasntEruptionMtAlephIncredible);
220 if (Engine_EventChooseYesNo(0, 0) != 0) {
222 }
226}
227
228/// Travelers left town in a big hurry: did the party see them? Yes: two women
229/// and four men, the girl and old man unhappy to be there. No: maybe they left
230/// earlier.
232
234 Engine_EventSetMessage(MsgVaultThoseTravelersLeftInBig);
239}
240
241/// One of the thieves asks whether the party accuses them; either answer gets a
242/// denial. "Are you accusing us of stealing Hammet's treasured Shaman's Rod?"
243static void Event_ThiefDeniesTheft(void) {
244
246 Engine_EventSetMessage(MsgVaultAccusingUsStealingHammetsTreasured);
250}
251
252/// Asks whether the party is off on an adventure. "Off on an adventure, are
253/// you?" Yes: impressive for youngsters. No: see the Sanctum while you're here.
254static void Event_AskAboutAdventure(void) {
255
257 Engine_EventSetMessage(MsgVaultOffOnAdventure);
261}
262
263/// Some folks got robbed during the chaos of the eruption.
264static void Event_TalkOfEruptionThefts(void) {
266 Engine_EventSetMessage(MsgVaultGuessFolksGot);
269}
270
271/// The watchman: nobody steals on his watch, the thieves must be from out of
272/// town.
275 Engine_EventSetMessage(MsgVaultNobodysStealingAnything);
278}
279
280/// The dog stops and barks.
281static void Event_TalkToDog(void) {
283 Engine_EventSetMessage(MsgVaultRuffRrruff);
288}
289
290/// The first walker stops: poor Ivan was left at the mayor's to look for the
291/// stolen rod.
292static void Event_PityIvan(void) {
294 s16 savedFacing = actor->facing;
295
296 actor->timer |= 2;
298 Engine_EventSetMessage(MsgVaultPoorGuyLeft);
302 actor->facing = savedFacing;
305 actor->timer &= 1;
306}
307
308/// The second walker stops: Hammet's caravan left as soon as the eruption
309/// stopped.
310static void Event_TalkOfHammetsCaravan(void) {
312 s16 savedFacing = actor->facing;
313
314 actor->timer |= 2;
316 Engine_EventSetMessage(MsgVaultMasterHammetsCaravan);
320 actor->facing = savedFacing;
323 actor->timer &= 1;
324}
325
326/// The roofer should be fixing the roof, but is probably in back slacking off.
327static void Event_LookForRoofer(void) {
329 Engine_EventSetMessage(MsgVaultFixingRoofCant);
335}
336
337/// Stops an actor, faces the leader and shows the current message.
341 Vault_FaceActorAndWait(actor, 0, 2);
342 Engine_EventShowMessage(actor, 0);
344}
345
346#include "common/vault_talk.h"
347
348/// After the thieves are jailed, asks whether the party is leaving again.
349/// "So, you're hitting the road again?"
350static void Event_AskAboutLeavingAgain(void) {
352 Engine_EventSetMessage(MsgVaultYoureHittingRoadAgain);
356}
357
358/// Praises the thieves' capture. "It's great that you caught those thieves!"
359static void Event_PraiseThievesCapture(void) {
361 Engine_EventSetMessage(MsgVaultGreatCaughtThieves);
364}
365
366/// Ivan went out to Lunpa, or, with Ivan in the party, rescuing Hammet must
367/// have been impossible.
368static void Event_TalkAboutIvan(void) {
369 struct EventWork *workspace;
371 Engine_EventSetMessage(MsgVaultTalkingAboutHammetsServantIvan);
372 // Flag 2 is set while Ivan is in the party.
374 workspace = gEventWork;
375 ++workspace->message;
376 }
379}
380
381/// The eruption devastated the roads; once the southern bridge is repaired,
382/// you can head toward Kalay.
383static void Event_TalkOfDamagedRoads(void) {
385 Engine_EventSetMessage(MsgVaultEruptionDevastatedRoads);
388}
389
390/// The first walker hopes Ivan didn't go to Lunpa alone, or, with Ivan in the
391/// party, asks when he joined up with Isaac.
394 s16 savedFacing = actor->facing;
395
396 actor->timer |= 2;
398 Engine_EventSetMessage(MsgVaultDidntGoLunpa);
404 actor->facing = savedFacing;
407 actor->timer &= 1;
408}
409
410/// The second walker: everyone is grateful the party captured the thieves.
413 s16 savedFacing = actor->facing;
414
415 actor->timer |= 2;
417 Engine_EventSetMessage(MsgVaultEveryoneGratefulCaptured);
421 actor->facing = savedFacing;
424 actor->timer &= 1;
425}
426
427/// Asks about the prisoners. "Those men you captured... They're in jail now?"
428/// Yes: the prison hadn't been used in a long time. No: they're upset; maybe go
429/// see them.
430static void Event_AskAboutPrisoners(void) {
432 Engine_EventSetMessage(MsgVaultThoseMenCapturedTheyreIn);
437}
438
439/// Asks who captured the thieves; either answer is praised.
440/// "Are you the ones who captured the thieves?"
443 Engine_EventSetMessage(MsgVaultOnesWhoCapturedThieves);
447}
448
449/// The dog barks; carrying a Bone before it has shown the passage lets the
450/// party give it one.
453 Engine_EventSetMessage(MsgVaultRuffRrruff2);
460 u16 *p = &gEventWork->unk172;
461 u16 value = 1;
462
463 *p = value;
464 }
466}
467
468/// Thanks the party before it leaves.
469/// "Thank you for the other day. Are you leaving town already?"
470static void Event_ThankBeforeDeparture(void) {
472 Engine_EventSetMessage(MsgVaultThankForOtherDayLeaving);
478}
479
480/// Mind Read: stealing during an eruption is unforgivable, or how should the
481/// prisoners be punished?
482static void Event_ReadMindOnTheft(void) {
485 Engine_EventSetMessage(MsgVaultManShouldStealFromAnother);
486 else
487 Engine_EventSetMessage(MsgVaultHowPunishPrisoners);
490}
491
492/// Mind Read: the strange travelers headed for the northeast of the Goma
493/// Range, or the only way out is the cave in the Goma Range.
494static void Event_ReadMindOnTravelers(void) {
497 Engine_EventSetMessage(MsgVaultGroupTravelersWasStrangeBunch);
498 } else {
499 Engine_EventSetMessage(MsgVaultWithRoadOutOnlyWay);
500 }
503}
504
505/// Mind Read on the first walker: the three creeps at the inn stole the rod,
506/// or where did Ivan go (when did they join him, with Ivan in the party)?
507static void Event_ReadMindOnIvan(void) {
511 Engine_EventSetMessage(MsgVaultBetWasThoseThreeCreeps);
512 } else {
513 Engine_EventSetMessage(MsgVaultWhereDidIvanGoBy);
516 }
520}
521
522/// Mind Read on the second walker: riches can't save you from a volcano, or the
523/// party must be stronger than they look.
524static void Event_ReadMindOnWealth(void) {
528 Engine_EventSetMessage(MsgVaultSupposeDoesntMatterHowRich);
529 else
530 Engine_EventSetMessage(MsgVaultMustStrongerThanLookHave);
534}
535
536/// Mind Read on the watchman: everyone knows the three at the inn stole the
537/// rod, or he feels much better with them behind bars.
538static void Event_ReadMindOnSuspects(void) {
541 Engine_EventSetMessage(MsgVaultEveryoneKnowsThoseThreeAt);
542 else
543 Engine_EventSetMessage(MsgVaultFeelMuchBetter);
546}
547
548/// Mind Read on the dog: humans value money over their lives; after the
549/// thieves are jailed, bring a bone for something useful, and once fed, a
550/// careful search will reveal a passage.
551static void Event_ReadDogMind(void) {
553 actor->paused = 1;
556 Engine_EventSetMessage(MsgVaultStealingInMidstVolcanicEruption);
560 Engine_EventSetMessage(MsgVaultCarefulSearchWillRevealPassage);
561 } else {
562 Engine_EventSetMessage(MsgVaultIfBringMeBoneIll);
563 }
566 actor->paused = 0;
567}
568
569/// Mind Read: that sneak is wasting time instead of fixing the roof.
570static void Event_ReadMindOnRoofer(void) {
572 Engine_EventSetMessage(MsgVaultSneakWastingTime);
575}
576
577#include "common/vault_toggle.h"
578
579/// Walks to the exit threshold and requests the room's transition.
580static void Vault_WalkThroughExit(s32 x, s32 y, s32 continuation) {
584 Engine_EventRequestExit(continuation);
585}
586
587/// Opens and enters the southeastern house.
588static void Event_EnterSoutheastHouse(void) {
591 Vault_WalkThroughExit(408, 320, 5);
592}
593
594/// Opens and enters the house east of the town's center.
598 Vault_WalkThroughExit(312, 304, 6);
599}
600
601/// Opens and enters the central house.
602static void Event_EnterCentralHouse(void) {
605 Vault_WalkThroughExit(216, 288, 7);
606}
607
608/// Enters the northeastern doorway behind its foreground tiles.
609static void Event_EnterNortheastHouse(void) {
611 struct AnimationObject *sprite = actor->sprite;
612
615 Map_CopyCellAttributes(33, 20, 1, 3, 23, 12);
617 sprite->image.priority = 3;
618 Vault_WalkThroughExit(376, 224, 8);
619}
620
621/// Enters the northern doorway behind its foreground tiles.
622static void Event_EnterNorthHouse(void) {
624 struct AnimationObject *sprite = actor->sprite;
625
628 Map_CopyCellAttributes(33, 20, 1, 3, 18, 10);
630 sprite->image.priority = 3;
631 Vault_WalkThroughExit(296, 176, 9);
632}
633
634/// Opens and enters the northwestern house.
635static void Event_EnterNorthwestHouse(void) {
638 Vault_WalkThroughExit(120, 144, 10);
639}
640
642
643/// The jail door opens and the party walks in, drawn behind the doorway.
644static void Event_EnterJail(void) {
646 struct AnimationObject *sprite = actor->sprite;
647
650 Map_CopyCellAttributes(33, 20, 1, 3, 4, 10);
652 sprite->image.priority = 3;
653 Vault_WalkThroughExit(72, 160, 12);
654}
655
656/// The party walks through the doorless entrance into the interiors (exit 13).
657static void Event_EnterPassage(void) {
659 Vault_WalkThroughExit(152, 264, 13);
660}
661
662/// Moves an actor through a jump and waits up to sixty frames for it to settle.
663static void Vault_JumpActorToAndWait(s32 actorId, s32 x, s32 z,
664 s32 verticalSpeed) {
665 struct FieldActor *actor = Object_GetById(actorId);
666 int frames;
667 Engine_ActorSetSpeed(actorId, PIXELS(3), PIXELS(3) / 2);
668 actor->gravity = PIXELS(1) / 2;
669 actor->bounce = 0;
670 actor->velocityY = verticalSpeed;
672 Engine_ActorMoveToAndWait(actorId, x, z);
673 Engine_ActorSetPosition(actorId, x << 16, z << 16);
674 for (frames = 60; frames != 0; --frames) {
676 if ((actor->velocityY >> 16) == 0)
677 break;
678 }
680 actor->gravity = PIXELS(1);
681}
682
683/// Isaac rings the bell; the first time, the Venus Djinni hiding nearby jumps
684/// out and comes to the bell.
685static void Event_RingBell(void) {
700 }
702}
703
704/// Given a Bone, the dog runs to the hidden passage and jumps there three
705/// times.
706static void Event_GiveBoneToDog(void) {
726}
727
728/// On arrival: restores the dog's and the Djinni's places, sets the walkers
729/// and the roof complainer stopping near the leader, and, while Ivan waits in
730/// Vault for the party, has him greet the two and rejoin.
732 s32 suspectsMindRead;
733 struct FieldActor *actor;
734 s32 lowBit;
735 s32 zero;
736
737 // Later in the story (flag 0x87a, set in Kalay and the Lamakan Desert) the
738 // town is replaced by its revisit scene.
741 }
742 // Restore the passage cells and the two walkers' proximity callbacks.
744 Map_CopyCellAttributes(55, 26, 4, 2, 23, 26);
745 }
747 lowBit = 1;
748 zero = 0;
750 actor->timer = lowBit;
751#ifdef UBFIX
753#else
754 actor->update = (void (*)(union FieldObject *))Vault_UpdateWalkingVillager;
755#endif
757 actor->timer = zero;
758#ifdef UBFIX
760#else
762#endif
765 }
768 if ((lowBit & suspectsMindRead) != 0) {
770#ifdef UBFIX
772#else
773 actor->update =
775#endif
776 }
777 }
778 // Back through the gates while Ivan waits in Vault: "Welcome back, you two!
779 // Let's go find the rod!"
780 if (gGameState.entrance <= 2) {
787 if (actor != 0) {
789 }
790 if (gGameState.entrance == 1) {
791 Actor_SetPosition(IVAN, PIXELS(400), PIXELS(448));
792 } else {
793 Actor_SetPosition(IVAN, PIXELS(224), PIXELS(162));
794 }
800 Engine_EventSetMessage(MsgVaultWelcomeBackTwo);
803 Actor_SetSpeed(IVAN, PIXELS(4) / 5, PIXELS(2) / 5);
806 if (actor != 0) {
808 actor->z.part.pixel);
809 }
814 }
815 }
816 }
817 }
820 }
821 // The same welcome at the western entrance (entrance 11) while Ivan is out of
822 // the party (flag 2 clear).
823 if (gGameState.entrance == 11) {
834 Engine_EventSetMessage(MsgVaultWelcomeBackTwo);
837 Actor_SetSpeed(IVAN, PIXELS(4) / 5, PIXELS(2) / 5);
840 if (actor != 0) {
842 actor->z.part.pixel);
843 }
848 }
849 }
850 }
852 } else {
853 if (gGameState.entrance == 13) {
856 }
857 }
858 }
859 return 0;
860}
861
863#include "common/vault_range.h"
864
867 Engine_EventWait(delay);
868}
869
870static void Vault_FaceActorAndWait(s32 actor, s32 cue, s32 delay) {
872 Engine_EventWait(delay);
873}
874
875/// Applies drift and gradually damps both rates toward zero.
876/// This custom update uses speed/acceleration as its two drift rates and
877/// mirrors the resulting position into the actor's target coordinates.
878static void Vault_UpdateDriftingEffect(union FieldObject *fieldObject) {
879 struct FieldActor *effect = (struct FieldActor *)fieldObject;
880 s32 horizontalRate;
881 s32 verticalRate;
882
883 effect->x.fixed += effect->speed;
884 effect->targetX = effect->x.fixed;
885
886 if (effect->timer != 0) {
887 effect->y.fixed += effect->acceleration;
888 effect->targetY = effect->y.fixed;
889 } else {
890 effect->z.fixed += effect->acceleration;
891 effect->targetZ = effect->z.fixed;
892 effect->y.fixed += PIXELS(1) / 64;
893 effect->targetY = effect->y.fixed;
894 }
895
896 horizontalRate = effect->speed;
897 effect->speed = horizontalRate - Math_Divide(horizontalRate, 28);
898 verticalRate = effect->acceleration;
899 effect->acceleration = verticalRate - Math_Divide(verticalRate, 28);
900}
901
902/// Spawns a drifting sprite near the dog, sharing its drawing priority.
904 struct FieldActor *anchor;
905 struct FieldActor *effect;
906 struct AnimationObject *sprite;
907 s32 x;
908 s32 z;
909 u8 zero;
910
911 anchor = (struct FieldActor *)Object_GetById(ACTOR_VAULT_DOG);
912 if (anchor == NULL)
913 return;
914 // Pick a small offset around the anchor and create the drifting sprite there.
917 x <<= 3;
918 x = (u32)x >> 16;
919 z <<= 3;
920 x -= 4;
921 z = (u32)z >> 16;
922 z -= 4;
923 x <<= 16;
924 z <<= 16;
925 {
926 s32 baseX = anchor->x.fixed;
927 s32 baseZ = anchor->z.fixed;
928 s32 baseY;
929
930 x += baseX;
931 baseY = anchor->y.fixed;
932 z += baseZ;
933 effect = (struct FieldActor *)Engine_ObjectCreate(0xac, x, baseY, z);
934 }
935 if (effect == NULL)
936 return;
937 sprite = effect->sprite;
938 switch (Engine_RandomNext() & 1) {
939 case 1:
940 Object_SetMode(effect, 3);
942 break;
943 default:
944 Object_SetMode(effect, 2);
946 break;
947 }
948 {
949 u8 *motionFlags = &effect->motionFlags;
950
951 zero = 0;
952 *motionFlags = zero;
953 }
954 // Choose either depth drift with a slow rise or vertical drift.
955 if (flags & 2) {
956 s32 driftMultiplier;
957 s32 directionBias;
958
959 driftMultiplier = (u32)Engine_RandomNext() % 10 + 5;
960 /* FAKEMATCH: reuse the coordinate local for the direction mask. With the
961 * literal 1, also as (flags ^ 1) << 2 or through a mask local of its own:
962 * differ 116. */
963 x = 1;
964 flags &= x;
965 directionBias = flags ^ x;
966 directionBias <<= 2;
967 driftMultiplier += directionBias;
968 effect->acceleration =
969 (2 * VAULT_DRIFT_RATE * flags - VAULT_DRIFT_RATE) * driftMultiplier;
970 driftMultiplier = (u32)Engine_RandomNext() % 15 - 7;
971 effect->speed = VAULT_DRIFT_RATE * driftMultiplier;
972 effect->timer = zero;
973 } else {
974 s32 driftMultiplier;
975
976 driftMultiplier = (u32)Engine_RandomNext() % 10 + 8;
977 effect->speed =
978 (2 * VAULT_DRIFT_RATE * flags - VAULT_DRIFT_RATE) * driftMultiplier;
979 driftMultiplier = (u32)Engine_RandomNext() % 14 + 1;
980 effect->acceleration = VAULT_DRIFT_RATE * driftMultiplier;
981 effect->timer = 1;
982 }
983 // Install the custom motion and share the anchor's drawing priority.
984 {
986 u8 *spriteFlags;
987
988 /* FAKEMATCH: preserve the sprite-flags address scheduling boundary. As
989 * plain stores, sprite->flags = 0 after the update pointer or through the
990 * pointer local: differ 2; the flags stored first: differ 4. */
991 do {
992 spriteFlags = &sprite->flags;
993 } while (0);
994 effect->update = update;
995 *spriteFlags = 0;
996 }
997 sprite->image.priority = anchor->sprite->image.priority;
998}
999
1001 SC_WAIT(1), SC_LOOP(22, SC_TOP), SC_WAIT(1),
1002 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
1003};
1004
1006 SC_WAIT(1), SC_LOOP(44, SC_TOP), SC_WAIT(1),
1007 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
1008};
1009
1011 SC_WAIT(1), SC_LOOP(126, SC_TOP), SC_WAIT(1),
1012 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
1013};
1014
1019};
1020
1022 SC_SET(SW_SPEED, PIXELS(2) / 5),
1023 SC_SET(SW_ACCEL, PIXELS(1) / 5),
1024 SC_LABEL(1),
1026 SC_ARG(2),
1027 SC_MOVE(PIXELS(168), 0, PIXELS(312)),
1028 SC_SYNC,
1029 SC_ARG(1),
1030 SC_WAIT(20),
1032 SC_WAIT(20),
1034 SC_WAIT(20),
1036 SC_WAIT(20),
1038 SC_WAIT(20),
1040 SC_WAIT(10),
1041 SC_ARG(4),
1042 SC_WAIT(240),
1044 SC_ARG(2),
1045 SC_MOVE(PIXELS(200), 0, PIXELS(312)),
1046 SC_SYNC,
1047 SC_ARG(1),
1048 SC_WAIT(20),
1050 SC_WAIT(20),
1052 SC_WAIT(20),
1054 SC_WAIT(20),
1056 SC_WAIT(20),
1058 SC_WAIT(10),
1059 SC_ARG(4),
1060 SC_WAIT(240),
1062 SC_END,
1063 SC_SET(SW_SPEED, PIXELS(2) / 5),
1064 SC_SET(SW_ACCEL, PIXELS(1) / 5),
1065 SC_SET(SW_COLLISION, 129),
1066 SC_SET(SW_RADIUS, 0x280000),
1067 SC_LABEL(1),
1068 SC_ARG(2),
1069 SC_WANDER_HOME(0x80000, 0x100000, 0x180000),
1070 SC_SYNC,
1071 SC_ARG(0),
1072 SC_WAIT(40),
1074 SC_END,
1075};
1076
1078 SC_ARG(2),
1079 SC_SET(SW_SPEED, PIXELS(4) / 5),
1080 SC_SET(SW_ACCEL, PIXELS(1) / 5),
1081 SC_LABEL(1),
1082 SC_MOVE(PIXELS(136), 0, PIXELS(376)),
1083 SC_SYNC,
1084 SC_MOVE(PIXELS(120), 0, PIXELS(376)),
1085 SC_SYNC,
1086 SC_MOVE(PIXELS(104), 0, PIXELS(392)),
1087 SC_SYNC,
1088 SC_MOVE(PIXELS(104), 0, PIXELS(408)),
1089 SC_SYNC,
1090 SC_MOVE(PIXELS(120), 0, PIXELS(424)),
1091 SC_SYNC,
1092 SC_MOVE(PIXELS(136), 0, PIXELS(424)),
1093 SC_SYNC,
1094 SC_MOVE(PIXELS(152), 0, PIXELS(408)),
1095 SC_SYNC,
1096 SC_MOVE(PIXELS(152), 0, PIXELS(392)),
1097 SC_SYNC,
1099 SC_END,
1100};
1101
1103 SC_ARG(2),
1104 SC_SET(SW_SPEED, PIXELS(4) / 5),
1105 SC_SET(SW_ACCEL, PIXELS(1) / 5),
1106 SC_LABEL(1),
1107 SC_MOVE(PIXELS(120), 0, PIXELS(424)),
1108 SC_SYNC,
1109 SC_MOVE(PIXELS(136), 0, PIXELS(424)),
1110 SC_SYNC,
1111 SC_MOVE(PIXELS(152), 0, PIXELS(408)),
1112 SC_SYNC,
1113 SC_MOVE(PIXELS(152), 0, PIXELS(392)),
1114 SC_SYNC,
1115 SC_MOVE(PIXELS(136), 0, PIXELS(376)),
1116 SC_SYNC,
1117 SC_MOVE(PIXELS(120), 0, PIXELS(376)),
1118 SC_SYNC,
1119 SC_MOVE(PIXELS(104), 0, PIXELS(392)),
1120 SC_SYNC,
1121 SC_MOVE(PIXELS(104), 0, PIXELS(408)),
1122 SC_SYNC,
1124 SC_END,
1125};
1126
1128 {0, CONDITION_ALWAYS, 223, 0, 135, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1129 {1, CONDITION_ALWAYS, 400, 0, 472, FACING_NORTH, 0, -1, -1, -1, -1, 0},
1130 {2, CONDITION_ALWAYS, 224, 0, 138, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1131 {5, CONDITION_ALWAYS, 408, 0, 344, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1132 {6, CONDITION_ALWAYS, 312, 0, 328, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1133 {7, CONDITION_ALWAYS, 216, 0, 312, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1134 {8, CONDITION_ALWAYS, 376, 0, 248, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1135 {9, CONDITION_ALWAYS, 296, 0, 200, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1136 {10, CONDITION_ALWAYS, 120, 0, 168, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1137 {11, CONDITION_ALWAYS, 64, 0, 294, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1138 {12, CONDITION_ALWAYS, 70, 0, 183, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1139 {13, CONDITION_ALWAYS, 152, 0, 272, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1141};
1142
1147 SCENE_EXIT(5, 21, 5),
1148 SCENE_EXIT(6, 21, 6),
1149 SCENE_EXIT(7, 21, 7),
1150 SCENE_EXIT(8, 21, 8),
1151 SCENE_EXIT(9, 21, 9),
1152 SCENE_EXIT(10, 21, 10),
1153 SCENE_EXIT(11, 9, 10),
1155 SCENE_EXIT(13, 21, 13),
1158};
1159
1160// clang-format off
1163 0, 0, 0, FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1167 PIXELS(280), 0, PIXELS(396), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1171 PIXELS(244), 0, PIXELS(204), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1173 PIXELS(124), 0, PIXELS(196), FACING_SOUTHEAST, TALK_FACE_PARTY, 0 },
1177 PIXELS(132), 0, PIXELS(380), FACING_WEST, TALK_KEEP_FACING, 0 },
1179 PIXELS(132), 0, PIXELS(420), FACING_EAST, TALK_KEEP_FACING, 0 },
1187 PIXELS(216), 0, PIXELS(392), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1191 PIXELS(168), 0, PIXELS(312), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1192 { 0xf8, CONDITION_ALWAYS, 7,
1193 0, 0, 0, FACING_NORTH, TALK_FACE_PARTY, 0 },
1195 PIXELS(344), 0, PIXELS(96), FACING_SOUTH, TALK_FACE_PARTY, 0 },
1196 { SCENE_TABLE_END },
1197};
1198
1207 PIXELS(244), 0, PIXELS(204), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1209 PIXELS(124), 0, PIXELS(196), FACING_SOUTHEAST, TALK_FACE_PARTY, 0 },
1213 PIXELS(132), 0, PIXELS(380), FACING_WEST, TALK_KEEP_FACING, 0 },
1215 PIXELS(132), 0, PIXELS(420), FACING_EAST, TALK_KEEP_FACING, 0 },
1219 0, 0, 0, FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1223 PIXELS(216), 0, PIXELS(440), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1227 PIXELS(168), 0, PIXELS(312), FACING_SOUTH + FACING_STEP, TALK_FACE_PARTY, 0 },
1228 { 0xf8, CONDITION_ALWAYS, 7,
1229 0, 0, 0, FACING_NORTH, TALK_FACE_PARTY, 0 },
1231 PIXELS(344), 0, PIXELS(96), FACING_SOUTH, TALK_FACE_PARTY, 0 },
1232 { SCENE_TABLE_END },
1233};
1234
1249 { EVENT_TALK, ACTOR_GREETER, CONDITION_ALWAYS, MSGNO(MsgVaultWelcomeToVaultTheTownAt) },
1251 { EVENT_TALK, ACTOR_HAMMET_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultMasterHammetAWealthyLandownerAnd) },
1253 { EVENT_TALK, ACTOR_IVAN_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultMasterHammetsServantCantReturnTo) },
1261 { EVENT_TALK, ACTOR_ROOFER, CONDITION_ALWAYS, MSGNO(MsgVaultAFieryRockBurntAHole) },
1263 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_GREETER, CONDITION_ALWAYS, MSGNO(MsgVaultISupposeTheseChildrenCantGo) },
1264 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_ERUPTION_WITNESS, CONDITION_ALWAYS, MSGNO(MsgVaultMtAlephsEruptionWasBeyondDescription) },
1265 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_HAMMET_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultWhyDoesAWealthyManLike) },
1267 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_IVAN_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultPoorIvanButTheRodMay) },
1272 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_LOITERING_THIEF, CONDITION_ALWAYS, MSGNO(MsgVaultHmphItLooksLikeTheyreOnto) },
1273 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_STRANDED_TRAVELER, CONDITION_ALWAYS, MSGNO(MsgVaultIWasJustAboutToLeave) },
1275 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_ROOFER, CONDITION_ALWAYS, MSGNO(MsgVaultFixTheRoofWhyPayFor) },
1280 { SCENE_EVENTS_END },
1281};
1282
1298 { EVENT_TALK, ACTOR_ERUPTION_WITNESS, CONDITION_ALWAYS, MSGNO(MsgVaultSmokeIsStillRisingFromMt) },
1299 { EVENT_TALK, ACTOR_HAMMET_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultMasterHammetTheWealthyMerchantI) },
1309 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_GREETER, CONDITION_ALWAYS, MSGNO(MsgVaultYouveMadeOurTownPeacefulAt) },
1310 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_ERUPTION_WITNESS, CONDITION_ALWAYS, MSGNO(MsgVaultNowMtAlephHasCalmedDown) },
1311 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_HAMMET_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultOfAllThePlacesWhyWould) },
1313 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_IVAN_GOSSIP, CONDITION_ALWAYS, MSGNO(MsgVaultNobodyGetsIntoLunpaExceptFor) },
1318 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_STRANDED_TRAVELER, CONDITION_ALWAYS, MSGNO(MsgVaultThereIsAlwaysAFightWhen) },
1320 { PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), ACTOR_ROOFER, CONDITION_ALWAYS, MSGNO(MsgVaultSniffAhTheSmellOfCooking) },
1325 { SCENE_EVENTS_END },
1326};
1327// clang-format on
1328
1330 MAP_CELL_STEP(35, 52, 2, 2, 4),
1331 MAP_CELL_STEP(33, 52, 2, 2, 4),
1333};
1334
1336 MAP_CELL_STEP(35, 50, 2, 2, 4),
1337 MAP_CELL_STEP(33, 50, 2, 2, 4),
1339};
1340
1342 MAP_CELL_STEP(35, 48, 2, 2, 4),
1343 MAP_CELL_STEP(33, 48, 2, 2, 4),
1345};
1346
1348 MAP_CELL_STEP(42, 48, 2, 2, 4),
1349 MAP_CELL_STEP(40, 48, 2, 2, 4),
1351};
1352
1354 MAP_CELL_STEP(42, 46, 2, 2, 4),
1355 MAP_CELL_STEP(40, 46, 2, 2, 4),
1357};
1358
1360 MAP_CELL_STEP(35, 46, 2, 2, 4),
1361 MAP_CELL_STEP(33, 46, 2, 2, 4),
1363};
1364
1366 MAP_CELL_STEP(35, 33, 2, 2, 4),
1367 MAP_CELL_STEP(33, 33, 2, 2, 4),
1369};
1370
1372 SC_WAIT(1),
1373 SC_LOOP(118, SC_TOP),
1374 SC_FREE,
1375};
1376
1378 SC_WAIT(1),
1379 SC_LOOP(38, SC_TOP),
1380 SC_FREE,
1381};
Ability numbers, named from the English release.
@ ABILITY_MIND_READ
Definition ability_ids.h:16
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
const struct ScenePlacement * Scene_GetPlacements(void)
const struct SceneEntrance * Scene_GetEntrances(void)
const struct SceneEvent * Scene_GetEvents(void)
const u32 * Scene_GetExits(void)
Both scenes share one exit table.
const struct SceneRegion * Scene_GetRegions(void)
s32 Scene_Initialize(void)
Sets up whichever scene is being entered and runs its arrival events.
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
B5Context, the object context a battle routine reads; most of its fields are still unnamed.
s32 gEffectScript0[]
const s32 * gEffectScripts[]
s32 gEffectScript1[]
s32 gEffectScript2[]
Which units are in a battle, and the Djinn recovery list.
@ ELEMENT_VENUS
Definition battle_unit.h:36
Calls through a function pointer, by argument count.
Character numbers, with each character's Japanese name.
#define IVAN
Ivan.
void Engine_ActorSetSpriteFlags(struct FieldActor *, s32)
struct FieldActor * Engine_ObjectCreate(s32, s32, s32, s32)
The engine calls the debug menus import, and their palette swatch tiles.
static UNUSED void * OverlayObject_CreateConfiguredObject(s32 x, s32 y, s32 z, s32 type)
A still effect in palette 15, at sprite priority 1, drawn under the actors.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
@ ANIM_WALK
Definition field_event.h:44
@ ANIM_STAND
Definition field_event.h:43
@ ANIM_NOD
Definition field_event.h:45
static s32 Event_OpenMessage(s32 speaker, s32 flags)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
static void Event_ShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_MessageShowCentered(s32 message, s32 flags)
void Engine_EventShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
#define GameFlag_IsSet
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
static void Camera_SetSpeed(s32 speed, s32 acceleration)
void Engine_ActorMoveToAndWait(s32 actor, s32 x, s32 z)
void Engine_ActorJump(s32 actor, s32 height, s32 frames)
#define MAP_CELL_STEP(srcX, srcY, width, height, frames)
Definition field_event.h:59
void Engine_ActorSetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_EventCloseScreen(void)
void Engine_ActorSetDestination(s32 actor, s32 x, s32 z)
static void Actor_WalkTo(s32 actor, s32 x, s32 z)
void Engine_EventWaitForScreen(void)
#define GameFlag_Set
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
static s32 Math_Divide(s32 dividend, s32 divisor)
void Engine_EventOpenScreen(void)
s32 Engine_EventOpenMessage(s32 speaker, s32 flags)
void Engine_GameFlagClear(s32 flag)
void Engine_CameraWaitForMove(void)
void Engine_ActorWaitForMove(s32 actor)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
s32 Engine_RandomNext()
static void Event_PlayCue(s32 cue)
#define MAP_CELL_STEPS_END
Definition field_event.h:61
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_MapAnimateCells(const u16 *steps, s32 destX, s32 destY)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_ActorFaceEachOther(s32 actor, s32 other, s32 frames)
void Engine_EventWait(s32 frames)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
static struct FieldActor * Actor_Get(s32 actor)
Field objects and actors, and the scene transition styles.
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
Definition field_obj.h:153
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
Definition field_obj.h:145
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EVENTS_END
#define FIND_ITEM(item)
@ EVENT_TOUCH
@ EVENT_TALK
@ FACING_STEP
Definition field_scene.h:36
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#define IF_FLAG_SET(flag)
Definition field_scene.h:48
@ SCENE_VAULT
Definition field_scene.h:14
@ SCENE_VAULT_JAIL
Definition field_scene.h:15
@ SCENE_VAULT_REVISIT
Definition field_scene.h:16
@ SCENE_WORLD_MAP
Definition field_scene.h:13
#define SCENE_EXIT(exit, scene, entrance)
Definition field_scene.h:73
@ ACTOR_PARTY_LEADER
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ TALK_KEEP_FACING
@ TALK_FACE_PARTY
@ TALK_FACE_PARTY_AND_BACK
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
#define USE_ITEM_ON_ACTOR(item)
@ ACTOR_WANDER
@ ACTOR_STAND
#define SEARCH(target)
#define SCENE_EXITS_END
Definition field_scene.h:77
#define TOUCH_WALKING_INTO(facing)
@ FACING_EAST
Definition field_scene.h:26
@ FACING_SOUTHEAST
Definition field_scene.h:27
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_NORTHWEST
Definition field_scene.h:31
@ FACING_SOUTH
Definition field_scene.h:28
@ FACING_WEST
Definition field_scene.h:30
#define PIXELS(value)
@ SEARCH_WOODEN_BOX
@ SEARCH_UNNAMED
16.16 fixed-point constants, sine and cosine, and the library division.
FixedPointPosition, a position in 16.16 fixed point.
Game flags, named where their meaning is shown.
#define FLAG_VAULT_IVAN_JOINED_ROD_SEARCH
Set when the party agrees to help Ivan find the rod; while it is set and the thieves are free,...
Definition flags.h:554
#define FLAG_SHOW_LOCATION_NAME
Definition flags.h:94
#define FLAG_VAULT_BOX_NUT
Definition flags.h:563
#define FLAG_VAULT_SUSPECTS_MIND_READ
Set once Ivan has read the minds of the two cornered suspects.
Definition flags.h:556
#define FLAG_VAULT_DJINNI_CALLED_BY_BELL
Definition flags.h:109
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
Definition flags.h:15
#define FLAG_VAULT_THIEVES_JAILED
Definition flags.h:106
#define FLAG_VAULT_DOG_SHOWN_PASSAGE
Definition flags.h:107
#define FLAG_REACHED_KALAY
Set whenever Kalay is entered; Vale's villagers then talk of the party's journey.
Definition flags.h:441
#define FLAG_IN_PARTY(character)
Flags 0 to 7: the character with that id (character_ids.h) is in the party (Party_AddActiveOwner).
Definition flags.h:9
#define FLAG_SCENE_TEMP_00
Definition flags.h:713
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
#define FLAG_VAULT_THIEVES_CONFRONTED
Set as the three thieves are confronted in the attic, before the battle.
Definition flags.h:558
GameState, the game's state: play time, coins, the scene and the leader's position,...
struct GameState gGameState
The screen blend's globals and the graphics routines.
@ ACTOR_GREETER
Definition imil.c:53
s32 PartyInventory_Discard(s32 itemId)
Discards one itemId from whoever carries it first, as Inventory_Discard does; always returns 0.
Definition inventory.c:422
s32 PartyInventory_FindOwner(s32 itemId)
Returns who carries itemId, asking the selected character first, or -1.
Definition inventory.c:229
gOverflowItem, an item slot the spoils code uses when items are handed out.
Item numbers, named from the English release.
@ ITEM_BONE
Definition item_ids.h:72
@ ITEM_NUT
Definition item_ids.h:41
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_LABEL(n)
Branch destination.
Definition objcmd.h:11
#define SC_SET(w, v)
Write a work value.
Definition objcmd.h:37
#define SC_LOOP(n, to)
Repeat up to n times.
Definition objcmd.h:28
#define SC_POS(x, y, z)
Set position.
Definition objcmd.h:18
#define SC_FREE
Release.
Definition objcmd.h:43
#define SC_SYNC
Wait for arrival.
Definition objcmd.h:17
#define SC_FOREVER
Definition objcmd.h:14
#define SC_WANDER_HOME(a, b, c)
Definition objcmd.h:25
#define SC_TO(n)
Definition objcmd.h:12
#define SC_ARG(v)
Definition objcmd.h:44
#define SC_MOVE(x, y, z)
Move toward the target.
Definition objcmd.h:19
#define SC_WAIT(n)
Wait n frames.
Definition objcmd.h:16
#define SC_TOP
Script start.
Definition objcmd.h:13
#define SC_END
Return to the main script.
Definition objcmd.h:32
@ SW_ACCEL
Definition objcmd.h:68
@ SW_COLLISION
Definition objcmd.h:79
@ SW_SPEED
Definition objcmd.h:67
@ SW_FACING
Definition objcmd.h:57
@ SW_RADIUS
Definition objcmd.h:61
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_PrepareObjectAndApplyValue(s32 unit, s32 announce)
Adds unit to the party.
Definition events.c:165
Song and sound effect ids, indices into gSound_SongTable.
#define SE_DOOR_OPEN
Definition songs.h:153
#define SE_MAP_EXIT
Definition songs.h:116
#define SE_100
Definition songs.h:93
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void Engine_TaskWait()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
#define NULL
Definition bilibin.h:6
Vault, before and after the thieves are caught: villagers who walk about stop when someone is close i...
s32 Vault_StopIfFacingNear(struct FieldActor *actor, struct FieldActor *target, s32 range, s32 force)
Stops the actor (paused, mode 1) when the target is nearer than range pixels and lies ahead of it,...
Definition vault_range.h:11
u8 gWindowWork[]
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
struct AnimationSpritePart image
Definition animspr.h:109
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
Definition animspr.h:128
u16 priority
2 when created
Definition animspr.h:100
u8 djinnOwnedCounts[4]
the Djinn held in each element, at most 10
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
Definition event_work.h:20
s16 touchedTrigger
the step event a touch or exit event answers
Definition event_work.h:26
u16 unk172
FieldWork's menu request; scenes set it to 1.
Definition event_work.h:29
s32 transitionFrames
frames
Definition event_work.h:45
u16 message
the next message, advanced as each window opens
Definition event_work.h:47
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s16 timer
The parameter its action script reads (a follow distance or an angle to face), the player's frames to...
Definition field_obj.h:109
s32 speed
speed limit, 16.16 fixed-point pixels per frame
Definition field_obj.h:55
s32 targetX
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:59
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
Definition field_obj.h:83
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
s32 targetZ
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:61
u8 paused
nonzero skips its script and motion, not its update
Definition field_obj.h:93
s32 bounce
The share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created)...
Definition field_obj.h:64
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
Definition field_obj.h:51
s32 velocityY
16.16 fixed-point pixels per frame
Definition field_obj.h:53
s32 gravity
Taken off the vertical velocity each frame while it is above the ground, in 16.16 fixed-point pixels ...
Definition field_obj.h:68
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
u16 facing
1/65536 turns
Definition field_obj.h:34
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
Definition field_obj.h:58
s32 targetY
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:60
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
Definition field_obj.h:116
void(*) update(union FieldObject *object)
Called each frame while the effect is live: the spawner sets BattleFx_UpdateObjectMotionScaleAndLinke...
s16 entrance
Definition game_state.h:37
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
Definition field_scene.h:54
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
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
The window system's work: the windows' tilemap, the windows, the three text channels,...
Definition window.h:19
u8 mode
Set while Mind Read shows thoughts: round frame corners, colour 8 text with no shadow,...
Definition window.h:35
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
Values that differ by patch level or language, chosen once for their code.
The integer types, TRUE, UNUSED and the fixed-address macros.
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
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
struct FieldActor actor
struct FieldEffect effect
struct BattleUnit * UnitGet(u32 owner)
Returns the unit record of owner: 0 to 7 are the playable characters in the game state,...
Definition units.c:73
static void Event_EnterCentralHouse(void)
Animates the central house door before entering.
Definition vale.c:324
static void Event_EnterSoutheastHouse(void)
Opens the southeastern door and enters its interior.
Definition vale.c:359
static void Event_GiveBoneToDog(void)
Given a Bone, the dog runs to the hidden passage and jumps there three times.
Definition vault.c:706
static void Event_ReadMindOnTheft(void)
Mind Read: stealing during an eruption is unforgivable, or how should the prisoners be punished?
Definition vault.c:482
static void Event_TalkOfEruptionThefts(void)
Some folks got robbed during the chaos of the eruption.
Definition vault.c:264
static void Event_ThankBeforeDeparture(void)
Thanks the party before it leaves.
Definition vault.c:470
u32 gVault_Exits[]
Definition vault.c:1143
static void Event_AskAboutFleeingTravelers(void)
Travelers left town in a big hurry: did the party see them?
Definition vault.c:231
s32 gVault_DriftScriptA[]
Definition vault.c:1371
u16 gVault_Scene10Cells[]
Definition vault.c:1359
static void Event_TalkToDogAfterCapture(void)
The dog barks; carrying a Bone before it has shown the passage lets the party give it one.
Definition vault.c:451
static void Event_ReadMindOnSuspects(void)
Mind Read on the watchman: everyone knows the three at the inn stole the rod, or he feels much better...
Definition vault.c:538
static void Event_EnterNorthwestHouse(void)
Opens and enters the northwestern house.
Definition vault.c:635
static void Event_TalkToDog(void)
The dog stops and barks.
Definition vault.c:281
static void Event_EnterPassage(void)
The party walks through the doorless entrance into the interiors (exit 13).
Definition vault.c:657
static void Event_ReadMindOnIvan(void)
Mind Read on the first walker: the three creeps at the inn stole the rod, or where did Ivan go (when ...
Definition vault.c:507
s32 gVault_DriftScriptB[]
Definition vault.c:1377
static void Event_RingBell(void)
Isaac rings the bell; the first time, the Venus Djinni hiding nearby jumps out and comes to the bell.
Definition vault.c:685
static void Vault_JumpActorToAndWait(s32 actorId, s32 x, s32 z, s32 verticalSpeed)
Moves an actor through a jump and waits up to sixty frames for it to settle.
Definition vault.c:663
static void Event_ReadMindOnWealth(void)
Mind Read on the second walker: riches can't save you from a volcano, or the party must be stronger t...
Definition vault.c:524
static void Event_AskAboutEruption(void)
Asks about the eruption.
Definition vault.c:215
static void Event_PityIvan(void)
The first walker stops: poor Ivan was left at the mayor's to look for the stolen rod.
Definition vault.c:292
static void Vault_AskYesNoAndShowReply(s32 speaker)
Asks the current question and selects its ordinary or alternate reply.
Definition vault.c:203
s32 gVault_Actor0[]
Definition vault.c:1077
static void Event_PraiseThievesCapture(void)
Praises the thieves' capture. "It's great that you caught those thieves!".
Definition vault.c:359
static void Event_TalkOfHammetsCaravan(void)
The second walker stops: Hammet's caravan left as soon as the eruption stopped.
Definition vault.c:310
static void Event_EnterNortheastHouse(void)
Enters the northeastern doorway behind its foreground tiles.
Definition vault.c:609
static void Event_PeerIntoWell(void)
Isaac peers into the well and hears water rumbling down there.
Definition vault.c:189
u16 gVault_Scene5Cells[]
Definition vault.c:1329
static void Event_EnterNorthHouse(void)
Enters the northern doorway behind its foreground tiles.
Definition vault.c:622
static UNUSED void Vault_SpawnDriftingEffect(s32 flags)
Spawns a drifting sprite near the dog, sharing its drawing priority.
Definition vault.c:903
static void Event_ThankForCapturingThieves(void)
The second walker: everyone is grateful the party captured the thieves.
Definition vault.c:411
u16 gVault_Scene9Cells[]
Definition vault.c:1353
static void Vault_FaceActorAndWait(s32 actor, s32 cue, s32 delay)
Definition vault.c:870
struct SceneEvent gVault_Events[]
Definition vault.c:1235
u16 gVault_Scene6Cells[]
Definition vault.c:1335
u16 gVault_Scene12Cells[]
Definition vault.c:1365
static void Event_ReadMindOnRoofer(void)
Mind Read: that sneak is wasting time instead of fixing the roof.
Definition vault.c:570
s32 gVault_Actor1[]
Definition vault.c:1102
struct ScenePlacement gVault_PlacementsAfterThieves[]
Definition vault.c:1199
static void Event_AskAboutAdventure(void)
Asks whether the party is off on an adventure.
Definition vault.c:254
@ VAULT_DRIFT_RATE
Definition vault.c:45
static void Event_ReadDogMind(void)
Mind Read on the dog: humans value money over their lives; after the thieves are jailed,...
Definition vault.c:551
static void Event_AskWhetherIvanWentToLunpa(void)
The first walker hopes Ivan didn't go to Lunpa alone, or, with Ivan in the party, asks when he joined...
Definition vault.c:392
static void Vault_ShowStandingActorMessage(s32 actor)
Stops an actor, faces the leader and shows the current message.
Definition vault.c:338
static void Vault_ShowMessageAndWait(s32 actor, s32 delay)
Definition vault.c:865
static void Event_TalkAboutIvan(void)
Ivan went out to Lunpa, or, with Ivan in the party, rescuing Hammet must have been impossible.
Definition vault.c:368
static void Event_WatchmanSuspectsOutsiders(void)
The watchman: nobody steals on his watch, the thieves must be from out of town.
Definition vault.c:273
static void Event_LookForRoofer(void)
The roofer should be fixing the roof, but is probably in back slacking off.
Definition vault.c:327
static void Event_TalkOfDamagedRoads(void)
The eruption devastated the roads; once the southern bridge is repaired, you can head toward Kalay.
Definition vault.c:383
u16 gVault_Scene8Cells[]
Definition vault.c:1347
static void Event_AskWhoCapturedThieves(void)
Asks who captured the thieves; either answer is praised.
Definition vault.c:441
static void Vault_WalkThroughExit(s32 x, s32 y, s32 continuation)
Walks to the exit threshold and requests the room's transition.
Definition vault.c:580
static int Vault_GetIvanVenusDjinnCount(void)
Counts the Venus Djinn that must leave Ivan before he leaves the party.
Definition vault.c:134
static void Event_ReadMindOnTravelers(void)
Mind Read: the strange travelers headed for the northeast of the Goma Range, or the only way out is t...
Definition vault.c:494
struct SceneEntrance gVault_Entrances[]
Definition vault.c:1127
s32 gVault_Actor2[]
Definition vault.c:1021
static void Event_EnterCentralEastHouse(void)
Opens and enters the house east of the town's center.
Definition vault.c:595
static void Event_AskAboutPrisoners(void)
Asks about the prisoners.
Definition vault.c:430
static void Event_EnterJail(void)
The jail door opens and the party walks in, drawn behind the doorway.
Definition vault.c:644
static void Event_ThiefDeniesTheft(void)
One of the thieves asks whether the party accuses them; either answer gets a denial.
Definition vault.c:243
struct SceneEvent gVault_EventsAfterThieves[]
Definition vault.c:1283
static void Event_IvanStaysBehind(void)
Exits 1 and 2 (triggers 20 and 21): while Ivan is helping search for the rod and the thieves are free...
Definition vault.c:144
struct ScenePlacement gVault_Placements[]
Definition vault.c:1161
@ ACTOR_ERUPTION_WITNESS
Asks about the eruption. "Wasn't the eruption of Mt. Aleph incredible?".
Definition vault.c:51
@ ACTOR_STRANDED_TRAVELER
was leaving town when the volcano erupted
Definition vault.c:64
@ ACTOR_VAULT_VENUS_DJINNI
Definition vault.c:69
@ ACTOR_WATCHMAN
Keeps watch. "Nobody's stealing anything on my watch!".
Definition vault.c:61
@ ACTOR_ROOFER
a fiery rock burnt a hole through the roof
Definition vault.c:66
@ ACTOR_HAMMET_GOSSIP
Master Hammet had his precious rod stolen.
Definition vault.c:53
@ ACTOR_TRAVELER_WATCHER
Speaks of travelers. "Those travelers left in a big hurry.".
Definition vault.c:56
@ ACTOR_SECOND_WALKER
Definition vault.c:59
@ ACTOR_THEFT_GOSSIP
folks got robbed during the eruption
Definition vault.c:52
@ ACTOR_ROOF_COMPLAINER
Complains of the roofer. "He should be fixing the roof now".
Definition vault.c:68
@ ACTOR_LOITERING_THIEF
A thief. "Are you accusing us of stealing...?".
Definition vault.c:63
@ VAULT_VENUS_DJINNI_INDEX
Definition vault.c:70
@ ACTOR_VAULT_DOG
Definition vault.c:65
@ ACTOR_FIRST_WALKER
The two who walk in circles.
Definition vault.c:58
@ ACTOR_IVAN_GOSSIP
Hammet's servant can't return to Kalay.
Definition vault.c:54
u16 gVault_Scene7Cells[]
Definition vault.c:1341
static void Vault_UpdateDriftingEffect(union FieldObject *fieldObject)
Applies drift and gradually damps both rates toward zero.
Definition vault.c:878
static void Event_AskAboutLeavingAgain(void)
After the thieves are jailed, asks whether the party is leaving again.
Definition vault.c:350
static s32 Vault_UpdateRoofComplainerProximity(union FieldObject *fieldObject)
Definition vault.c:90
Vault and its interiors: Ivan hands back Isaac's Djinni before he leaves the party.
static s32 Vault_ReturnIsaacsDjinni(void)
Brings every Djinni back from recovery (twenty rounds of it), then, if Ivan holds the first Venus Dji...
Definition vault_djinn.h:18
Vault, before and after the thieves are caught: the two villagers who walk about together (actors 14 ...
static s32 Vault_UpdateWalkingVillager(union FieldObject *fieldObject)
Vault, before and after the thieves are caught: the doorway of exit 11, which opens in two frames as ...
static void Vault_OpenDoorwayAndEnter(void)
Walking north into cell code 11 opens the doorway to the Sanctum.
Vault and its interiors: a villager's thought read with Mind Read.
static void Vault_ShowThought(s32 actorId)
Shows the message already set as the actor's thought: the actor stops and stands while the thought is...
Definition vault_talk.h:9
Vault, before and after the thieves are caught: touch triggers 1 and 2 swap the collision of the 4x2 ...
static void Vault_RestorePassageCells(void)
Cell code 2 restores the passage's usual collision and clears FLAG_SCENE_TEMP_00.
static void Vault_EnableAlternatePassageCells(void)
Cell code 1 selects the passage's alternate collision and sets FLAG_SCENE_TEMP_00,...
The window renderer's work.