28#include "text/msg_ids.h"
129 if (pillar !=
NULL) {
169 if (cellX == 7 && cellZ == 16) {
285 thoughts = MsgLunpaEastGuardFearsBlame;
287 thoughts = MsgLunpaEastGuardTrustsCaveGate;
341 s32 recognitionMessageBase;
348 recognitionMessageBase = MsgLunpaLeftGuardRecognizesHammet;
376 s32 recognizedHammet;
382 if (recognizedHammet == 0) {
449 if (placedActor !=
NULL) {
582 s32 warningMessageBase;
597 warningMessageBase = MsgLunpaGuardsCatchParty;
616 leader->
z.
part.pixel);
695 dustVelocity[0], dustVelocity[1], dustVelocity[2], 0,
NULL);
821 if (puddle !=
NULL) {
867#define LUNPA_ENTRANCE(entrance, x, z, facing) \
868 {(entrance), CONDITION_ALWAYS, (x), 0, (z), (facing), 0, -1, -1, -1, -1, 0}
869#define GATE_ENTRANCE(entrance, x, z, facing) \
870 {(entrance), CONDITION_ALWAYS, (x), 0, (z), (facing), 0, 32, 48, 272, 344, 0}
898#define ROOM_EXIT(exit) \
899 SCENE_EXIT((exit), SCENE_LUNPA_SUHALLA, ROOM_ENTRANCE(exit))
970#define TALK(actor, value) {EVENT_TALK, (actor), CONDITION_ALWAYS, (value)}
971#define MIND_READ(actor, value) \
972 {PSYNERGY_ON_ACTOR(ABILITY_MIND_READ), (actor), CONDITION_ALWAYS, (value)}
974#define DOOR(trigger) \
975 {TOUCH_WALKING_INTO(FACING_NORTH), (trigger), CONDITION_ALWAYS, \
976 EVENT_SCRIPT(Event_EnterDoor)}
978#define LUNPA_ROADS_AND_DOORS \
979 {EVENT_EXIT, TRIGGER_WORLD_MAP_ROAD, CONDITION_ALWAYS, \
980 LUNPA_EXIT_TO_WORLD_MAP}, \
981 {EVENT_EXIT, TRIGGER_GATE_ROAD, CONDITION_ALWAYS, LUNPA_EXIT_TO_GATE}, \
982 {EVENT_EXIT, TRIGGER_CAVE_ROAD, CONDITION_ALWAYS, LUNPA_EXIT_TO_CAVE}, \
983 DOOR(TRIGGER_FIRST_HOME_DOOR), DOOR(TRIGGER_SECOND_HOME_DOOR), \
984 DOOR(TRIGGER_THIRD_HOME_DOOR), DOOR(TRIGGER_ARMS_SHOP_DOOR), \
985 DOOR(TRIGGER_ITEM_SHOP_DOOR), DOOR(TRIGGER_INN_DOOR), \
986 DOOR(TRIGGER_TEMPLE_DOOR), DOOR(TRIGGER_EIGHTH_ROOM_DOOR), { \
987 TOUCH_WALKING_INTO(FACING_NORTH), TRIGGER_HIDDEN_PASSAGE, \
988 CONDITION_ALWAYS, EVENT_SCRIPT(Event_EnterHiddenPassage) \
991#define LUNPA_SECRETS \
992 {PSYNERGY_ON_ACTOR(ABILITY_FROST), ACTOR_HIDDEN_PUDDLE, FLAG_SCENE_TEMP_00, \
993 EVENT_SCRIPT(Event_FreezeHiddenPuddle)}, \
994 {PSYNERGY_IN_AREA(ABILITY_REVEAL, REVEAL_SHOWN), 0, CONDITION_ALWAYS, \
995 EVENT_SCRIPT(Event_RevealSecrets)}, \
996 {PSYNERGY_IN_AREA(ABILITY_REVEAL, REVEAL_FADED), 0, CONDITION_ALWAYS, \
997 EVENT_SCRIPT(Event_HideSecrets)}, \
998 {SEARCH(SEARCH_UNNAMED), TRIGGER_HIDDEN_SWITCH, FLAG_SCENE_TEMP_01, \
999 EVENT_SCRIPT(Event_PressHiddenSwitch)}, \
1000 {SEARCH(SEARCH_UNNAMED), TRIGGER_PSYNERGY_STONE, \
1001 FLAG_LUNPA_PSYNERGY_STONE, FIND_PSYNERGY_STONE}, \
1002 {SEARCH(SEARCH_GRAVE), TRIGGER_GRAVE_SLEEP_BOMB, \
1003 FLAG_LUNPA_GRAVE_SLEEP_BOMB, FIND_ITEM(ITEM_SLEEP_BOMB)}, \
1004 {SEARCH(SEARCH_BARREL), TRIGGER_BARREL_NUT, FLAG_LUNPA_BARREL_NUT, \
1005 FIND_ITEM(ITEM_NUT)}, \
1006 {PSYNERGY_ON_ACTOR(ABILITY_CATCH), ACTOR_FLOATING_NUT, \
1007 FLAG_LUNPA_NUT_CAUGHT, EVENT_SCRIPT(Event_CatchFloatingNut)}, \
1008 {SEARCH(SEARCH_UNNAMED), TRIGGER_WELL, CONDITION_ALWAYS, \
1009 EVENT_SCRIPT(Event_SearchWell)}, \
1052 MSGNO(MsgLunpaVillageVillagerAReopenedThoughts)),
1054 MSGNO(MsgLunpaVillageVillagerBReopenedThoughts)),
1056 MSGNO(MsgLunpaVillageVillagerCReopenedThoughts)),
1058 MSGNO(MsgLunpaVillageVillagerDReopenedThoughts)),
1060 MSGNO(MsgLunpaVillageVillagerEReopenedThoughts)),
1062 MSGNO(MsgLunpaVillageVillagerFReopenedThoughts)),
1064 MSGNO(MsgLunpaVillageVillagerGReopenedThoughts)),
1066 MSGNO(MsgLunpaVillageVillagerHReopenedThoughts)),
1068 MSGNO(MsgLunpaVillageWestGuardReopenedThoughts)),
1096 {
MAP_CELL_STEP(38, 35, 2, 2, 5),
MAP_CELL_STEP(40, 35, 2, 2, 5),
1098 {
MAP_CELL_STEP(42, 35, 2, 2, 5),
MAP_CELL_STEP(44, 35, 2, 2, 5),
1100 {
MAP_CELL_STEP(46, 33, 2, 2, 5),
MAP_CELL_STEP(48, 33, 2, 2, 5),
1102 {
MAP_CELL_STEP(46, 35, 2, 2, 5),
MAP_CELL_STEP(48, 35, 2, 2, 5),
1104 {
MAP_CELL_STEP(50, 33, 2, 2, 5),
MAP_CELL_STEP(52, 33, 2, 2, 5),
1106 {
MAP_CELL_STEP(50, 35, 2, 2, 5),
MAP_CELL_STEP(52, 35, 2, 2, 5),
1108 {
MAP_CELL_STEP(42, 33, 4, 2, 5),
MAP_CELL_STEP(38, 33, 4, 2, 5),
1110 {
MAP_CELL_STEP(54, 33, 2, 2, 5),
MAP_CELL_STEP(56, 33, 2, 2, 5),
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.
const s32 * gEffectScripts[]
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
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.
Field effects, their scripts and the flags that spawn them.
#define SCRIPT_REPEAT(count, label)
#define SCRIPT_SET_POSITION(x, y, z)
#define SCRIPT_WAIT(frames)
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
s32 Engine_LeaderCheckAhead(void)
static void Actor_SetDestination(s32 actor, s32 x, s32 z)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
static void Map_AnimateCells(const u16 *steps, s32 destX, s32 destY)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
void Engine_PsynergyBegin(s32 ability, s32 flags)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_MessageShowCentered(s32 message, s32 flags)
void Engine_ObjectSetPartPalettes(struct FieldActor *object, s32 palette)
s32 Engine_PartyGiveItem(s32 item, s32 flags)
void Engine_PsynergyRaiseHands(void)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
void Engine_PsynergyLowerHands(void)
s32 Engine_MathSin(s32 angle)
#define MAP_CELL_STEP(srcX, srcY, width, height, frames)
void Engine_ItemShowFound(s32 item, s32 height)
static void Actor_SetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_EventCloseScreen(void)
static void Actor_FaceActor(s32 actor, s32 target, s32 frames)
static void Actor_WalkTo(s32 actor, s32 x, s32 z)
void Engine_PsynergyCancel(void)
void Engine_EventWaitForScreen(void)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
static void Actor_WalkByAndWait(s32 actor, s32 dx, s32 dz)
s32 Engine_EventAskYesNo(s32 speaker, s32 flags)
void Engine_EventOpenScreen(void)
s32 Engine_EventOpenMessage(s32 speaker, s32 flags)
void Engine_GameFlagSet(s32 flag)
void Engine_GameFlagClear(s32 flag)
void Engine_ActorWaitForMove(s32 actor)
void Engine_CameraFollowActor(s32 actor, s32 keep_position)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorStop(s32 actor)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
static void Event_PlayCue(s32 cue)
static void Map_CopyCells(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
#define MAP_CELL_STEPS_END
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_PsynergyPlayEffect(s32 effect)
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
s32 Engine_MathCos(s32 angle)
static void Actor_WalkBy(s32 actor, s32 dx, s32 dz)
static void Actor_CenterAndWalk(s32 actor, s32 priority, s32 dz)
static void MapObject_SetPosition(s32 object, s32 fixed_x, s32 fixed_z)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_EventWait(s32 frames)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
void Engine_PsynergySetTarget(s32 caster, s32 target)
static struct FieldActor * Actor_Get(s32 actor)
Field objects and actors, and the scene transition styles.
@ TRANSITION_BACKDROP_FADE
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
@ ACTOR_FALLS
falls by its gravity and bounces
#define SCENE_TRANSITION(style, variant)
The field's runtime work: map cells, scene records and regions, map markers and FieldWork.
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define PSYNERGY_IN_AREA(ability, phase)
@ SCENE_LUNPA_FORTRESS_GATE
#define SCENE_EXIT(exit, scene, entrance)
@ TALK_FACE_PARTY_AND_BACK
#define EVENT_SCRIPT(script)
#define FLAG_LUNPA_FORTRESS_THREE_GUARDS_BEATEN
#define FLAG_LUNPA_FORTRESS_HALL_GUARD_BEATEN
#define FLAG_SCENE_TEMP_43
#define FLAG_LUNPA_NUT_CAUGHT
the nut floating over the town
#define FLAG_LUNPA_PSYNERGY_STONE
#define FLAG_LUNPA_TRADE_REOPENED
#define FLAG_SCENE_TEMP_44
#define FLAG_SCENE_TEMP_40
#define FLAG_SCENE_TEMP_00
#define FLAG_LUNPA_FORTRESS_COLUMN_LOWERED
#define FLAG_SCENE_TEMP_02
#define FLAG_LUNPA_FORTRESS_FIRST_SWITCH_UNCOVERED
Whirlwind has blown away what hid the first switch, the passage and the second switch.
#define FLAG_LUNPA_CAVE_REUNION_SEEN
#define FLAG_KEEP_PARTY_POSITION
#define FLAG_LUNPA_GATE_GUARD_SAW_HAMMET
The gate's left guard has recognized Hammet with the party.
#define FLAG_GUARDS_SUSPECT_KALAY
Set on the world map; from then on the east guard asks whether the party came from Kalay.
#define FLAG_LUNPA_FORTRESS_SECOND_SWITCH_FLIPPED
#define FLAG_LUNPA_FORTRESS_WEST_GUARD_BEATEN
#define FLAG_SCENE_TEMP_01
#define FLAG_LUNPA_FORTRESS_FIRST_SWITCH_FLIPPED
#define FLAG_SCENE_TEMP_41
#define FLAG_LUNPA_FORTRESS_PASSAGE_UNCOVERED
#define FLAG_SCENE_TEMP_42
#define FLAG_LUNPA_FORTRESS_SECOND_SWITCH_UNCOVERED
#define FLAG_LUNPA_FORTRESS_EAST_GUARD_BEATEN
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
static void Event_EnterDoor(void)
The leader walks into a doorway: the door opens and the leader goes in.
static void Event_ComplainAboutCold(void)
Shivers and complains that the weather has become colder.
static void Event_EnterHiddenPassage(void)
The hidden passage to the jail, once opened and while Reveal shows it.
struct SceneEvent gGateEvents[]
static void Event_TalkToWestGuard(void)
The west guard of the town asks whether the party wants in.
static void Event_TalkToLeftGuard(void)
The gate's left guard: hears someone while the party is cloaked; after trade reopens,...
static void Event_GuardsBlockGate(void)
Coming close uncloaked, the guards step in front of the fortress door and the gateway closes.
static void Event_TalkToRightGuard(void)
The gate's right guard.
static void Event_EnterFortress(void)
Through the fortress door, out of the gate's top.
static void Event_AskAboutLengthOfStay(void)
Asks how long the party has been in Lunpa.
#define MIND_READ(actor, value)
static void Lunpa_KickUpLeaderDust(void)
Every 16 frames while the leader is thrown: a puff of dust.
struct SceneEvent gLunpaReopenedEvents[]
#define LUNPA_ROADS_AND_DOORS
static UNUSED void Lunpa_PlayRevealCue(void)
Reveal's sound when it uncovers something.
static void Lunpa_ApplyFrozenPuddleCollision(void)
Restores the frozen pillar's three collision cells, including its sides.
static void Event_HideSecrets(void)
Reveal's end, and every entry to the town: the secrets hide again.
u16 gLunpaDoorSteps[DOOR_COUNT][11]
static void Event_AskAboutHammetsKidnapping(void)
Asks whether Dodonpa kidnapped Hammet for ransom.
static void Event_GuardsThrowLeaderOut(void)
Entering the gate after being caught inside: the guards throw the leader out and down the steps.
static void Lunpa_CopyGatewayCollision(s32 sourceColumn, s32 sourceRow)
Copies one open or blocked source cell across the three-cell gateway.
static void Event_GuardsCatchParty(void)
Raised when the guards spot the party: they recognize the man with them, and march the party back dow...
struct SceneEntrance gGateEntrances[]
struct LunpaDoor gLunpaDoors[]
static void Lunpa_DrawHiddenPassageFrame(s32 sourceColumn, s32 sourceRow)
Draws the three map regions that make one frame of the hidden passage.
static void Event_CastCloak(void)
Cloak: the gateway closes behind the guards.
static void Lunpa_WatchForFortressApproach(void)
Every frame at the gate after trade reopens: stepping up to row 10 raises Garet's warning (trigger TR...
static void Event_PressHiddenSwitch(void)
Searching the switch Reveal shows: the passage opens in five steps.
static void Event_ReadRightGuardsThoughts(void)
static void Event_ReadEastGuardsThoughts(void)
static void Event_FreezeHiddenPuddle(void)
Frost on the puddle Reveal shows: it freezes into a pillar the party can stand on.
s32 gMediumEffectScript[]
struct SceneEvent gLunpaSealedEvents[]
static void Event_CloakFades(void)
Cloak fades: if the leader is still among the guards, they are caught.
static void Lunpa_ReopenGateway(void)
struct ScenePlacement gLunpaPlacements[]
static void Event_SearchWell(void)
static void Lunpa_WatchForUncloakedParty(void)
Every frame at the gate: an uncloaked leader in front of the guards is spotted.
static void UNUSED Lunpa_CheckAhead(void)
static void Event_TalkToEastGuard(void)
The east guard: wants authorization, or once the guards suspect Kalay, asks twice whether the party c...
static void Event_CatchFloatingNut(void)
Catch on the nut floating over the town: the party gets it.
struct SceneEntrance gLunpaEntrances[]
static void Event_RevealSecrets(void)
Reveal: the Psynergy Stone's spot, the hidden switch's glint, the puddle and, once opened,...
static void Event_GaretTurnsLeaderBack(void)
Garet reminds the leader they cannot go into the fortress, and the leader steps back.
#define GATE_ENTRANCE(entrance, x, z, facing)
#define TALK(actor, value)
struct ScenePlacement gGatePlacements[]
static void UNUSED Lunpa_DoNothing(void)
s32 gShortEffectScript[]
How long an effect of common/effect_spawn.h lasts: 22, 44 or 126 frames, then it moves away and is fr...
static void Event_LeaderSneaksOut(void)
Entering the gate after sneaking out of the fortress: the leader casts Cloak and slips around the gua...
static void Lunpa_UpdateIcePillarDrawOrder(void)
Every frame while the pillar stands: draw it under the leader once the leader is on top.
static void Event_AskAboutSeeingDonpa(void)
Asks whether the party wants to see Donpa.
#define LUNPA_ENTRANCE(entrance, x, z, facing)
static void Event_ReadLeftGuardsThoughts(void)
Mind Read on the left guard: before the cave reunion he thinks the man with the party looks like that...
static void Event_AskAboutFortressCommotion(void)
Offers to explain the commotion at the fortress.
@ PALETTE_TRANSLUCENT_EFFECT
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,...
Scene numbers, named after their places.
#define SE_HIDDEN_PASSAGE_OPEN
#define MUS_TREASURE_FOUND
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_EventSetMessage()
void Engine_EventShowMessage()
void Scene_FloatNut(s32 id)
Draws actor id as the Nut's icon and starts it floating, 32 pixels up unless the party returns to whe...
@ LUNPA_EXIT_TO_ARMS_SHOP
@ LUNPA_EXIT_TO_FIRST_HOME
@ LUNPA_EXIT_TO_THIRD_HOME
@ LUNPA_EXIT_TO_EIGHTH_ROOM
@ LUNPA_EXIT_TO_ITEM_SHOP
@ LUNPA_EXIT_TO_SECOND_HOME
@ LUNPA_EXIT_TO_WORLD_MAP
@ JAIL_ENTRANCE_FROM_LUNPA
@ FORTRESS_ENTRANCE_FROM_GATE
@ WORLD_MAP_ENTRANCE_FROM_LUNPA
@ CAVE_ENTRANCE_FROM_LUNPA
@ RECOGNITION_SEEN_THAT_MAN
@ CATCH_LEFT_GUARD_REFUSES_ENTRY
@ CATCH_RIGHT_GUARD_SENDS_PARTY_OFF
@ CATCH_LEFT_GUARD_CHALLENGES
@ CATCH_RIGHT_GUARD_WONDERS
@ TRIGGER_FORTRESS_APPROACH
@ MAP_OBJECT_PSYNERGY_STONE
@ GATE_ENTRANCE_THROWN_OUT
@ GATE_ENTRANCE_FROM_LUNPA
@ GATE_ENTRANCE_SNEAKING_OUT
@ GATE_ENTRANCE_FROM_FORTRESS
@ LUNPA_ENTRANCE_FROM_ITEM_SHOP
@ LUNPA_ENTRANCE_FROM_JAIL
@ LUNPA_ENTRANCE_FROM_THIRD_HOME
@ LUNPA_ENTRANCE_FROM_FIRST_HOME
@ LUNPA_ENTRANCE_FROM_GATE
@ LUNPA_ENTRANCE_FROM_CAVE
@ LUNPA_ENTRANCE_FROM_TEMPLE
@ LUNPA_ENTRANCE_FROM_INN
@ LUNPA_ENTRANCE_FROM_SECOND_HOME
@ LUNPA_ENTRANCE_FROM_WORLD_MAP
@ LUNPA_ENTRANCE_FROM_EIGHTH_ROOM
@ LUNPA_ENTRANCE_FROM_ARMS_SHOP
@ TRIGGER_FIRST_HOME_DOOR
u16 message
the next message, advanced as each window opens
A field actor: a person or thing on the field with a position, motion toward a target,...
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
union FieldCoordinate z
16.16 fixed-point pixels
s32 scaleX
16.16 fixed point, 0x10000 full size
s32 scaleY
16.16 fixed point, 0x10000 full size
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
Full event work allocated by Field_RunScene (heap slot 27).
s16 event
A raised event for Scene_RunRaisedEvent, or -1 when characters fell to poison or hazard damage,...
s16 command
a field Psynergy to use, as owner << 10 | Psynergy
s32 transition
SCENE_TRANSITION(style, variant); 0x100 on entry.
s16 action
The twelve requests: each nonzero value asks the field loop for one thing; Field_ClearRequests clears...
s16 cloaked
1 under Cloak, which prevents battles
s16 retreatEntrance
where Retreat goes; the group's first entrance
One house door: the cell animation that opens it and where it plays.
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
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,...
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
The integer types, TRUE, UNUSED and the fixed-address macros.
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels
The patch levels: our groups of the measured changes from the Japanese release.