Alchemy
Loading...
Searching...
No Matches

kolima_forest_tree.c

Go to the documentation of this file.
1/// @file
2/// Kolima Forest's clearing before Tret, the great tree, and Laurel: once
3/// Tret's hostile heart is defeated, Hermes' Water heals him and lifts Kolima's
4/// curse.
5
7#include "game_state.h"
10#include "unit/object/object.h"
12#include "unit/game/game.h"
14#include "battle.h"
15#include "debug.h"
16#include "field.h"
17#include "game.h"
18#include "graphics.h"
19#include "menu.h"
20#include "minigame.h"
21#include "sound.h"
22#include "system.h"
23#include "resource.h"
24#include "field_obj.h"
25#include "field_effect.h"
26#include "battle_unit.h"
27#include "types.h"
28#include "call.h"
29#include "field_event.h"
30#include "engine_call.h"
31#include "scene_ids.h"
32#include "palette_scene.h"
33#include "io_reg.h"
34#include "field_scene.h"
35#include "text/msg_ids.h"
36#include "ability_ids.h"
37#include "objcmd.h"
38#include "fixed_math.h"
39#include "palbuf.h"
40#include "flags.h"
41#include "character_ids.h"
42#include "item_ids.h"
43#include "macros.h"
44#include "songs.h"
45
46enum {
52};
53
55static void KolimaForestTree_RestoreTret(void);
58static void KolimaForestTree_PlayGesture(s32 auxiliaryActorId, s32 gesture);
59static void KolimaForestTree_SpawnOrbitSparks(void);
60static void KolimaForestTree_ReplaceInventoryItem(s32 oldItemId, s32 newItemId);
61
62s32 gKolimaForestTreeSparkOrigin[3] __attribute__((section(".bss")));
63s32 gKolimaForestTreeSparkFrame __attribute__((section(".bss")));
64s32 gKolimaForestTreePlaySparkSound __attribute__((section(".bss")));
65s32 gKolimaForestTreePaletteFrame __attribute__((section(".bss")));
66
69}
70
71/// Returns the region at the entrance to Tret's interior.
74}
75
76/// Returns the connections to the bridge and Tret's interior.
78
79/// Returns Tret, Laurel and their auxiliary actors.
82}
83
84/// Takes the touched exit after completing the leader's current movement.
86 struct EventWork *scene;
87
88 scene = gEventWork;
93}
94
95/// Returns the trees' dialogue, Mind Read and item-use events.
98}
99
100/// Introduces Laurel or hears her warning while Tret is still dying.
105 Engine_EventSetMessage(MsgKolimaForestKolimaAlive);
107 } else if (GameFlag_IsSet(FLAG_MET_LAUREL) != 0) {
108 Engine_EventSetMessage(MsgKolimaLeaveBeforeForest);
110 } else {
111 Engine_EventSetMessage(MsgKolimaWho);
126 }
129}
130
131/// Talks to Tret and offers the item prompt when Hermes' Water is available.
133 s32 waterOwner;
134
138 Engine_EventSetMessage(MsgKolimaNowHaveSuchPowerAxe);
139 Event_ShowMessage(8, 0);
141 } else {
144 Engine_EventSetMessage(MsgKolimaSilence2);
145 Event_ShowMessage(8, 0);
148 if (waterOwner != -1) {
149 u16 *stateSlot = &gEventWork->unk172;
150 u16 requestPrompt = 1;
151
152 *stateSlot = requestPrompt;
153 }
154 } else {
155 Engine_EventSetMessage(MsgKolimaSilence);
156 Event_ShowMessage(8, 0);
157 ColorBuffer_ApplyTarget(0x406218, 1);
159 Engine_TaskWait(40);
165 Engine_TaskWait(40);
166 }
167 }
169}
170
171/// Reads Laurel's thoughts about the healing water or the danger beyond the
172/// river.
176 Engine_EventSetMessage(MsgKolimaMustHorribleBeyondRiverAm);
177 } else {
178 Engine_EventSetMessage(MsgKolimaHealingWatersMercuryLighthouseMight);
179 }
182}
183
184/// Reads Tret's regret before healing, or his concern for the forest afterward.
188 Engine_EventSetMessage(MsgKolimaKnowCannotStopButPlease);
189 } else {
190 Engine_EventSetMessage(MsgKolimaPeopleKolimaForgiveMe);
191 }
194}
195
196/// Heals Tret only after his hostile heart has been defeated.
202 } else {
204 }
206}
207
208/// Shows Tret's hostile heart repelling the leader's attempt to help.
210 struct FieldActor *leader;
211
212 // The hostile heart lifts the leader away before the water can heal Tret.
215 ColorBuffer_ApplyTarget(0x406218, 1);
217 Engine_TaskWait(40);
222 Engine_TaskWait(30);
224 Camera_MoveTo(PIXELS(328), -1, PIXELS(235), 1);
230 leader->velocityY = PIXELS(5);
231 leader->gravity = PIXELS(1) / 4;
232 leader->bounce = 5 * Q16_ONE / 8;
234 while (leader->velocityY >= 0) {
236 }
237 do {
239 } while (leader->velocityY <= 0);
242 Engine_EventWait(120);
244 Engine_TaskWait(40);
245 leader->bounce = Q16_ONE / 4;
246 {
247 struct FieldActor *leader = Actor_Get(ACTOR_PARTY_LEADER);
249 }
251 // Hear the heart's refusal, then restore the leader's ordinary motion.
252 Engine_EventSetMessage(MsgKolimaControlTretsHeartShallNot);
260 Engine_TaskWait(40);
261 {
263
264 leader->facing = facing;
265 }
266 leader->gravity = PIXELS(1);
267 leader->bounce = Q16_ONE / 4;
273}
274
275/// Gives all four companions the same nod, waiting on Ivan's animation.
276static __inline__ void KolimaForestTree_NodTogether(void) {
281}
282
283/// Turns the companions together and pauses after the final facing change.
284static __inline__ void KolimaForestTree_FaceParty(s32 facing, s32 waitFrames) {
288 Actor_FaceDirection(IVAN, facing, waitFrames);
289}
290
291/// Heals Tret, lifts Kolima's curse and hears the trees' warning.
293 s32 includeMia;
294 struct FieldActor *leader;
295 s32 *paletteFrame;
296 s32 flash;
297 void (*spawnOrbitSparks)(void);
298 const s32 *finalActions;
299
300 // Gather the companions while Hermes' Water seeps into Tret.
301 // Flag 3: Mia is in the party.
302 includeMia = GameFlag_IsSet(FLAG_IN_PARTY(MIA));
306 Engine_MessageShowCentered(MsgKolimaWaterHermesSeepedIntoTret, 1);
307 Actor_SetSpeed(GARET, PIXELS(1), PIXELS(1) / 2);
308 Actor_SetSpeed(IVAN, PIXELS(1), PIXELS(1) / 2);
310 if (leader != 0) {
311 Actor_SetPosition(GARET, leader->x.fixed, leader->z.fixed);
312 }
314 if (leader != 0) {
315 Actor_SetPosition(IVAN, leader->x.fixed, leader->z.fixed);
316 }
319 if (includeMia != 0) {
320 Actor_SetSpeed(MIA, PIXELS(1), PIXELS(1) / 2);
322 if (leader != 0) {
323 Actor_SetPosition(MIA, leader->x.fixed, leader->z.fixed);
324 }
326 }
331 Engine_TaskWait(40);
332 // Carry the healing across the forest as its healthy colours return.
333 paletteFrame = &gKolimaForestTreePaletteFrame;
334 *paletteFrame = 0;
339 Camera_SetSpeed(PIXELS(16) / 5, PIXELS(2) / 5);
340 Camera_MoveTo(PIXELS(256), -1, PIXELS(254), 1);
345 Camera_MoveTo(PIXELS(413), -1, PIXELS(261), 1);
351 Camera_MoveTo(PIXELS(326), -1, PIXELS(384), 1);
354 if (*paletteFrame != 24) {
355 do {
357 } while (*paletteFrame != 24);
358 }
360 Engine_TaskWait(10);
361 // Flash the two saved palettes before settling on the healthy forest.
362 flash = 0;
363 do {
369 flash = (flash + 1);
371 } while ((u32)flash <= 3);
374 Engine_TaskWait(80);
375 Camera_MoveTo(PIXELS(328), PIXELS(8), PIXELS(212), 1);
381 // Tret and Laurel discover that their powers have returned.
382 Engine_EventSetMessage(MsgKolimaFeelGreatPowerSpreadingThrough);
383 Event_ShowMessage(8, 0);
395 Event_ShowMessage(8, 0);
400 Camera_MoveTo(PIXELS(234), 0, PIXELS(232), 1);
430 if (Engine_EventChooseYesNo(0, 0) == 0) {
433 } else {
434 gEventWork->message += 2;
440 if (includeMia != 0) {
443 } else {
444 gEventWork->message += 1;
445 }
450 }
452 Camera_MoveTo(PIXELS(328), PIXELS(8), PIXELS(212), 1);
460 ColorBuffer_ApplyTarget(0x406218, 1);
464 // Tret sends out the power that frees Kolima's villagers.
467 spawnOrbitSparks = KolimaForestTree_SpawnOrbitSparks;
470 Engine_EventWait(100);
471 Engine_TaskRemoveCallback(spawnOrbitSparks);
472 ColorBuffer_ApplyTarget(0x7fff, 0);
474 Engine_EventWait(100);
480 Engine_EventSetMessage(MsgKolimaShouldDoPeopleKolimaCursed);
483 Camera_MoveTo(PIXELS(234), 0, PIXELS(232), 1);
492 if (Engine_EventChooseYesNo(0, 0) == 0) {
494 } else {
496 gEventWork->message += 1;
497 }
501 // Explain the curse and how the falling Psynergy Stones changed the forest.
502 Engine_EventSetMessage(MsgKolimaWasIndeedAngryPeopleHad);
557 ColorBuffer_ApplyTarget(0x406218, 1);
561 // Laurel looks beyond the river and warns of the forest to the south.
564 spawnOrbitSparks = KolimaForestTree_SpawnOrbitSparks;
567 Engine_EventWait(100);
588 Engine_TaskRemoveCallback(spawnOrbitSparks);
611 if (Engine_EventChooseYesNo(0, 0) == 1) {
612 gEventWork->message += 1;
613 }
628 // Rejoin the party and exchange the used water for its empty bottle.
630 Actor_SetActionScript(GARET, finalActions);
631 if (includeMia != 0) {
632 Actor_SetActionScript(MIA, finalActions);
633 }
634 Actor_RunActionScriptAndWait(IVAN, finalActions);
638 Engine_EventSetMessage(MsgKolimaOweGreatDebtHaveSaved);
648}
649
650/// Restores the trees' faces, collision and the dying forest's palette.
652 struct FieldActor *tretAuxiliary;
653 struct FieldActor *tretsDarkSide;
654 struct FieldActor *laurelAuxiliary;
655
656 tretAuxiliary = Object_GetById(ACTOR_TRET_AUXILIARY);
657 tretsDarkSide = Object_GetById(ACTOR_TRETS_DARK_SIDE);
658 laurelAuxiliary = Object_GetById(ACTOR_LAUREL_AUXILIARY);
668 Object_GetById(12)->radius = 6;
669 Object_GetById(13)->radius = 6;
678 tretAuxiliary->motionFlags = 0;
679 tretAuxiliary->y.fixed = PIXELS(28);
680 laurelAuxiliary->motionFlags = 0;
681 laurelAuxiliary->y.fixed = PIXELS(28);
682 tretsDarkSide->motionFlags = 0;
683 tretsDarkSide->y.fixed = PIXELS(28);
691 return 0;
692}
693
694#include "common/kolima_grow.h"
695
696/// Spawns the growing sparks that repel the party leader.
698 struct FieldActor *effect;
699 struct AnimationObject *sprite;
700 s32 phase;
701 s32 effectFlags;
702 s32 spawnX = PIXELS(326);
703 s32 spawnY = PIXELS(32);
704 s32 spawnZ = PIXELS(192);
705 s32 targetX = PIXELS(326);
706 s32 targetZ = PIXELS(240);
707
708 phase = gFrameCount & 3;
709 if (phase != 0)
710 return;
713 effect = Engine_ObjectCreate(26, spawnX, spawnY, spawnZ);
714 if (effect == 0)
715 return;
716 sprite = effect->sprite;
717 sprite->flags = phase;
718 effectFlags = 0xff & ~ACTOR_PRIORITY_AUTOMATIC;
719 effectFlags &= effect->priorityFlags;
720 effect->priorityFlags = effectFlags;
721 sprite->image.priority = 1;
722 effect->scaleX = Q16_ONE / 10;
723 effect->speed = PIXELS(4);
724 effect->acceleration = PIXELS(4);
725 effect->motionFlags = phase;
726 Object_SetMode(effect, 2);
727 Engine_ObjectSetPosition(effect, targetX, 0, targetZ);
729}
730
731/// Alternates the saved healthy and withered palettes over thirty frames.
734
735 if (step == 0) {
738 } else if (step == 20) {
741 }
744 if (step == 30) {
746 }
747}
748
749/// Alternates two facial frames twice, ending on the first frame.
750static __inline__ void KolimaForestTree_AlternateFaceFrames(s32 actorId,
751 s32 firstFrame,
752 s32 secondFrame) {
753 Engine_ActorSetAnimation(actorId, firstFrame);
755 Engine_ActorSetAnimation(actorId, secondFrame);
757 Engine_ActorSetAnimation(actorId, firstFrame);
759 Engine_ActorSetAnimation(actorId, secondFrame);
761 Engine_ActorSetAnimation(actorId, firstFrame);
762}
763
764/// Chooses Tret or Laurel's facial sequence through their auxiliary actor.
765static void KolimaForestTree_PlayGesture(s32 auxiliaryActorId, s32 gesture) {
766 if (auxiliaryActorId == ACTOR_TRET_AUXILIARY) {
767 switch (gesture) {
768 case 0:
772 break;
773 case 1:
775 break;
776 case 2:
780 break;
781 case 3:
785 break;
786 case 4:
788 break;
789 case 5:
793 break;
794 case 6:
798 break;
799 case 8:
803 break;
804 case 9:
808 break;
809 case 10:
811 break;
812 case 7:
813 case 11:
815 break;
816 }
817 } else {
818 switch (gesture) {
819 case 0:
823 break;
824 case 1:
826 break;
827 case 2:
831 break;
832 case 3:
836 break;
837 case 4:
839 break;
840 case 5:
844 break;
845 }
846 }
847 Engine_TaskWait(12);
848}
849
850/// Expands a spark along its spiral for 120 frames, then releases its cache
851/// slot.
852static void KolimaForestTree_UpdateOrbitSpark(union FieldObject *fieldObject) {
853 struct FieldActor *spark = &fieldObject->actor;
854 s32 position[3];
855 s32 age = spark->timer;
856 s32 heading;
857
858 if (age <= 119) {
859 SET_VECTOR(position, spark->targetX, spark->targetY, spark->targetZ);
860 heading = (s16)spark->work;
861 Vector_AddPolarOffset(age * Q16_ONE, age * 768 + heading, position);
862 spark->x.fixed = position[0];
863 spark->y.fixed = position[1];
864 spark->z.fixed = position[2];
865 spark->scaleX += Q16_ONE / 200;
866 spark->scaleY += Q16_ONE / 200;
867 spark->timer++;
868 } else {
869 Resource_ResetEntry(spark->sprite->slot);
871 }
872}
873
874/// Emits six-spark rings at ten-frame intervals during each burst.
876 struct FieldActor *spark;
877 struct AnimationObject *previousSprite;
878 u32 sparkIndex;
879
880 previousSprite = NULL;
882 case 0:
883 case 10:
884 case 20:
885 case 30:
886 case 40:
888 for (sparkIndex = 0; sparkIndex <= 5; sparkIndex++) {
892 if (spark != 0) {
893 previousSprite = Sprite_ShareVramCache(spark->sprite, previousSprite);
894 spark->motionFlags = 0;
895 spark->sprite->image.priority = 1;
897 Object_SetMode(spark, 1);
898 spark->timer = 0;
899 spark->work = (sparkIndex * 60 * Q16_ONE) / 360;
903 spark->speed = PIXELS(8) / 5;
905 }
906 }
907 break;
908 }
909 if (++gKolimaForestTreeSparkFrame > 120) {
911 }
912}
913
914/// Replaces the used water with its empty bottle in the same inventory slot.
916 s32 newItemId) {
917 s32 owner = PartyInventory_FindOwner(oldItemId);
918
919 if (owner != -1) {
920 s32 inventorySlot = Inventory_Find(owner, oldItemId);
921
922 if (inventorySlot != -1) {
923 UnitGet(owner)->inventory[inventorySlot] = newItemId;
924 }
925 }
926}
927
929
931 SC_ARG(2), SC_MOVE(PIXELS(312), 0, PIXELS(230)), SC_SYNC,
933 SC_END,
934};
935
937 SC_ARG(2), SC_MOVE(PIXELS(346), 0, PIXELS(224)), SC_SYNC,
939 SC_END,
940};
941
943 SC_ARG(2), SC_MOVE(PIXELS(333), 0, PIXELS(240)), SC_SYNC,
945 SC_END,
946};
947
949 SC_ARG(2), SC_MOVE(PIXELS(328), 0, PIXELS(212)),
950 SC_SYNC, SC_POS(0, 0, 0),
951 SC_WAIT(1), SC_END,
952};
953
955 {0, CONDITION_ALWAYS, 209, 0, 279, FACING_SOUTH, 0, 0, 0, 512, 448, 0},
956 {1, CONDITION_ALWAYS, 136, 0, 424, FACING_NORTH, 0, 0, 0, 512, 448, 0},
957 {2, CONDITION_ALWAYS, 328, 16, 200, FACING_SOUTH, 0, 0, 0, 512, 448, 0},
959};
960
961// clang-format off
963 {320, 88, 176, 336, 104, 192, -1, 2},
964 {-1, 0, 0, 0, 0, 0, 0, 0},
965};
966
968 SCENE_EXITS(44),
969 SCENE_EXIT(1, 43, 2),
970 SCENE_EXIT(2, 45, 1),
972};
973
976 PIXELS(327), 0, PIXELS(192), FACING_SOUTH, TALK_KEEP_FACING, 0 },
978 PIXELS(136), 0, PIXELS(270), FACING_SOUTH, TALK_KEEP_FACING, 0 },
979 { 0x16, CONDITION_ALWAYS, 7,
980 PIXELS(327), 0, PIXELS(192), FACING_SOUTH, TALK_KEEP_FACING, 0 },
981 { 0x16, CONDITION_ALWAYS, 7,
982 PIXELS(136), 0, PIXELS(270), FACING_SOUTH, TALK_KEEP_FACING, 0 },
983 { 0x16, CONDITION_ALWAYS, 7,
984 PIXELS(327), 0, PIXELS(194), FACING_SOUTH, TALK_KEEP_FACING, 0 },
985 { 0x16, CONDITION_ALWAYS, 7,
986 PIXELS(136), 0, PIXELS(272), FACING_SOUTH, TALK_KEEP_FACING, 0 },
988 PIXELS(327), 0, PIXELS(192), FACING_SOUTH, TALK_KEEP_FACING, 0 },
990 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
992 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
994 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
995 { SCENE_TABLE_END },
996};
997
999 { EVENT_EXIT, 1, CONDITION_ALWAYS, 1 },
1000 // Hermes' Water (item 0xb8) used on Tret.
1007 { SCENE_EVENTS_END },
1008};
1009// clang-format on
1010
1012 SC_ADD(SW_SCALE_X, Q16_ONE / 10),
1015};
Ability numbers, named from the English release.
@ ABILITY_MIND_READ
Definition ability_ids.h:16
void Object_RefreshSelectorById(u32 objectId)
Waits, at most 300 frames, for an actor's script to reach its end (command 0x10).
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
The battle animation state, render objects and effect entries, and the palette buffer work.
BattleUnit, a party member's or enemy's battle state, with the elements, abilities and actions it use...
Calls through a function pointer, by argument count.
Character numbers, with each character's Japanese name.
#define GARET
Jerald.
#define MIA
Mary.
#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.
The engine call layer: one typed inline for each of the thirteen main-image routines below that the s...
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
Field effects, their scripts and the flags that spawn them.
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)
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)
void Engine_ActorWalkByAndWait(s32 actor, s32 dx, s32 dz)
#define SPEAKER_WINDOW_ABOVE
Definition field_event.h:56
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
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
#define SPEAKER_PORTRAIT_RIGHT
Definition field_event.h:55
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
static void Camera_SetSpeed(s32 speed, s32 acceleration)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
void Engine_ActorJump(s32 actor, s32 height, s32 frames)
#define EMOTE_IN_FRONT
Definition field_event.h:49
static void Actor_MoveToAndWait(s32 actor, s32 x, s32 z)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ObjectDispatchRelease(struct FieldActor *object)
static void Actor_RunActionScriptAndWait(s32 actor, const s32 *script)
Runs a script, waiting at most 300 frames for its final command.
#define SPEAKER_WINDOW_BELOW
Definition field_event.h:57
static void ColorBuffer_ApplyTarget(s32 value, s32 mode)
#define GameFlag_Set
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
void Engine_GameFlagSet(s32 flag)
void Engine_CameraWaitForMove(void)
static void Actor_SetActionScript(s32 actor, const s32 *script)
The engine encodes either a built-in action or an action-script address.
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
static void Event_PlayCue(s32 cue)
void Engine_ActorSetChildValue(s32 actor, s32 value)
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
@ TASK_PRIORITY_SCENE
Definition field_event.h:40
void Engine_ColorBufferInterpolate(s32 frames)
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_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_AUTOMATIC
The sprite takes its priority from the map cell under it.
Definition field_obj.h:153
#define SCENE_TRANSITION(style, variant)
Definition field_obj.h:20
@ ACTOR_FACES_MOTION
turns toward its velocity, 1/16 turn a frame
Definition field_obj.h:166
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EVENTS_END
@ EVENT_EXIT
@ EVENT_TALK
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#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)
#define USE_ITEM_ON_ACTOR(item)
@ ACTOR_STAND
#define SCENE_EXITS_END
Definition field_scene.h:77
@ FACING_NORTHEAST
Definition field_scene.h:33
@ FACING_EAST
Definition field_scene.h:26
@ FACING_SOUTHEAST
Definition field_scene.h:27
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_SOUTHWEST
Definition field_scene.h:29
@ FACING_NORTHWEST
Definition field_scene.h:31
@ FACING_SOUTH
Definition field_scene.h:28
@ FACING_WEST
Definition field_scene.h:30
#define PIXELS(value)
16.16 fixed-point constants, sine and cosine, and the library division.
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
Definition fixed_math.h:10
Game flags, named where their meaning is shown.
#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_MET_LAUREL
Definition flags.h:104
#define FLAG_KOLIMA_CURSE_LIFTED
Definition flags.h:103
#define FLAG_TRET_DEFEATED
Definition flags.h:102
volatile u32 gFrameCount
Frames WaitFrames has finished.
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.
s32 Inventory_Find(s32 owner, s32 itemId)
Returns the first slot holding itemId (any quantity, equipped or not), or -1.
Definition inventory.c:212
s32 PartyInventory_FindOwner(s32 itemId)
Returns who carries itemId, asking the selected character first, or -1.
Definition inventory.c:229
The hardware's I/O registers and their bits, as pret names them.
Item numbers, named from the English release.
@ ITEM_HERMES_WATER
Definition item_ids.h:44
@ ITEM_EMPTY_BOTTLE
Definition item_ids.h:45
static void KolimaForestTree_ReadLaurelThoughts(void)
Reads Laurel's thoughts about the healing water or the danger beyond the river.
static void KolimaForestTree_PlayGesture(s32 auxiliaryActorId, s32 gesture)
Chooses Tret or Laurel's facial sequence through their auxiliary actor.
static void KolimaForestTree_ReadTretThoughts(void)
Reads Tret's regret before healing, or his concern for the forest afterward.
s32 gKolimaForestTreeEffectScript[]
static void KolimaForestTree_UpdateOrbitSpark(union FieldObject *fieldObject)
Expands a spark along its spiral for 120 frames, then releases its cache slot.
static void KolimaForestTree_UseHermesWater(void)
Heals Tret only after his hostile heart has been defeated.
static __inline__ void KolimaForestTree_AlternateFaceFrames(s32 actorId, s32 firstFrame, s32 secondFrame)
Alternates two facial frames twice, ending on the first frame.
static UNUSED void KolimaForestTree_ExitTouchedRegion(void)
Takes the touched exit after completing the leader's current movement.
u32 gKolimaForestTreeExits[]
s32 KolimaForestTree_Initialize(void)
Restores the trees' faces, collision and the dying forest's palette.
s32 gKolimaForestTree_RejoinPartyActions[]
static void KolimaForestTree_RejectHermesWater(void)
Shows Tret's hostile heart repelling the leader's attempt to help.
static __inline__ void KolimaForestTree_NodTogether(void)
Gives all four companions the same nod, waiting on Ivan's animation.
static void KolimaForestTree_SpawnRejectionSpark(void)
Spawns the growing sparks that repel the party leader.
static void KolimaForestTree_TalkToLaurel(void)
Introduces Laurel or hears her warning while Tret is still dying.
s32 gKolimaForestTreePlaySparkSound
@ ACTOR_LAUREL
@ ACTOR_TRETS_DARK_SIDE
@ ACTOR_TRET_AUXILIARY
@ ACTOR_LAUREL_AUXILIARY
@ ACTOR_TRET
s32 gKolimaForestTreeSparkOrigin[3]
struct ScenePlacement gKolimaForestTreePlacements[]
struct SceneEntrance gKolimaForestTreeEntrances[]
const struct ScenePlacement * KolimaForestTree_GetPlacements(void)
Returns Tret, Laurel and their auxiliary actors.
static void KolimaForestTree_TalkToTret(void)
Talks to Tret and offers the item prompt when Hermes' Water is available.
static void KolimaForestTree_SpawnOrbitSparks(void)
Emits six-spark rings at ten-frame intervals during each burst.
struct SceneEvent gKolimaForestTreeEvents[]
struct SceneRegion gKolimaForestTreeRegions[]
s32 gKolimaForestTree_MiaApproachActions[]
static void KolimaForestTree_RestoreTret(void)
Heals Tret, lifts Kolima's curse and hears the trees' warning.
s32 gKolimaForestTreePaletteFrame
static __inline__ void KolimaForestTree_FaceParty(s32 facing, s32 waitFrames)
Turns the companions together and pauses after the final facing change.
s32 gKolimaForestTree_GaretApproachActions[]
s32 gKolimaForestTree_IvanApproachActions[]
const struct SceneEvent * KolimaForestTree_GetEvents(void)
Returns the trees' dialogue, Mind Read and item-use events.
const struct SceneEntrance * KolimaForestTree_GetEntrances(void)
s32 gKolimaForestTreeSparkFrame
static void KolimaForestTree_ReplaceInventoryItem(s32 oldItemId, s32 newItemId)
Replaces the used water with its empty bottle in the same inventory slot.
const u32 * KolimaForestTree_GetExits(void)
Returns the connections to the bridge and Tret's interior.
const struct SceneRegion * KolimaForestTree_GetRegions(void)
Returns the region at the entrance to Tret's interior.
static void KolimaForestTree_UpdateHealingPalette(void)
Alternates the saved healthy and withered palettes over thirty frames.
Kolima, its forest bridge and the forest's tree: an effect (object 26) that stretches as it travels.
static s32 SceneEffect_AdvanceAngleUntilIdle(struct ScriptInterpreter *interpreter)
An object script call: widen the object by 0x1eb8 (about 0.12) a frame, and release it once it has re...
Definition kolima_grow.h:11
Small statement macros both games use for positions, velocities and bounds.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
Definition macros.h:12
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
Definition math.c:23
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#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_SYNC
Wait for arrival.
Definition objcmd.h:17
#define SC_FOREVER
Definition objcmd.h:14
#define SC_ADD(w, v)
Definition objcmd.h:38
#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_FACING
Definition objcmd.h:57
@ SW_SCALE_X
Definition objcmd.h:62
#define SC_CALL(fn)
Definition objcmd.h:50
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
struct AnimationObject * Sprite_ShareVramCache(struct AnimationObject *sourceSprite, struct AnimationObject *sharedSprite)
Makes sourceSprite share sharedSprite's VRAM block, releasing its own; with no sharedSprite it keeps ...
Definition dispatch.c:346
Palette fades, the battle effect palette buffers and the colour channel curves.
@ PALETTE_TRANSFORM_PLAIN
each colour unchanged
Definition palbuf.h:72
Declares nothing of its own: it only includes types.h.
void Audio_PlayCueFromEventWork(void)
Starts the current scene's field music, chosen by Scene_ResolveInteractionResult.
Definition scene.c:355
Scene numbers, named after their places.
char SceneId_KolimaForestBridge
Song and sound effect ids, indices into gSound_SongTable.
#define SE_220
Definition songs.h:215
#define MUS_001
Definition songs.h:11
#define SE_133
Definition songs.h:126
#define MUS_007
Definition songs.h:17
#define MUS_017
Definition songs.h:27
#define SE_200
Definition songs.h:195
#define SE_161
Definition songs.h:156
#define SE_246
Definition songs.h:241
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_TaskWait()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
#define NULL
Definition bilibin.h:6
void KolimaPalette_Restore(s32 second)
Makes the healthy colours (second 0) or the cursed ones (second 1) the colours to fade to; the scene ...
void KolimaPalette_Curse(s32 strength)
Keeps the healthy colours, curses the background palettes 0 to 13 (all but colours 1 to 7 of palette ...
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
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
Definition event_work.h:20
s32 startTransition
SCENE_TRANSITION(style, variant).
Definition event_work.h:43
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
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
u16 radius
Collision radius in pixels: 16, or half the sprite metadata's boxY, when created; the overlap checks ...
Definition field_obj.h:43
u8 steeringFlags
ActorSteeringFlag bits.
Definition field_obj.h:92
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
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
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition field_obj.h:39
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition field_obj.h:40
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
Definition field_obj.h:116
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
Definition field_obj.h:91
s16 retreatEntrance
where Retreat goes; the group's first entrance
Definition game_state.h:109
s16 retreatScene
where Retreat goes; the group's first entrance
Definition game_state.h:108
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 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
unsigned short u16
Definition types.h:13
#define UNUSED
Definition types.h:22
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
struct FieldActor actor
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
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
Definition vram_cache.c:106