Alchemy

positions.c

Effect positions, projection and id dispatch helpers.

games/tbs/src/effect/parts/positions.c on GitHub

Effect positions, projection and id dispatch helpers. Part of effect.c, the battle effect object, compiled only through it.

Functions

EffectStep_AdvanceWithGravity3D

void EffectStep_AdvanceWithGravity3D(struct EffectStep *step, s32 damping, s32 gravity)

Moves a particle one frame in three dimensions: adds its velocity, then gravity to its vertical speed, then damps every speed by damping / 64.

Called each frame for the 3D sparks, motes, shards and shells of 18 parts, from the casting impacts, the beam sequences and the burst scene to the lobbed shells and the stat reductions; each then projects the particle with EffectPosition_ProjectPoint. Changes only the step.

Used by BattleFx_RunAnnihilation, BattleFx_RunBeamSequence, BattleFx_RunBurstScene, BattleFx_RunCastingImpact, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDrain, BattleFx_RunEruption, BattleFx_RunGatheringLights, BattleFx_RunHail, BattleFx_RunJudgment, BattleFx_RunLobbedShells, BattleFx_RunMoteFountain, BattleFx_RunParticleStreams, BattleFx_RunRingAndSparkScene, BattleFx_RunRushingStrike, BattleFx_RunStatReduction, BattleFx_RunStreakVolley, BattleFx_RunSwirlingStars, BattleFx_RunTargetBursts, BattleFx_RunTargetStrike.

Line 29

EffectStep_AdvanceWithGravity2D

void EffectStep_AdvanceWithGravity2D(struct EffectStep *step, s32 damping, s32 gravity)

Moves a particle one frame on the screen: adds its velocity, then gravity to its vertical speed, then damps both speeds by damping / 64.

Called each frame for the screen-space sparks, motes, chips and puffs of 20 parts, among them Thor, Spire, Ramses, Ragnarok, the Titan Blade, the Helm Splitter, the Djinn attacks and the projectile volleys. Changes only the step; z and velocityZ are left alone.

Used by BattleFx_RunBolt, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunCybele, BattleFx_RunDjinniEntrance, BattleFx_RunDouse, BattleFx_RunHelmSplitter, BattleFx_RunImpactBurst, BattleFx_RunJupiter, BattleFx_RunMars, BattleFx_RunMercury, BattleFx_RunNeptune, BattleFx_RunPlasma, BattleFx_RunPrism, BattleFx_RunProjectileVolley, BattleFx_RunRagnarok, BattleFx_RunRamses, BattleFx_RunRay, BattleFx_RunShatteringOpening, BattleFx_RunSparkGroups, BattleFx_RunSpire, BattleFx_RunTargetStrike, BattleFx_RunThor, BattleFx_RunTitanBlade, BattleFx_RunUndeadSword, BattleFx_RunVenus.

Line 46

EffectPosition_ProjectPoint

s32 EffectPosition_ProjectPoint(const void *point, struct EffectPosition *position)

Projects a point in the current transform onto the screen, 16 pixels higher, and returns the projection's scale.

The common way an effect places a 3D particle: 35 parts call it each frame once it has set the view, the casting impacts, beams, Judgment, Procne and the stat changes most often. Only Astral Blast (stars.c) reads the scale, to size its stars by depth.

point: three s32s in 16.16, x, y and z (an EffectStep's position).

Used by BattleFx_DrawStreaks, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBind, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunCastingImpact, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFrost, BattleFx_RunFroth, BattleFx_RunGatheringLights, BattleFx_RunGround, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunJudgment, BattleFx_RunLobbedShells, BattleFx_RunMoteFountain, BattleFx_RunOrbitingSkulls, BattleFx_RunOrbitingSpirals, BattleFx_RunParticleStreams, BattleFx_RunProcne, BattleFx_RunProjectileVolley, BattleFx_RunQuake, BattleFx_RunRingAndSparkScene, BattleFx_RunRushingStrike, BattleFx_RunShiningStar, BattleFx_RunStatBoost, BattleFx_RunStatReduction, BattleFx_RunStreakVolley, BattleFx_RunSwirlingStars and 6 more.

Line 64

EffectPosition_ProjectSprite

void EffectPosition_ProjectSprite(s32 id, struct EffectPosition *position)

The screen position of a battler's sprite, at its scaled height, 16 pixels higher.

Called by BattleFx_RunBeamSequence (beams.c), for the first target, and BattleFx_RunBurstShower (burst_shower.c), for the user. Leaves the view set to the battle camera (BattleUnit_ProjectToScreen).

Used by BattleFx_RunBeamSequence, BattleFx_RunBurstShower.

Line 77

EffectPosition_ProjectScaledBattler

void EffectPosition_ProjectScaledBattler(s32 id, struct EffectPosition *position)

The screen position of a battler, scaled for the battle view, 16 pixels higher.

The usual anchor for an effect on its user or first target: called during the setup of 21 parts, from the casting impacts, beams, the burst scene and Spire to the healing motes and the stat boosts.

Used by BattleFx_RunAnnihilation, BattleFx_RunAtalanta, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBladeRain, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunDjinnBeams, BattleFx_RunElementBurst, BattleFx_RunHealingMotes, BattleFx_RunNeptune, BattleFx_RunOrbitingSkulls, BattleFx_RunPaletteParticles, BattleFx_RunRingAndSparkScene, BattleFx_RunSleep, BattleFx_RunSparkGroups, BattleFx_RunSpiderWeb, BattleFx_RunSpire, BattleFx_RunStatBoost, BattleFx_RunSwirlSwipe, BattleFx_RunTargetMotes, BattleFx_RunTargetStrike, BattleFx_RunTriangleStrike, BattleFx_RunVine.

Line 88

EffectPosition_ProjectBattler

void EffectPosition_ProjectBattler(s32 id, struct EffectPosition *position)

The screen position of a battler, 16 pixels higher.

Called during the setup of 11 parts, among them the target strikes, Bolt, the rushing strike, the Titan Blade, the Helm Splitter and the element pillar.

Used by BattleFx_RunBolt, BattleFx_RunElementPillar, BattleFx_RunHail, BattleFx_RunHelmSplitter, BattleFx_RunKirin, BattleFx_RunMirroredWall, BattleFx_RunPlanetDiver, BattleFx_RunRushingStrike, BattleFx_RunTargetStrike, BattleFx_RunTitanBlade, BattleFx_RunUndeadSword.

Line 100

BattleUnit_ProjectToScreen

s32 BattleUnit_ProjectToScreen(s32 unit, s32 *screen)

Projects a battler onto the screen, raised by half its table height (the table holds the full height in 16.16) at the sprite's scale. The view is reset to the battle camera first, so the result does not depend on the transform an effect has left behind.

Called only by EffectPosition_ProjectSprite. Leaves the render transform looking from gCameraWork's eye to its position, and always returns 0.

screen: receives x and y.

Used by EffectPosition_ProjectSprite.

Line 114

BattleFx_ProbeKeysForExtendedActor

void BattleFx_ProbeKeysForExtendedActor(void)

Reads the held keys when the first target is an enemy (id 128 or more) and does nothing with them. Nothing calls it.

XXX: what it was for; a debug build or the Lost Age's twin of this part would show whether the keys once chose an effect for enemy targets.

Line 138

BattleFx_DispatchByIdRange

void BattleFx_DispatchByIdRange(struct BattleEffectArgument *effect)

Runs a battle effect from the second range of kinds: 100 to 135 are the casting impacts (kind - 100), 136 to 199 the beam sequences, 200 and up the ring and spark scenes.

Reached from the battle's presentation through its far-call stub: from the attack, item, Psynergy cast and unit transition runners (battle/staging.c) when the plan has STAGING_BY_ID_RANGE (bit 14 of the effect word), and always from the plain attack runner and the approach action (battle/auto_battle.c). Takes heap slots HEAP_SLOT_BATTLE_SHEET (from EWRAM first), HEAP_SLOT_BATTLE_EFFECT and HEAP_SLOT_BATTLE_CANVAS for the effect, and releases them in the reverse order once it returns.

Line 158

On this page