Alchemy

field_fx.c

Showing a found item, and Reveal's sparkles on hidden things.

games/tbs/src/object/object/field_fx.c on GitHub

Showing a found item, and Reveal's sparkles on hidden things. Part of object.c, the field object, compiled only through it.

Functions

Marker_MoveLeaderAway

void Marker_MoveLeaderAway(void)

Keeps the party leader off the markers: a leader within 16 pixels of a marker cell's centre is moved 20 pixels from that centre, in the direction it stood, and loses its move target. Only the first marker it stands on moves it. Called by two scene overlays (Suhalla Desert, Lamakan Desert).

Used by Reveal_ShowSecrets.

Line 47

Object_InitializeSparkle

static inline void Object_InitializeSparkle(struct ObjectRuntime *obj)

Starts the particle script and its first child at priority 1, if the spawn succeeded. Allocation failure leaves the effect absent. The script sinks the sparkle a quarter pixel a frame for 60 frames, then frees it.

Used by ItemDisplay_EmitSparkles, RevealMarker_EmitSparkles.

Line 89

ItemDisplay_EmitSparkles

void ItemDisplay_EmitSparkles(union FieldObject *fieldObject)

Each frame of a found item's picture: one time in ten, a sparkle appears within 16 pixels of it. Installed as the picture's updateHook by BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence and BattleFx_StartEffectObject22.

Used by BattleFx_StartEffectObject22, BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence.

Line 104

BattleFx_StartRandomParticleEmitter

struct EffectObj *BattleFx_StartRandomParticleEmitter(s32 actor, s32 item)

Shows the picture of item (0 for none) at the centre of the cell 16 pixels in front of character actor, at a height of 16 pixels whatever the actor's, with sparkles. While Reveal is active, its marks and sparkles are cleared first. Returns the picture's actor, or 0 without the actor or a free object. The picture is object 22, thrown up (velocityY 2 << 16, gravity 0x4000: it rises for 8 frames) while it grows to full size, its icon drawn through heap block 17, which is released again, and loaded into VRAM. The caller owns the picture: Field_SearchTile releases it once the find is told. Called by Field_SearchTile for coins and items found, and by BattleFx_PlayCueAndStartEmitterOnTarget.

Used by BattleFx_PlayCueAndStartEmitterOnTarget, Field_SearchTile.

Line 140

Object_DestroyIfPresent

void Object_DestroyIfPresent(void *object)

Releases object unless it is NULL. Called by Field_SearchTile to drop the picture of an item nobody could carry.

Used by Field_SearchTile.

Line 222

ItemDisplay_RaiseAboveLeader

void ItemDisplay_RaiseAboveLeader(struct ObjectRuntime *object)

Raises a found item's picture to 36 pixels above the party leader, who holds it up (animation 28) facing the screen. Called by Field_SearchTile for what a search finds, by EffectRuntime_RunRisingObjectSequence and by BattleFx_StartEffectObject22.

Used by BattleFx_StartEffectObject22, EffectRuntime_RunRisingObjectSequence, Field_SearchTile.

Line 231

EffectRuntime_RunRisingObjectSequence

void EffectRuntime_RunRisingObjectSequence(void *object, s32 flags)

Shows a found item's picture: flags bit 0 adds sparkles and bit 1 raises it above the leader, with waits of 60 and 80 frames around that when both are set. The leader then returns to animation 1. Scene overlays call it as Engine_RunRisingObjectSequence (six of them).

Line 256

BattleFx_StartEffectObject22

void BattleFx_StartEffectObject22(s32 item, s32 flags)

Shows the picture of item 36 pixels above the party leader for 80 frames; flags bit 0 adds sparkles and bit 1 raises it as a found item. Then it releases the picture and the leader returns to animation 1. Scene overlays call it as Engine_ItemShowFound (41 of them). When no object is free, heap block 17, taken for the icon, is not released (the scene change's heap reset frees it).

Line 287

BattleFx_ClearRandomParticles

void BattleFx_ClearRandomParticles(void)

While Reveal is active, destroys all its sparkles, leaving its marks. Called by the field menu (Menu_RunTopSelection, window/selection.c) each time Menu_SelectTopEntry returns, a cancel included, while Reveal is active.

Line 333

RevealMarker_EmitSparkles

void RevealMarker_EmitSparkles(union FieldObject *fieldObject)

Each frame of a Reveal marker: one time in ten, a sparkle appears within 16 pixels of it. Installed as the marker's updateHook by FieldEffect_SpawnNearbyMarkers.

Used by BattleFx_StartRandomParticleEmitter, FieldEffect_SpawnNearbyMarkers.

Line 354

Field_IsRevealActive

s32 Field_IsRevealActive(struct ScriptInterpreter *interpreter)

Returns 1 while Reveal is active, else 0. Run by a Reveal marker's object script (gBattleFx_MarkerParticleScript) through SC_CALL: the marker stays while it returns 1 and frees itself once it returns 0.

Used by gBattleFx_MarkerParticleScript.

Line 380

FieldEffect_SpawnNearbyMarkers

void FieldEffect_SpawnNearbyMarkers(void)

Reveal: marks with sparkles the hidden things within 8 cells left or right and 5 up or down of the leader: map places 100 to 239 with no marker actor, whose search event (kind 3) gives an item, coins, a Psynergy stone or a mimic (types 0 to 3 and 5) and whose flag is not yet set. Each mark is an object 22 running gBattleFx_MarkerParticleScript. Called by Reveal's effect (psynergy_effects/reveal.c).

Used by FieldFx_RunReveal.

Line 399

Structures

EffectObj

struct EffectObj

An object of the 64-object pool (struct ObjectRuntime, 0x70 bytes), seen as the found item's picture, the sparkles and the Reveal marks use it.

FieldDeclared as
scriptWords32 scriptWordThe script pointer, as a word; 0 while the pool object is free.
pad0u8 pad0[0x24]
velocityYs32 velocityY16.16 fixed-point pixels a frame; up is positive
pad1u8 pad1[0x1c]
gravitys32 gravity16.16 fixed-point pixels taken off velocityY each frame while the object falls (motion bit 1); 0x10000 when created.
pad2u8 pad2[4]
animationstruct AnimationObject *animation
pad3u8 pad3[24]
updateHookvoid (*updateHook)(union FieldObject *object)frame hook at offset 0x6c

Used by BattleFx_ClearRandomParticles, BattleFx_StartEffectObject22, BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence, FieldEffect_SpawnNearbyMarkers.

Line 13

Macros

EFFECT_OBJECT_COUNT

#define EFFECT_OBJECT_COUNT 64

ObjectSystem_Initialize allocates 64 ObjectRuntime records in heap slot 5.

Used by BattleFx_ClearRandomParticles, BattleFx_StartRandomParticleEmitter.

Line 32

#define MENU_OPEN_OFFSET 0xcca

In gEventWork, the byte after queuedSound: Menu_RunTopSelection sets it once Menu_SelectTopEntry first returns, a cancel included, and clears it as it returns.

Used by RevealMarker_EmitSparkles.

Line 328

Also, macros without a comment: EFFECT_OBJECT_POOL, EFFECT_OBJECT_POOL, SPARKLE_OBJECT_ID, PARTICLES_PAUSE_FOR_MENU.

On this page