setup.c
An effect's work: setting it up, its caster and target, cleaning up.
games/tbs/src/object/psynergy_effects/setup.c on GitHub
An effect's work: setting it up, its caster and target, cleaning up. Part of psynergy_effects.c, compiled only through it.
Functions
BattleFx_UpdateAllEffectSlots
void BattleFx_UpdateAllEffectSlots(void)
Scheduler callback: updates the 24 effect slots.
Used by BattleEffect_CleanupSceneObjects, BattleFx_LoadActionEffectResources.
BattleFx_LoadActionEffectResources
void BattleFx_LoadActionEffectResources(s32 abilityId, s32 mode)
Prepares the work of the Psynergy effect for ability (heap slot 56) and loads its spark tiles. Called again while an effect resolves, it only switches the ability.
Field_UsePsynergy and the item uses (object/items.c) call it before an effect and BattleEffect_CleanupSceneObjects after it, which releases the work, the spark tiles' resource entry and the scheduler callback started here. Goma Cave's entrance calls it too, for Ivan's Whirlwind on the stump's ivy. The caster is the leader, with no target until BattleFx_SetupObjectPair names one.
Used by Field_RunPsynergyEvents, Field_UseItem, Field_UsePsynergy, GomaCaveEntrance_WhirlwindOnStumpIvy.
BattleFx_SetupObjectPair
void BattleFx_SetupObjectPair(s32 userId, s32 targetId)
Records the caster and the target of an effect. With no target, the effect takes place 16 pixels in front of the caster (facing to the nearest quarter turn). work->angle becomes that facing, the way the effects aim. A target's update hook, script and first sprite's param are saved, for the effects that take it over to restore.
Used by BattleFx_LoadActionEffectResources, BattleFx_Run, Field_RunPsynergyEvents, Field_UsePsynergy, GomaCaveEntrance_WhirlwindOnStumpIvy.
EffectRuntime_StopCurrentObject
void EffectRuntime_StopCurrentObject(void)
Stops the caster's per-frame hook and restores its colours (sprite param 0), then waits a frame.
Used by BattleFx_SteerPushedTarget, EventObject_Initialize, FieldFx_RunPlyOnTarget, Field_RunPsynergyEvents, Field_UsePsynergy, GomaCaveEntrance_WhirlwindOnStumpIvy.
BattleEffect_CleanupSceneObjects
void BattleEffect_CleanupSceneObjects(void)
Ends a Psynergy effect: frees the effect slots still in use and, unless another effect is being resolved, waits (at most 30 frames) for the swelling arcs to end, stops the slot callback, releases the effect's tiles, restores the map's shake, plays the queued sound and releases the effect's work.
Used by Event_MeetFlint, Field_RunPsynergyEvents, Field_UseItem, Field_UsePsynergy, Imil_MiaCastsPlyOnOldMan, Kolima_FinishReadingThoughts, MercuryLighthouseAerie_AlexCastsPly, Scene_EndCutscenePsynergy, ValeBabi_DemonstrateCatch, VaultInteriors_EndMindRead.
EventObject_Initialize
void EventObject_Initialize(void)
Starts casting: the caster takes its casting pose (animation 20) and stops. Unless the effect is silent the caster flashes with a sound; unless it is quiet, the ability's name is shown while every other object stands still. With flag 0x140 the caster's colours keep cycling and it takes pose 21; otherwise the caster's hook stops. Sets the field work's castStarted, which BattleEffect_CleanupSceneObjects clears. Called by Field_UsePsynergy and Goma Cave's entrance once the effect's caster and target are set up.
Used by Field_UsePsynergy, GomaCaveEntrance_WhirlwindOnStumpIvy.
BattleEffect_InitializeSharedScene
void BattleEffect_InitializeSharedScene(void)
Saves the palettes for the effect and fades them toward one of the eight effect colours (gBattleFx_TargetColors), picked by the frame counter or forced by flags 0x148 to 0x14f, over 8 frames. Most field Psynergy effects open with it, and BattleFx_PrepareBufferInterpolation fades back.
Used by BattleEffect_RunFallbackObjectTransition, BattleEffect_SpawnBurstParticleField, BattleFx_SteerLiftedTarget, BattleFx_SteerPushedTarget, FieldFx_RunCatch, FieldFx_RunDouse, FieldFx_RunForce, FieldFx_RunFrost, FieldFx_RunLiftOnTarget, FieldFx_RunMove, FieldFx_RunPly, FieldFx_RunRetreat, FieldFx_RunWhirlwind, RunSceneTransitionEffect.
BattleFx_PrepareBufferInterpolation
void BattleFx_PrepareBufferInterpolation(void)
Fades the palettes back from an effect's colours to the saved ones over 8 frames; while Reveal is active the BG half fades to Reveal's grey instead (PALETTE_TRANSFORM_GREY, 0x10001).
Used by BattleEffect_RunFallbackObjectTransition, BattleFx_FinishSceneAndReleaseHeapBlock, BattleFx_SteerLiftedTarget, BattleFx_SteerPushedTarget, FieldFx_RunCatch, FieldFx_RunDouse, FieldFx_RunForce, FieldFx_RunFrost, FieldFx_RunGrowth, FieldFx_RunGrowthOnTarget, FieldFx_RunLiftOnTarget, FieldFx_RunMove, FieldFx_RunPly, FieldFx_RunRetreat, FieldFx_RunWhirlwind.
Macros, without a comment: SETUP_OBJECT_SLOTS.