Skip to Content
The Alchemy Project

src/field/script_commands_djinni.c

A Djinni's hop before its battle, a Djinni joining the party, and the field effect sprites the joining lights are drawn with. More…

Included by script_commands.c.

Macros

NameDescription
#defineDJINNI_AFTERIMAGES 8afterimages of the leaping Djinni
#defineDJINNI_LIGHT_RADIUS_TICKS 60The ticks a Jupiter Djinni's light widens, and later closes in over, so that it ends where it began; and the ticks it circles and drifts.
#defineDJINNI_LIGHT_CIRCLING_TICKS 40
#defineDJINNI_LIGHT_DRIFTING_TICKS 40

Enumerations

NameDescription
enumDJINNI_LIGHT_STATE { DJINNI_LIGHT_WIDENING, DJINNI_LIGHT_CIRCLING, DJINNI_LIGHT_D … }The states of a Jupiter Djinni's light particle, in order.

Functions

NameDescription
voidfdActorMoveHalfwayTowardTarget (ACTOR *actor)Update function shared by the Djinni battle-start and Mercury afterimages.
voidfdDjinnRunBattleStartHop (Sint32 djinniId)A Djinni's battle start: the Djinni (actor id) bounces twice, turns to face the leader, hops back 16 pixels three times, then leaps 64 pixels at the party trailing eight afterimages tinted for its element.
voidfdDjinnJoinParty (Sint32 actorId, Sint32 element, Sint32 djinn)A Djinni joins the party: djinn (0 to 19) of element goes to the party member with the fewest Djinn, or to no one and only its flag while FLAG_DJINN_LESSON is set.
voidfdDjinnRestoreActorAfterBattle (void)Puts a Djinni's actor back where its battle started from: for a pending Djinni battle (pendingDjinni DJINNI_BATTLE_SCRIPT_FIRST plus the Djinni's number, FLAG_KEEP_PARTY_POSITION set, the battle over) the scene's actor placed for that Djinni (condition = its flag) goes back to its placement's position, or 32 pixels north of the leader when the script has DJINN_NO_HOP set, and stands.
voidfdDjinnResolvePending (Sint32 shown)Settles a pending Djinni or mimic battle as a scene loads, from the battle's result in engineResult (the enemies defeated, BATTLE_OUTCOME_FLED when the party fled, BATTLE_OUTCOME_LOST when it lost): with shown 0, before the scene shows, a lost or fled Djinni hides again and a beaten mimic's flag is set; once it shows, a beaten Djinni joins the party.
voidfdEffectUpdateAllSlots (void)Event: updates the 24 field effect sprites.
voidfdEffectInitSlots (void)Allocates and clears the field effect sprites (HEAP_SLOT_FIELD_EFFECT) and starts their update event.
voidfdEffectReleaseSlots (void)Stops the field effect sprites: removes their event, frees every slot still in use and releases their heap block, FieldEffectStateWork with it.
voidfdEffectAdvanceSpinAngle (ACTOR *actor)Per-tick update: spins an actor 1/8 turn a tick.
voidfdEffectRunAngledApproachPhases (FIELD_PARTICLE *particle)Field effect sprite callback of a Jupiter Djinni's light particles, the ring of coloured lights a joining Jupiter Djinni bursts into: each circles its centre while it widens, circles, drifts toward a point 20 pixels over the leader and closes in on it, and is freed.

Description

A Djinni's hop before its battle, a Djinni joining the party, and the field effect sprites the joining lights are drawn with. Part of script_commands.c.

Macros in detail

DJINNI_AFTERIMAGES

#define DJINNI_AFTERIMAGES 8

afterimages of the leaping Djinni

Referenced by fdDjinnRunBattleStartHop().

Definition at line 12 of file script_commands_djinni.c.

DJINNI_LIGHT_RADIUS_TICKS

#define DJINNI_LIGHT_RADIUS_TICKS 60

The ticks a Jupiter Djinni's light widens, and later closes in over, so that it ends where it began; and the ticks it circles and drifts.

Referenced by fdEffectRunAngledApproachPhases().

Definition at line 355 of file script_commands_djinni.c.

DJINNI_LIGHT_CIRCLING_TICKS

#define DJINNI_LIGHT_CIRCLING_TICKS 40

Referenced by fdEffectRunAngledApproachPhases().

Definition at line 356 of file script_commands_djinni.c.

DJINNI_LIGHT_DRIFTING_TICKS

#define DJINNI_LIGHT_DRIFTING_TICKS 40

Referenced by fdEffectRunAngledApproachPhases().

Definition at line 357 of file script_commands_djinni.c.

Enumerations in detail

DJINNI_LIGHT_STATE

enum DJINNI_LIGHT_STATE

The states of a Jupiter Djinni's light particle, in order.

EnumeratorValueDescription
DJINNI_LIGHT_WIDENING0circles as its radius grows
DJINNI_LIGHT_CIRCLING1
DJINNI_LIGHT_DRIFTING2its centre drifts toward the leader
DJINNI_LIGHT_CLOSING3circles as its radius shrinks
DJINNI_LIGHT_DONE4frees its slot

Definition at line 360 of file script_commands_djinni.c.

Functions in detail

fdActorMoveHalfwayTowardTarget

void fdActorMoveHalfwayTowardTarget(ACTOR *actor)

Update function shared by the Djinni battle-start and Mercury afterimages.

References fdEffectMoveAfterimageHalfway().

Referenced by fdDjinnRunBattleStartHop().

Definition at line 7 of file script_commands_djinni.c.

fdDjinnRunBattleStartHop

void fdDjinnRunBattleStartHop(Sint32 djinniId)

A Djinni's battle start: the Djinni (actor id) bounces twice, turns to face the leader, hops back 16 pixels three times, then leaps 64 pixels at the party trailing eight afterimages tinted for its element.

References fdActorCreateStub(), fdActorFaceDirectionById(), fdActorGetById(), fdActorJump(), fdActorMoveHalfwayTowardTarget(), fdActorRunRepeatedMotion(), fdActorSelectAnimationStub(), fdActorSetSpriteColorModeStub(), fdActorSetSpriteFlagsStub(), fdActorSetTargetPosFromMagnitudeAngle(), fdActorWaitForMoveStub(), fdScriptEnd(), fdScriptStart(), fdSpriteShareVRAMCacheEntry(), MainRoutineStateWork, Sint32, sySoundPlayStub() and sySynch().

Referenced by fdRequestDjinnBattle().

Definition at line 17 of file script_commands_djinni.c.

fdDjinnJoinParty

void fdDjinnJoinParty(Sint32 actorId, Sint32 element, Sint32 djinn)

A Djinni joins the party: djinn (0 to 19) of element goes to the party member with the fewest Djinn, or to no one and only its flag while FLAG_DJINN_LESSON is set. Its actor, actorId (-1 for none), plays its element's joining and leaves the scene.

References fdActorClearOutOfBounds(), fdActorRespawn(), fdDjinnRunJupiterJoinEffect(), fdDjinnRunMarsJoinEffect(), fdDjinnRunMercuryJoinEffect(), fdDjinnRunVenusJoinEffect(), fdScriptEnd(), fdScriptStart(), fdWorldMapFreeze(), fdWorldMapUnfreeze(), gmDjinnGiveToPartyStub(), gmFlagGetStub(), gmFlagSetStub(), mnDjinnShowJoinedMessageStub(), Sint32 and state.

Referenced by dbTestGiveDjinni(), fdDjinnResolvePending(), scBilibinGustJoins(), scCrossboneIsleKeysBaneJoins(), scImilFeverJoins(), scKalayScorchJoins(), scKalayTolbiDocksGroundJoins(), scKolimaGraniteJoins(), scLaliveroTalkToTorch(), scLamakanDesertTalkToSmog(), scLunpaFortressDjinniJoins(), scTolbiJoinEmber(), scValeCaveTalkToKite(), scVaultRevisitSapJoins(), scWorldMapMeetFlint() and scXianMistJoins().

Definition at line 129 of file script_commands_djinni.c.

fdDjinnRestoreActorAfterBattle

void fdDjinnRestoreActorAfterBattle(void)

Puts a Djinni's actor back where its battle started from: for a pending Djinni battle (pendingDjinni DJINNI_BATTLE_SCRIPT_FIRST plus the Djinni's number, FLAG_KEEP_PARTY_POSITION set, the battle over) the scene's actor placed for that Djinni (condition = its flag) goes back to its placement's position, or 32 pixels north of the leader when the script has DJINN_NO_HOP set, and stands.

References fdActorLookup(), fdActorSelectAnimationStub(), fdActorSetPosAndResetMotionStub(), fdFindActorPlacement(), gmFlagGetStub(), MainRoutineStateWork and Sint32.

Referenced by fdEngineRun().

Definition at line 182 of file script_commands_djinni.c.

fdDjinnResolvePending

void fdDjinnResolvePending(Sint32 shown)

Settles a pending Djinni or mimic battle as a scene loads, from the battle's result in engineResult (the enemies defeated, BATTLE_OUTCOME_FLED when the party fled, BATTLE_OUTCOME_LOST when it lost): with shown 0, before the scene shows, a lost or fled Djinni hides again and a beaten mimic's flag is set; once it shows, a beaten Djinni joins the party.

References fdDjinnJoinParty(), fdFindActorPlacement(), gmFlagSetStub(), MainRoutineStateWork, Sint32 and sySynch().

Referenced by fdEngineRun().

Definition at line 245 of file script_commands_djinni.c.

fdEffectUpdateAllSlots

void fdEffectUpdateAllSlots(void)

Event: updates the 24 field effect sprites.

References fdEffectUpdateEffectSlots().

Referenced by fdEffectInitSlots() and fdEffectReleaseSlots().

Definition at line 311 of file script_commands_djinni.c.

fdEffectInitSlots

void fdEffectInitSlots(void)

Allocates and clears the field effect sprites (HEAP_SLOT_FIELD_EFFECT) and starts their update event.

References fdEffectUpdateAllSlots(), state, syHeapSlotAllocate() and sySetEvent().

Referenced by fdDjinnRunJupiterJoinEffect(), fdDjinnRunMarsJoinEffect(), fdDjinnRunMercuryJoinEffect(), fdDjinnRunVenusJoinEffect() and scAltmillerCaveReleaseWallBurst().

Definition at line 318 of file script_commands_djinni.c.

fdEffectReleaseSlots

void fdEffectReleaseSlots(void)

Stops the field effect sprites: removes their event, frees every slot still in use and releases their heap block, FieldEffectStateWork with it.

References fdEffectUpdateAllSlots(), fdParticleFree(), Sint32, syCloseEvent(), syHeapSlotRelease() and sySynch().

Referenced by fdDjinnRunJupiterJoinEffect(), fdDjinnRunMarsJoinEffect(), fdDjinnRunMercuryJoinEffect(), fdDjinnRunVenusJoinEffect() and scAltmillerCaveReleaseWallBurst().

Definition at line 330 of file script_commands_djinni.c.

fdEffectAdvanceSpinAngle

void fdEffectAdvanceSpinAngle(ACTOR *actor)

Per-tick update: spins an actor 1/8 turn a tick.

Referenced by fdDjinnRunJupiterJoinEffect() and fdDjinnRunVenusJoinEffect().

Definition at line 348 of file script_commands_djinni.c.

fdEffectRunAngledApproachPhases

void fdEffectRunAngledApproachPhases(FIELD_PARTICLE *particle)

Field effect sprite callback of a Jupiter Djinni's light particles, the ring of coloured lights a joining Jupiter Djinni bursts into: each circles its centre while it widens, circles, drifts toward a point 20 pixels over the leader and closes in on it, and is freed. It turns 1/32 turn a tick throughout, and its radius grows, then shrinks, by 1 pixel a tick.

References fdActorGetById(), fdCameraWorldToScreen(), fdParticleFree(), MainRoutineStateWork and syVectorAddPolarOffset().

Referenced by fdDjinnRunJupiterJoinEffect().

Definition at line 374 of file script_commands_djinni.c.