Skip to Content
The Alchemy Project

src/field/field_engine_treasure_spots.c

The map's treasure spots: chests and Psynergy Stones. More…

Included by field_engine.c.

Enumerations

NameDescription
enumanonymous enum { OAM_SIZE_16X8, OAM_SIZE_16X16 }OAM attribute 1's sizes (GBATEK "OBJ Attributes"): an OBJ_SHAPE_HORIZONTAL sprite of size 0 is 16 by 8 pixels, an OBJ_SHAPE_SQUARE one of size 1 16 by 16.

Functions

NameDescription
voidfdActorSnapToTerrain (void *actorPtr)Sets an actor's y and groundHeight to the map's height at its x and z.
Sint16 *fdSceneItemGetRows (void)The current scene's rows of the scene item table (SceneItems): those after the first header for this scene whose flag is -1 or not yet set, or NULL.
Sint32fdSceneItemFindPos (Sint32 value, Sint32 *out)Clears out, then fills it with the position of scene point value; returns 0 when the point was found, else -1.
voidfdPlaceTreasureSpots (void)Places an actor at each of the map's treasure spots (ids 100 to 239) that the scene has a script for, up to sixteen: a chest for a chest script, shown open once its flag is set and gone once its mimic was beaten, and a Psynergy Stone for an examine cue giving one, until it is taken.
voidfdActorSetWideSprite (Uint32 actorId, Sint32 mode)TREASURE_SPOT_PUT_AWAY moves the actor to x and z 0 and marks it with sceneWord TREASURE_SPOT_ON_METATILE; any other mode draws its sprite wide, 16 by 8 pixels, 4 pixels lower.
voidfdActorSetSquareSprite (Uint32 actorId)Draws the actor's sprite square, 16 by 16 pixels, 8 pixels down.
Sint32fdActorGetSpriteShape (Uint32 actorId)Returns the OAM shape of the actor's sprite (0 square, 1 wide, 2 tall), or 0 without one.
voidfdActorReturnHome (Sint32 mode, Uint32 actorId, Sint32 flag)RETURN_HOME_CLEAR_Z moves the actor to z 0; RETURN_HOME_DUG_UP sets flag, draws a moved actor square again and drops it back home (homeX, homeZ) at Scoop's anchor.
voidfdActorShakeAngle (Uint32 actorId)Shakes the actor's facing at random for 16 ticks, then turns it back.
voidfdTreasureSpotCloseChest (Uint32 actorId)Closes the chest of the actor again (its item could not be carried), with SE_CHEST_CLOSE, and waits 12 ticks.
voidfdTreasureSpotLaunchMimic (Uint32 actorId)Makes the chest of the actor jump up as a mimic: after 18 ticks it takes TREASURE_SPOT_CHEST_MIMIC, plays SE_ENEMY_CRY and gets an upward velocity of 8 pixels a tick, its shadow shown.
voidfdTreasureSpotOpenChest (Uint32 actorId)Opens the chest of the actor with SE_CHEST_OPEN, and waits 12 ticks.
voidfdTreasureSpotShowOpened (Uint32 actorId)Shows the chest of the actor open, with no sound.
voidfdTreasureSpotOpenEmptyChest (Uint32 actorId)Opens the empty chest of the actor with SE_CHEST_OPEN, and waits 12 ticks.
ACTOR *fdTreasureSpotGetActor (Uint32 actorId)Returns the actor, or NULL.
voidfdTreasureSpotRemove (Uint32 actorId)Releases the actor and empties its slot.
voidfdTreasureSpotSetActorPos (Uint32 actorId, FIXED x, FIXED z)Moves the actor to (x, z) on the ground, 16.16 pixels; -1 keeps its home (homeX, homeZ) on that axis.

Description

The map's treasure spots: chests and Psynergy Stones. Part of field_engine.c.

Enumerations in detail

anonymous enum

enum { OAM_SIZE_16X8, OAM_SIZE_16X16 }

OAM attribute 1's sizes (GBATEK "OBJ Attributes"): an OBJ_SHAPE_HORIZONTAL sprite of size 0 is 16 by 8 pixels, an OBJ_SHAPE_SQUARE one of size 1 16 by 16.

EnumeratorValueDescription
OAM_SIZE_16X80with OBJ_SHAPE_HORIZONTAL
OAM_SIZE_16X161with OBJ_SHAPE_SQUARE

Definition at line 169 of file field_engine_treasure_spots.c.

Functions in detail

fdActorSnapToTerrain

void fdActorSnapToTerrain(void *actorPtr)

Sets an actor's y and groundHeight to the map's height at its x and z.

References fdMapGridGetTerrainHeightStub() and Sint32.

Definition at line 6 of file field_engine_treasure_spots.c.

fdSceneItemGetRows

Sint16 *fdSceneItemGetRows(void)

The current scene's rows of the scene item table (SceneItems): those after the first header for this scene whose flag is -1 or not yet set, or NULL.

References MainRoutineStateWork, SceneItems, Sint32 and syGameFlagGet().

Referenced by fdEffectSpawnRevealMarkers(), fdPlaceTreasureSpots() and fdTalkToActor().

Definition at line 19 of file field_engine_treasure_spots.c.

fdSceneItemFindPos

Sint32 fdSceneItemFindPos(Sint32 value, Sint32 *out)

Clears out, then fills it with the position of scene point value; returns 0 when the point was found, else -1.

References fdScenePointGetPos() and Sint32.

Referenced by fdEffectSpawnRevealMarkers() and fdPlaceTreasureSpots().

Definition at line 49 of file field_engine_treasure_spots.c.

fdPlaceTreasureSpots

void fdPlaceTreasureSpots(void)

Places an actor at each of the map's treasure spots (ids 100 to 239) that the scene has a script for, up to sixteen: a chest for a chest script, shown open once its flag is set and gone once its mimic was beaten, and a Psynergy Stone for an examine cue giving one, until it is taken.

References fdActorCreateStub(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdActorShowItemIconById(), fdMapGridGetTerrainHeightStub(), fdSceneItemFindPos(), fdSceneItemGetRows(), MapGridMetatileBuffer, Sint32 and syGameFlagGet().

Referenced by fdEngineRun().

Definition at line 59 of file field_engine_treasure_spots.c.

fdActorSetWideSprite

void fdActorSetWideSprite(Uint32 actorId, Sint32 mode)

TREASURE_SPOT_PUT_AWAY moves the actor to x and z 0 and marks it with sceneWord TREASURE_SPOT_ON_METATILE; any other mode draws its sprite wide, 16 by 8 pixels, 4 pixels lower.

References fdActorLookup() and Sint32.

Referenced by scInit() and scYampiDesertSetUpPuddles().

Definition at line 178 of file field_engine_treasure_spots.c.

fdActorSetSquareSprite

void fdActorSetSquareSprite(Uint32 actorId)

Draws the actor's sprite square, 16 by 16 pixels, 8 pixels down.

References fdActorLookup().

Referenced by fdActorReturnHome().

Definition at line 202 of file field_engine_treasure_spots.c.

fdActorGetSpriteShape

Sint32 fdActorGetSpriteShape(Uint32 actorId)

Returns the OAM shape of the actor's sprite (0 square, 1 wide, 2 tall), or 0 without one.

References fdActorLookup() and Sint32.

Referenced by fdTalkToActor().

Definition at line 220 of file field_engine_treasure_spots.c.

fdActorReturnHome

void fdActorReturnHome(Sint32 mode, Uint32 actorId, Sint32 flag)

RETURN_HOME_CLEAR_Z moves the actor to z 0; RETURN_HOME_DUG_UP sets flag, draws a moved actor square again and drops it back home (homeX, homeZ) at Scoop's anchor.

References fdActorLookup(), fdActorSetSquareSprite(), fdScoopDropFromHand(), Sint32 and syGameFlagSet().

Referenced by fdScriptDigUpTreasure() and scYampiDesertDigUpTreasure().

Definition at line 239 of file field_engine_treasure_spots.c.

fdActorShakeAngle

void fdActorShakeAngle(Uint32 actorId)

Shakes the actor's facing at random for 16 ticks, then turns it back.

References fdActorLookup(), Sint32, syRandom() and sySynch().

Definition at line 260 of file field_engine_treasure_spots.c.

fdTreasureSpotCloseChest

void fdTreasureSpotCloseChest(Uint32 actorId)

Closes the chest of the actor again (its item could not be carried), with SE_CHEST_CLOSE, and waits 12 ticks.

References fdActorLookup(), fdActorSelectAnimationStub(), sySoundPlayStub() and sySynch().

Referenced by fdTalkToActor().

Definition at line 287 of file field_engine_treasure_spots.c.

fdTreasureSpotLaunchMimic

void fdTreasureSpotLaunchMimic(Uint32 actorId)

Makes the chest of the actor jump up as a mimic: after 18 ticks it takes TREASURE_SPOT_CHEST_MIMIC, plays SE_ENEMY_CRY and gets an upward velocity of 8 pixels a tick, its shadow shown.

References fdActorLookup(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), sySoundPlayStub() and sySynch().

Referenced by fdTalkToActor().

Definition at line 298 of file field_engine_treasure_spots.c.

fdTreasureSpotOpenChest

void fdTreasureSpotOpenChest(Uint32 actorId)

Opens the chest of the actor with SE_CHEST_OPEN, and waits 12 ticks.

References fdActorLookup(), fdActorSelectAnimationStub(), sySoundPlayStub() and sySynch().

Referenced by fdTalkToActor().

Definition at line 314 of file field_engine_treasure_spots.c.

fdTreasureSpotShowOpened

void fdTreasureSpotShowOpened(Uint32 actorId)

Shows the chest of the actor open, with no sound.

References fdActorLookup() and fdActorSelectAnimationStub().

Referenced by fdTalkToActor().

Definition at line 323 of file field_engine_treasure_spots.c.

fdTreasureSpotOpenEmptyChest

void fdTreasureSpotOpenEmptyChest(Uint32 actorId)

Opens the empty chest of the actor with SE_CHEST_OPEN, and waits 12 ticks.

References fdActorLookup(), fdActorSelectAnimationStub(), sySoundPlayStub() and sySynch().

Referenced by fdTalkToActor().

Definition at line 330 of file field_engine_treasure_spots.c.

fdTreasureSpotGetActor

ACTOR *fdTreasureSpotGetActor(Uint32 actorId)

Returns the actor, or NULL.

References fdActorLookup().

Referenced by fdEffectSpawnRevealMarkers() and fdTalkToActor().

Definition at line 339 of file field_engine_treasure_spots.c.

fdTreasureSpotRemove

void fdTreasureSpotRemove(Uint32 actorId)

Releases the actor and empties its slot.

References fdActorReleaseAtIndex().

Referenced by fdTalkToActor().

Definition at line 345 of file field_engine_treasure_spots.c.

fdTreasureSpotSetActorPos

void fdTreasureSpotSetActorPos(Uint32 actorId, FIXED x, FIXED z)

Moves the actor to (x, z) on the ground, 16.16 pixels; -1 keeps its home (homeX, homeZ) on that axis.

References fdActorLookup() and fdMapGridGetTerrainHeightStub().

Referenced by fdTreasureSpotSetPos() and scNaribweHideChest().

Definition at line 352 of file field_engine_treasure_spots.c.