Alchemy
Loading...
Searching...
No Matches

bilibin_cave.c

Go to the documentation of this file.
1/// @file
2/// The cave that leads past Bilibin, in three sections walked in turn: the
3/// entrance section (BilibinCave3) with a Growth plant, the middle section
4/// (BilibinCave2) with Reveal and Douse, and the exit section (BilibinCave1),
5/// a puzzle of Douse, Frost and pushed actors.
6
7#include "script.h"
8#include "game_state.h"
9#include "engine_call.h"
10#include "scene_ids.h"
11#include "unit/import.h"
13#include "unit/object/object.h"
15#include "unit/field/field.h"
16#include "battle.h"
17#include "debug.h"
18#include "field.h"
19#include "game.h"
20#include "graphics.h"
21#include "menu.h"
22#include "minigame.h"
23#include "sound.h"
24#include "system.h"
25#include "global_cells.h"
26#include "map.h"
27#include "types.h"
28#include "field_event.h"
29#include "field_scene.h"
30#include "ability_ids.h"
31#include "item_ids.h"
32#include "objcmd.h"
33#include "field_obj.h"
34#include "flags.h"
35#include "songs.h"
36
37// The entry points dispatch to the section-specific setup routines below.
38static void BilibinCave_RestoreGrowthSection(void);
39static void BilibinCave_RestoreDouseSection(void);
41static void BilibinCave_EmptyActorSetupHook(s32 actorId);
42
43/// Actors of the entrance section, named by the Psynergy that works on them.
44enum { GROWTH_TARGET = 8 };
45
46/// Actors of the middle section.
48
49/// Actors of the exit section.
50enum {
52 PUSHED_ACTOR_A = 11, ///< moved by Move or pushed
54 FROST_TARGET_A = 15, ///< walkable once the Douse target is gone
56 FROST_TARGET_C = 17 ///< changes as a pushed actor reaches cell (35, 23)
57};
58
59/// Clears the scripted actor's sprite flags and completes this script command.
61 struct ScriptInterpreter *interpreter) {
62 struct FieldActor *actor = (struct FieldActor *)interpreter;
64 return 0;
65}
66
68 s16 scene = gGameState.scene;
69
70 if (scene == (s32)&SceneId_BilibinCave3) {
72 }
73 if (scene == (s32)&SceneId_BilibinCave2) {
75 }
76 if (scene == (s32)&SceneId_BilibinCave1) {
78 }
80}
81
82const struct SceneRegion *BilibinCave_GetRegions(void) { return NULL; }
83
85
87 s16 scene = gGameState.scene;
88
89 if (scene == (s32)&SceneId_BilibinCave3) {
91 }
92 if (scene == (s32)&SceneId_BilibinCave2) {
94 }
95 if (scene == (s32)&SceneId_BilibinCave1) {
97 }
99}
100
102 s16 scene = gGameState.scene;
103
104 if (scene == (s32)&SceneId_BilibinCave3) {
105 return gBilibinCaveEvents3;
106 }
107 if (scene == (s32)&SceneId_BilibinCave2) {
108 return gBilibinCaveEvents2;
109 }
110 if (scene == (s32)&SceneId_BilibinCave1) {
111 return gBilibinCaveEvents1;
112 }
114}
115
116/// Replaces the crossing cell with the attributes at source cell (1, 0).
117static void Event_AlterCrossingCell(void) {
118 Map_CopyCellAttributes(1, 0, 1, 1, 21, 14);
119}
120
121/// Restores the crossing cell from source cell (0, 0).
122static void Event_RestoreCrossingCell(void) {
123 Map_CopyCellAttributes(0, 0, 1, 1, 21, 14);
124}
125
126/// Replaces the narrow tile strip and its two-row collision rectangle.
127static void Event_RevealHiddenPath(void) {
128 {
129 s32 width = 1;
130 s32 height = 3;
131
132 Map_CopyCellsTo(111, 37, 97, 21, width, height);
133 }
134 {
135 s32 destinationCellX = 32;
136 s32 destinationCellZ = 24;
137
138 Map_CopyCellAttributes(46, 38, 3, 2, destinationCellX, destinationCellZ);
139 }
140}
141
142/// Restores the strip's tiles and its one-row collision rectangle.
143static void Event_HideRevealedPath(void) {
144 {
145 s32 width = 1;
146 s32 height = 3;
147
148 Map_CopyCellsTo(95, 21, 97, 21, width, height);
149 }
150 {
151 s32 destinationCellX = 32;
152 s32 destinationCellZ = 25;
153
154 Map_CopyCellAttributes(46, 38, 3, 1, destinationCellX, destinationCellZ);
155 }
156}
157
158/// Douse on the middle section's target: it disappears, for good.
164}
165
166/// Douse on the exit section's target: it disappears, and the first Frost
167/// target settles into a surface the party can walk over.
173 // Match the replacement's drawing priority to its collision cell.
175 Actor_Get(FROST_TARGET_A)->motionFlags = 0;
178 Map_CopyCellAttributes(0, 0, 1, 1, 18, 14);
180}
181
182/// Clears a Frost target's child effect, then plays its freezing animation.
183static inline void BilibinCave_FreezeTarget(s32 actor) {
190}
191
192/// Frost on the first target, before the Douse target is gone.
193static void Event_FreezeFirstTarget(void) {
195}
196
197/// Frost on the second target.
198static void Event_FreezeSecondTarget(void) {
200}
201
202/// Frost on the third target, while 0x302 is set.
203static void Event_FreezeThirdTarget(void) {
205}
206
207/// After a push or Move: while either pushed actor stands on cell (35, 23)
208/// (0x303 and 0x304), the third Frost target changes with a sound, and 0x302
209/// says so; when both leave, it changes back.
211 struct FieldActor *firstActor;
212 struct FieldActor *secondActor;
213 s32 destinationCellX;
214
215 // Track each movable actor independently before changing the Frost target.
216 firstActor = Object_GetById(PUSHED_ACTOR_A);
217 secondActor = Actor_Get(PUSHED_ACTOR_B);
218 if ((firstActor->x.fixed >> 20) == 35 && (firstActor->z.fixed >> 20) == 23) {
219 GameFlag_Set(0x303);
220 } else {
221 GameFlag_Clear(0x303);
222 }
223 if ((secondActor->x.fixed >> 20) == 35 &&
224 (secondActor->z.fixed >> 20) == 23) {
225 GameFlag_Set(0x304);
226 } else {
227 GameFlag_Clear(0x304);
228 }
229 if (GameFlag_IsSet(0x303) != 0 || GameFlag_IsSet(0x304) != 0) {
230 if (GameFlag_IsSet(0x302) == 0) {
234 destinationCellX = 36;
236 Map_CopyCellAttributes(0, 1, 1, 1, destinationCellX, 22);
237 Map_CopyCellAttributes(0, 2, 1, 1, destinationCellX, 24);
239 }
240 GameFlag_Set(0x302);
241 } else {
242 if (GameFlag_IsSet(0x302) != 0) {
246 destinationCellX = 36;
248 Map_CopyCellAttributes(1, 1, 1, 1, destinationCellX, 22);
249 Map_CopyCellAttributes(1, 2, 1, 1, destinationCellX, 24);
251 }
252 GameFlag_Clear(0x302);
253 }
254}
255
256/// Growth on the entrance section's target: the plant grows and its cell's
257/// collision changes; 0x305 keeps it grown.
258static void Event_GrowPlant(void) {
259
260 Map_CopyCellAttributes(31, 0, 1, 1, 8, 13);
261 Engine_GameFlagSet(0x305);
262}
263
264/// Enables the map-work byte while crossing this touch trigger.
265static void Event_SetMapTriggerFlag(void) {
266 struct MapState *map = gMapWork[0];
267 map->unk17 = 1;
268}
269
270/// Clears the same map-work byte at the opposing trigger.
271static void Event_ClearMapTriggerFlag(void) {
272 struct MapState *map = gMapWork[0];
273 map->unk17 = 0;
274}
275
276/// Restores the current section's saved puzzle state.
278 s16 variant = gGameState.scene;
279
280 if (variant == (s32)&SceneId_BilibinCave3) {
282 } else if (variant == (s32)&SceneId_BilibinCave2) {
284 } else if (variant == (s32)&SceneId_BilibinCave1) {
286 }
287 return 0;
288}
289
290/// Restores the collision change already made by Growth.
292 if (Engine_GameFlagIsSet(0x305) != 0) {
293
294 Map_CopyCellAttributes(31, 0, 1, 1, 8, 13);
296 }
297}
298
299/// Opens section 2 and restores its Douse target.
301
303
306
308 0) {
310 } else {
312 }
313}
314
315/// Clears the drawing flags of an actor used by the cave's animations.
316static inline void BilibinCave_ClearActorSpriteFlags(s32 actorId) {
317 struct FieldActor *actor = Actor_Get(actorId);
319}
320
321/// Initializes section 1's animated actors and persistent puzzle states.
323 struct FieldActor *actor;
324 s32 destinationCellX;
325
327 // Set up the decorative animations before restoring interactive actors.
367 // Restore the surface exposed by Douse, including its collision and priority.
371 Actor_Get(FROST_TARGET_A)->motionFlags = 0;
372 Actor_Get(FROST_TARGET_A)->y.fixed = -PIXELS(4);
375 Map_CopyCellAttributes(0, 0, 1, 1, 18, 14);
376 } else {
381 }
382 // Rebuild the Frost target and return moved actors to their saved cells.
384 if (GameFlag_IsSet(0x302) != 0) {
385 destinationCellX = 36;
387 Map_CopyCellAttributes(0, 1, 1, 1, destinationCellX, 22);
388 Map_CopyCellAttributes(0, 2, 1, 1, destinationCellX, 24);
389 } else {
390 destinationCellX = 36;
392 Map_CopyCellAttributes(1, 1, 1, 1, destinationCellX, 22);
393 Map_CopyCellAttributes(1, 2, 1, 1, destinationCellX, 24);
394 }
395 if (GameFlag_IsSet(0x303) != 0) {
397 }
398 if (GameFlag_IsSet(0x304) != 0) {
400 }
401}
402
403// The shared cell lookup retains its position before the push handler.
405
406/// Pushes the actor ahead only when its next cell and movement probe are clear.
407static void Event_PushActorAhead(void) {
408 struct FieldActor *leader;
409 struct FieldActor *target;
410 struct FieldActor *blocker;
411 s32 heading;
412 s32 nextCellX;
413 s32 nextCellZ;
414 struct FieldPosition destination;
415
417 heading = leader->facing >> 12;
418
419 nextCellX =
420 (leader->x.part.pixel + (gBilibinCave_PushSteps[heading] >> 16)) >> 4;
421 nextCellZ =
422 (leader->z.part.pixel + (s16)gBilibinCave_PushSteps[heading]) >> 4;
423 target = SceneActor_FindActorAtCell(nextCellX, nextCellZ);
424 if (target == 0)
425 return;
426
427 nextCellX =
428 (target->x.part.pixel + (gBilibinCave_PushSteps[heading] >> 16)) >> 4;
429 nextCellZ =
430 (target->z.part.pixel + (s16)gBilibinCave_PushSteps[heading]) >> 4;
431 blocker = SceneActor_FindActorAtCell(nextCellX, nextCellZ);
432 if (blocker != 0)
433 return;
434
435 // Check the destination before moving both actors into their push states.
436 target->terrainId = 2;
437
438 destination.x =
439 target->x.fixed + (gBilibinCave_PushSteps[heading] & 0xffff0000);
440 destination.y = target->y.fixed;
441 destination.z =
442 target->z.fixed + (s16)gBilibinCave_PushSteps[heading] * PIXELS(1);
443
444 if (FieldObject_CheckMovementCollision(target, &destination) > 0)
445 return;
446
447 Object_SetMode(leader, 8);
448 Engine_TaskWait(15);
450
451 target->speed = PIXELS(1) / 5;
452 target->acceleration = PIXELS(1) / 5;
453 Engine_ObjectSetPosition(target, destination.x, destination.y, destination.z);
454
455 leader->speed = PIXELS(1) / 5;
456 leader->acceleration = PIXELS(1) / 5;
457 Engine_ObjectSetPosition(leader, destination.x, destination.y, destination.z);
458
459 // Wait for the target's movement before snapping it to the destination.
461
462 target->x.fixed = destination.x;
463 target->z.fixed = destination.z;
464 target->velocityX = (s32)blocker;
465 target->velocityZ = (s32)blocker;
466
467 // Resume the leader and refresh the mechanism affected by the moved actor.
468 Object_SetMode(leader, 1);
470}
471
472/// The original setup invokes this empty hook for every animated actor.
474
477 SC_END,
478};
479
481 {0, CONDITION_ALWAYS, 72, 0, 488, FACING_NORTH, 0, -1, -1, -1, -1, 0},
483};
484
486 {0, CONDITION_ALWAYS, 372, 0, 272, FACING_NORTH, 0, -1, -1, -1, -1, 0},
487 {1, CONDITION_ALWAYS, 99, 0, 447, FACING_NORTH, 0, -1, -1, -1, -1, 0},
488 {2, CONDITION_ALWAYS, 342, 0, 254, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
489 {3, CONDITION_ALWAYS, 440, 0, 136, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
491};
492
494 {0, CONDITION_ALWAYS, 864, 0, 168, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
495 {1, CONDITION_ALWAYS, 312, 0, 756, FACING_NORTH, 0, 40, 60, 630, 840, 0},
496 {2, CONDITION_ALWAYS, 472, 0, 680, FACING_NORTH, 0, 40, 60, 630, 840, 0},
497 {3, CONDITION_ALWAYS, 392, 0, 200, FACING_SOUTH, 0, 40, 60, 630, 840, 0},
498 {4, CONDITION_ALWAYS, 536, 0, 426, FACING_SOUTH, 0, 40, 60, 630, 840, 0},
499 {5, CONDITION_ALWAYS, 856, 0, 124, FACING_SOUTH, 0, 760, 65, 925, 330, 0},
500 {6, CONDITION_ALWAYS, 808, 0, 248, FACING_NORTH, 0, 760, 65, 925, 330, 0},
502};
503
505 {0, CONDITION_ALWAYS, 172, 0, 300, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
506 {1, CONDITION_ALWAYS, 120, 0, 472, FACING_NORTH, 0, 60, 60, 790, 600, 0},
507 {2, CONDITION_ALWAYS, 312, 0, 524, FACING_NORTH, 0, 60, 60, 790, 600, 0},
508 {3, CONDITION_ALWAYS, 538, 0, 548, FACING_NORTH, 0, 60, 60, 790, 600, 0},
509 {4, CONDITION_ALWAYS, 344, 0, 176, FACING_SOUTH, 0, 60, 60, 790, 600, 0},
510 {5, CONDITION_ALWAYS, 856, 0, 632, FACING_NORTH, 0, 740, 510, 980, 690, 0},
512};
513
515 SCENE_EXITS(49), SCENE_EXIT(1, 2, 35), SCENE_EXIT(2, 48, 1),
516 SCENE_EXIT(3, 48, 2), SCENE_EXIT(0, 48, 0), SCENE_EXIT(1, 49, 2),
517 SCENE_EXIT(2, 49, 3), SCENE_EXIT(3, 47, 1), SCENE_EXIT(4, 48, 6),
518 SCENE_EXIT(5, 47, 2), SCENE_EXIT(6, 48, 4), SCENE_EXIT(0, 47, 0),
519 SCENE_EXIT(1, 48, 3), SCENE_EXIT(2, 48, 5), SCENE_EXIT(3, 2, 48),
520 SCENE_EXIT(4, 47, 5), SCENE_EXIT(5, 47, 4), SCENE_EXITS_END,
521};
522
525};
526
527// clang-format off
530 PIXELS(136), 0, PIXELS(208), FACING_SOUTH, TALK_KEEP_FACING, 0 },
531 { SCENE_TABLE_END },
532};
533
536 PIXELS(840), 0, PIXELS(120), FACING_SOUTH, TALK_KEEP_FACING, 0 },
538 PIXELS(856), 0, PIXELS(120), FACING_SOUTH, TALK_KEEP_FACING, 0 },
540 PIXELS(872), 0, PIXELS(120), FACING_SOUTH, TALK_KEEP_FACING, 0 },
541 { SCENE_TABLE_END },
542};
543
546 PIXELS(280), 0, PIXELS(232), FACING_SOUTH, TALK_KEEP_FACING, 0 },
548 PIXELS(152), 0, PIXELS(264), FACING_SOUTH, TALK_KEEP_FACING, 0 },
560 PIXELS(296), 0, PIXELS(230), FACING_SOUTH, TALK_KEEP_FACING, 0 },
562 PIXELS(504), 0, PIXELS(280), FACING_SOUTH, TALK_KEEP_FACING, 0 },
564 PIXELS(584), 0, PIXELS(376), FACING_SOUTH, TALK_KEEP_FACING, 0 },
566 PIXELS(344), 0, PIXELS(224), FACING_SOUTH, TALK_KEEP_FACING, 0 },
576 PIXELS(200), 0, PIXELS(264), FACING_SOUTH, TALK_KEEP_FACING, 0 },
583 { SCENE_TABLE_END },
584};
585
588};
589
591 { EVENT_EXIT, 1, CONDITION_ALWAYS, 1 },
592 { EVENT_EXIT, 2, CONDITION_ALWAYS, 2 },
593 { EVENT_EXIT, 3, CONDITION_ALWAYS, 3 },
598};
599
601 { EVENT_EXIT, 1, CONDITION_ALWAYS, 1 },
602 { EVENT_EXIT, 2, CONDITION_ALWAYS, 2 },
603 { EVENT_EXIT, 3, CONDITION_ALWAYS, 3 },
604 { EVENT_EXIT, 4, CONDITION_ALWAYS, 4 },
605 { EVENT_EXIT, 5, CONDITION_ALWAYS, 5 },
606 { EVENT_EXIT, 6, CONDITION_ALWAYS, 6 },
612};
613
615 { EVENT_EXIT, 1, CONDITION_ALWAYS, 1 },
616 { EVENT_EXIT, 2, CONDITION_ALWAYS, 2 },
617 { EVENT_EXIT, 3, CONDITION_ALWAYS, 3 },
618 { EVENT_EXIT, 4, CONDITION_ALWAYS, 4 },
619 { EVENT_EXIT, 5, CONDITION_ALWAYS, 5 },
630 { SEARCH(SEARCH_CHEST), 100, 0xf5e, FIND_ITEM(ITEM_VIAL) },
634};
635// clang-format on
636
637/// Packs signed pixel steps with X in the upper halfword and Z in the lower.
638#define DIRECTION_STEP(dx, dz) (((u32)(dx) << 16) | ((dz) & 0xffff))
639
641 DIRECTION_STEP(16, 0), DIRECTION_STEP(16, 0), DIRECTION_STEP(16, 0),
642 DIRECTION_STEP(0, 16), DIRECTION_STEP(0, 16), DIRECTION_STEP(0, 16),
643 DIRECTION_STEP(0, 16), DIRECTION_STEP(-16, 0), DIRECTION_STEP(-16, 0),
644 DIRECTION_STEP(-16, 0), DIRECTION_STEP(-16, 0), DIRECTION_STEP(0, -16),
645 DIRECTION_STEP(0, -16), DIRECTION_STEP(0, -16), DIRECTION_STEP(0, -16),
646 DIRECTION_STEP(16, 0),
647};
Ability numbers, named from the English release.
@ ABILITY_DOUSE
Definition ability_ids.h:12
@ ABILITY_REVEAL
Definition ability_ids.h:19
@ ABILITY_MOVE
Definition ability_ids.h:15
@ ABILITY_FROST
Definition ability_ids.h:11
@ ABILITY_GROWTH
Definition ability_ids.h:10
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
#define DIRECTION_STEP(dx, dz)
Pixel step by direction: X in the upper halfword, Z in the lower.
struct SceneEntrance gBilibinCaveEntrances2[]
static void Event_ClearMapTriggerFlag(void)
Clears the same map-work byte at the opposing trigger.
@ GROWTH_TARGET
struct SceneEvent gBilibinCaveEvents2[]
struct SceneEntrance gBilibinCaveEntrancesOther[]
static void BilibinCave_UpdateFrostTargetFromMovableActors(void)
After a push or Move: while either pushed actor stands on cell (35, 23) (0x303 and 0x304),...
static void Event_RestoreCrossingCell(void)
Restores the crossing cell from source cell (0, 0).
struct ScenePlacement gBilibinCavePlacements3[]
s32 gBilibinCave_ClearSpriteScript[]
const struct SceneEvent * BilibinCave_GetEvents(void)
static void BilibinCave_ClearActorSpriteFlags(s32 actorId)
Clears the drawing flags of an actor used by the cave's animations.
static void Event_SetMapTriggerFlag(void)
Enables the map-work byte while crossing this touch trigger.
static void Event_RevealHiddenPath(void)
Replaces the narrow tile strip and its two-row collision rectangle.
static void Event_GrowPlant(void)
Growth on the entrance section's target: the plant grows and its cell's collision changes; 0x305 keep...
struct SceneEvent gBilibinCaveEvents3[]
static void Event_FreezeThirdTarget(void)
Frost on the third target, while 0x302 is set.
static void BilibinCave_RestoreDouseSection(void)
Opens section 2 and restores its Douse target.
const u32 * BilibinCave_GetExits(void)
static void Event_DouseMiddleSectionTarget(void)
Douse on the middle section's target: it disappears, for good.
static void Event_AlterCrossingCell(void)
Replaces the crossing cell with the attributes at source cell (1, 0).
struct SceneEvent gBilibinCaveEvents1[]
static void BilibinCave_RestoreGrowthSection(void)
Restores the collision change already made by Growth.
s32 BilibinCave_Initialize(void)
Restores the current section's saved puzzle state.
static void Event_PushActorAhead(void)
Pushes the actor ahead only when its next cell and movement probe are clear.
static void BilibinCave_RestoreIcePuzzleSection(void)
Initializes section 1's animated actors and persistent puzzle states.
static void Event_FreezeSecondTarget(void)
Frost on the second target.
@ MIDDLE_DOUSE_TARGET
struct SceneEntrance gBilibinCaveEntrances3[]
static void BilibinCave_FreezeTarget(s32 actor)
Clears a Frost target's child effect, then plays its freezing animation.
static s32 BilibinCave_ClearScriptedActorSpriteFlags(struct ScriptInterpreter *interpreter)
Clears the scripted actor's sprite flags and completes this script command.
const struct SceneRegion * BilibinCave_GetRegions(void)
struct SceneEntrance gBilibinCaveEntrances1[]
static void Event_HideRevealedPath(void)
Restores the strip's tiles and its one-row collision rectangle.
const struct SceneEntrance * BilibinCave_GetEntrances(void)
struct ScenePlacement gBilibinCavePlacementsOther[]
const struct ScenePlacement * BilibinCave_GetPlacements(void)
s32 gBilibinCave_PushSteps[]
struct ScenePlacement gBilibinCavePlacements1[]
u32 gBilibinCaveExits[]
static void Event_DouseExitSectionTarget(void)
Douse on the exit section's target: it disappears, and the first Frost target settles into a surface ...
struct SceneEvent gBilibinCaveEventsOther[]
static void BilibinCave_EmptyActorSetupHook(s32 actorId)
The original setup invokes this empty hook for every animated actor.
@ FROST_TARGET_B
@ PUSHED_ACTOR_B
@ EXIT_DOUSE_TARGET
@ FROST_TARGET_C
changes as a pushed actor reaches cell (35, 23)
@ FROST_TARGET_A
walkable once the Douse target is gone
@ PUSHED_ACTOR_A
moved by Move or pushed
static void Event_FreezeFirstTarget(void)
Frost on the first target, before the Douse target is gone.
struct ScenePlacement gBilibinCavePlacements2[]
void Engine_ActorSetSpriteFlags(struct FieldActor *, s32)
The engine calls the debug menus import, and their palette swatch tiles.
The engine call layer: one typed inline for each of the thirteen main-image routines below that the s...
static s32 FieldObject_CheckMovementCollision(struct FieldActor *actor, struct FieldPosition *position)
Definition engine_call.h:66
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
void Engine_ObjectSetPosition(struct FieldActor *object, s32 fixed_x, s32 fixed_y, s32 fixed_z)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
#define GameFlag_IsSet
static void Map_CopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
#define GameFlag_Clear
#define GameFlag_Set
void Engine_GameFlagSet(s32 flag)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
static void Event_PlayCue(s32 cue)
void Engine_ActorSetChildValue(s32 actor, s32 value)
s32 Engine_GameFlagIsSet(s32 flag)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_EventWait(s32 frames)
static struct FieldActor * Actor_Get(s32 actor)
Field objects and actors, and the scene transition styles.
@ TRANSITION_WINDOW
Definition field_obj.h:17
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
Definition field_obj.h:155
#define SCENE_TRANSITION(style, variant)
Definition field_obj.h:20
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_EXIT
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#define PSYNERGY_IN_AREA(ability, phase)
#define IF_FLAG_SET(flag)
Definition field_scene.h:48
#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
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
@ ACTOR_STAND
#define SEARCH(target)
#define SCENE_EXITS_END
Definition field_scene.h:77
#define TOUCH_WALKING_INTO(facing)
#define PLACEMENT_SHARE_PREVIOUS_SPRITE
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_SOUTH
Definition field_scene.h:28
@ FACING_WEST
Definition field_scene.h:30
#define TOUCH_WALKING
#define PIXELS(value)
@ SEARCH_CHEST
Game flags, named where their meaning is shown.
#define FLAG_BILIBIN_CAVE_SECOND_DOUSE_TARGET_CLEARED
Definition flags.h:110
#define FLAG_BILIBIN_CAVE_FIRST_DOUSE_TARGET_CLEARED
Definition flags.h:111
GameState, the game's state: play time, coins, the scene and the leader's position,...
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
void * gMapWork[]
The screen blend's globals and the graphics routines.
The main-image routines scene overlays import.
Item numbers, named from the English release.
@ ITEM_WATER_OF_LIFE
Definition item_ids.h:49
@ ITEM_ELVEN_RAPIER
Definition item_ids.h:15
@ ITEM_VIAL
Definition item_ids.h:42
@ ITEM_PSY_CRYSTAL
Definition item_ids.h:46
Maps: their cells, layers, animations and blend scripts, and the map state.
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_END
Return to the main script.
Definition objcmd.h:32
#define SC_CALL(fn)
Definition objcmd.h:50
void FieldObject_WaitForMove(void *fieldObject)
Waits a frame at a time until a field object has arrived at its target, at most 600 frames.
Scene numbers, named after their places.
char SceneId_BilibinCave2
char SceneId_BilibinCave3
char SceneId_BilibinCave1
The field object script interpreter and the operands its commands read.
Song and sound effect ids, indices into gSound_SongTable.
#define SE_220
Definition songs.h:215
#define SE_HIDDEN_PASSAGE_OPEN
Definition songs.h:205
#define SE_185
Definition songs.h:180
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_TaskWait()
#define NULL
Definition bilibin.h:6
s32 startTransition
SCENE_TRANSITION(style, variant).
Definition event_work.h:43
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s32 speed
speed limit, 16.16 fixed-point pixels per frame
Definition field_obj.h:55
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
s32 velocityX
16.16 fixed-point pixels per frame
Definition field_obj.h:52
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
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 velocityZ
16.16 fixed-point pixels per frame
Definition field_obj.h:54
u8 terrainId
The map layer (0 to 3) its ground height is read from, which the scrolling camera updates from the ce...
Definition field_obj.h:47
A position on the field.
s32 z
16.16 fixed-point pixels
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
Definition map.h:49
u8 unk17
MapScrollWork's footprints; Bilibin Cave sets it.
Definition map.h:53
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 prefix that command handlers read from a field object's 0x70-byte slot.
Definition script.h:16
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
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
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels