dispatch.c
Running a field Psynergy by its kind, and helpers its effects share.
games/tbs/src/object/psynergy_effects/dispatch.c on GitHub
Running a field Psynergy by its kind, and helpers its effects share. Part of psynergy_effects.c, compiled only through it.
Functions
Field_DispatchTypeHandler
void Field_DispatchTypeHandler(s32 kind)
Runs one step of the current Psynergy effect: 0 casts it with no target, 1 casts it on its target (secondObjectId), 2 finishes it and 3 runs its kind's extra handler. Exported as Field_DispatchTypeHandlerFar; Goma Cave's entrance imports it and passes 1 to play Whirlwind on the stump's ivy from its own event.
Used by GomaCaveEntrance_WhirlwindOnStumpIvy.
BattleFx_Run
void BattleFx_Run(void)
Casts the current Psynergy effect with no target: runs the body of its kind (scene->fieldKind).
Called by Field_UsePsynergy when no scene event names a target (FLAG_PSYNERGY_TARGET clear), by Field_UseItem for an item with a field action, and by Field_DispatchTypeHandler(0). Halt also moves gGameState.pausedObject to the actor it stops.
Used by Field_DispatchTypeHandler, Field_UseItem, Field_UsePsynergy.
BattleFx_DispatchRequestKind
void BattleFx_DispatchRequestKind(void)
Casts the current Psynergy effect on its target (secondObjectId): runs the handler of its kind.
Called by Field_UsePsynergy when a scene event names the target (FLAG_PSYNERGY_TARGET still set after the before event), and by Field_DispatchTypeHandler(1). Clears scene->enabled first: that is how the runners BattleFx_Run shares (Force, Frost, Ply, Whirlwind, Catch) tell that a scene event decides what happens to the target. Halt also moves gGameState.pausedObject to the target.
Used by Field_DispatchTypeHandler, Field_UsePsynergy.
BattleFx_ClearChildValueOnMismatch
void BattleFx_ClearChildValueOnMismatch(void)
Finishes the current effect when it is Mind Read: ends the effect and lets its target move again, unless the target is the object kept stopped. Called by Field_UsePsynergy after the after event, and by Field_DispatchTypeHandler(2): Mind Read is the one kind whose effect stays up through the after event, the conversation it reads.
Used by Field_DispatchTypeHandler, Field_UsePsynergy.
FieldEvent_RunTypeHandler
void FieldEvent_RunTypeHandler(void)
The extra handler of Reveal, Cloak and Avoid: what each does when it ends. Called by Field_RunPsynergyEvents, which ends a Psynergy that runs out by itself, and by Field_DispatchTypeHandler(3).
Used by Field_DispatchTypeHandler, Field_RunPsynergyEvents.
Field_RunEventAction
s32 Field_RunEventAction(const void *event, s32 param, s32 target)
Runs the event tied to an effect: a result below 0x10000 is a message, shown at target; a larger one is a routine, called with param and target (through r3). Afterwards, with FLAG_NOTHING_HAPPENS set, says "But nothing happens.". Returns 0.
Called by Field_UsePsynergy and Field_RunPsynergyEvents for the before and after events, and by Force, Frost and Reveal for the events of their own phases.
Used by FieldFx_RunForce, FieldFx_RunFrost, FieldFx_RunReveal, Field_RunPsynergyEvents, Field_UsePsynergy, ResetSceneTransitionEffect.
ObjectGroup_ApplyRandomChildValues
void ObjectGroup_ApplyRandomChildValues(union FieldObject *fieldObject)
Per-frame update: sets every part of an object's sprite to param frame % 6, which cycles its colours. Move, Lift and Carry give it to the target they hold, Retreat to its caster. A sprite that keeps its VRAM cache entry (retainCacheEntry) is left alone.
Used by BattleFx_SteerLiftedTarget, BattleFx_SteerPushedTarget, FieldFx_RunLiftOnTarget, FieldFx_RunRetreat.
Motion_SetTargetPositionFromMagnitudeAngle
void Motion_SetTargetPositionFromMagnitudeAngle(struct ObjectRuntime *object, s32 magnitude, s32 angle)
Sends an object toward the point magnitude (16.16 pixels) away from it in direction angle: sets its move target. Carry, Lift, Douse, Move and the Djinni's hop into battle throw things this way.
Used by BattleFx_RunVenusDjinnCapture, BattleFx_StartItemBreak, BattleFx_SteerLiftedTarget, Djinn_RunBattleStartHop, FieldFx_RunLiftOnTarget, FieldFx_RunPly, FieldFx_SpawnRandomAngleTriplet, SpawnHeavyImpactEffect, UpdateRisingParticleBurst.
ResourceTable_CountFreeBlocks
s32 ResourceTable_CountFreeBlocks(void)
Counts the free blocks (owner 0xff) of the 512 resource blocks. BattleFx_LoadActionEffectResources subtracts this from VRAM_BLOCK_COUNT to record the blocks already occupied before the effect starts.
Used by BattleFx_LoadActionEffectResources.
Sprite_ShareVramCache
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 its block. Retains the shared cache entry and returns the sprite whose block is shared from now on (sharedSprite, or sourceSprite when there was none), or NULL for no sourceSprite. Chains of afterimages pass one block along this way. Each sprite retains the entry so releasing an afterimage cannot free graphics still used by the others. Sprite teardown leaves the shared entry for the caller to release.
Used by BattleFx_RunMercuryDjinnCapture, Djinn_RunBattleStartHop, FieldFx_RunForce, FieldFx_RunPly, KolimaForestTree_SpawnOrbitSparks, TretTreeInteriors_SpawnSwirlSparks.
Object_Spawn
struct ObjectRuntime *Object_Spawn(s32 kind, s32 x, s32 y, s32 z)
Creates an object for an effect, at the caster's ground height, with sprite priority 0 and animation 1. An object without animation is released and NULL returned. The effects spawn their orbs, hands and particles through it, and check for NULL: the object table may be full. The object floats (motion flags 4), is depth-sorted as if 320 pixels lower (priority flag bit 2) and has no shadow; its creator releases it, or its script frees it.
Used by BattleEffect_RunFallbackObjectTransition, BattleEffect_SpawnBurstParticleField, BattleFx_RunSparkEmitter, BattleFx_RunVenusDjinnCapture, BattleFx_SpawnFallingParticles, BattleFx_SpawnItemBreakMode1, BattleFx_SpawnItemBreakMode3, BattleFx_StartItemBreak, BattleFx_SteerLiftedTarget, BattleFx_UpdateItemBreakFragment, FieldFx_RunCatch, FieldFx_RunDouse, FieldFx_RunForce, FieldFx_RunFrost, FieldFx_RunGrowth, FieldFx_RunPly, FieldFx_RunWhirlwind, FieldFx_SpawnRandomAngleTriplet, ItemDisplay_EmitSparkles, RevealMarker_EmitSparkles, SpawnHeavyImpactEffect, UpdateRisingParticleBurst.
ObjectGroup_SetActionForOthers
void ObjectGroup_SetActionForOthers(struct ObjectRuntime *except, s32 state, s32 value)
Sets the movement state and animation timer steps of every object but the player's and except. EventObject_Initialize stops them (state 1, speed 0) while an effect plays and lets them go again (state 0, speed 0x10).
Used by EventObject_Initialize.