Skip to Content
The Alchemy Project

src/field/field_engine_walking.c

Field requests and each tick of the leader's walking: exits, encounters, damage. More…

Included by field_engine.c.

Macros

NameDescription
#defineHAZARD_DAMAGE_AMOUNT 0xffMAIN_ROUTINE_STATE.hazardDamage's amount, below HAZARD_DAMAGE_PERCENT.
#defineHEAVY_DAMAGE 10A loss of more HP than this plays SE_HEAVY_IMPACT rather than SE_IMPACT.
#definePOISON_DAMAGE_DIVISOR 20Poison takes 1/POISON_DAMAGE_DIVISOR of a character's maximum HP, rounded to the nearest, and venom ("deadly poison") 1/VENOM_DAMAGE_DIVISOR.
#defineVENOM_DAMAGE_DIVISOR 10

Functions

NameDescription
Sint32fdEngineReturnZero (void)Unused: returns 0.
voidfdClearRequests (void)Clears the field's twelve pending requests (see FIELD_STATE).
Sint32fdCountRequests (void)Returns the sum of the field's twelve pending requests: non-zero while any request is pending.
voidfdUpdateHoverReady (void)Sets the field state's hoverReady when the ship flies (FLAG_SHIP_FLIES) and a party member knows Hover; clears it otherwise.
Sint32fdGetCollisionAheadOfLeader (void)Returns the metatile behavior of the map metatile 16 pixels ahead of the party leader (on the World Map, of its 32-pixel metatile), or 0 without a leader.
Sint32fdGetCollisionUnderLeader (void)The collision code of the metatile under the leader (on the world map, of its block), or 0 with no leader.
voidfdCheckExitRegions (FIXED posX, FIXED posY, FIXED posZ)Takes the exit of the first of the scene's exit regions that contains the position (x, y, z), in 16.16 pixels, and whose condition holds: records the region's exit value for fdEngineRun, plays the exit sound and starts leaving the scene.
Sint32btDjinnRecoveryCountDownStub (void)Brings the party's recovering Djinn one turn nearer, setting each that is ready, and returns 1 when any was set.
voidfdUpdateWalking (Uint32 layer, FIXED x, FIXED y, FIXED z)Handles one tick of the party leader's walking onto the metatile at (x, y, z) of map grid layer: records step cues and push metatiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.
voidfdPartyAddPp (Sint32 amount, Sint32 unused)Gives each character in the party amount PP (PP regenerates as the party walks).
voidfdPartyAddHp (Sint32 amount, Sint32 scaled)Changes each party member's HP by amount, or by that percentage of maximum HP when scaled is set; a loss flashes the screen orange.
Sint32fdPartyApplyPoisonDamage (void)Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and deadly poison a tenth, rounded to the nearest and at least 1.
voidfdWorldMapFreeze (void)On the World Map, with no area graphics already pending: marks them pending, pauses the camera's actor and, when a screen transition is running, ends it at once and waits 2 ticks; then shows the still image (fdWorldMapStartStillImageStub).
voidfdWorldMapReloadPendingAreaGraphics (void)On the World Map, loads the area graphics fdWorldMapFreeze left pending and lets the camera's actor move again.
ACTOR *fdGetPartyActor (void)Returns the actor that stands for the party: the leader's, or the first placed actor while MainRoutineStateWork.ownerOverride gives the party's control to it (the ship, when the party sails it).

Description

Field requests and each tick of the leader's walking: exits, encounters, damage. Part of field_engine.c.

Macros in detail

HAZARD_DAMAGE_AMOUNT

#define HAZARD_DAMAGE_AMOUNT 0xff

MAIN_ROUTINE_STATE.hazardDamage's amount, below HAZARD_DAMAGE_PERCENT.

Referenced by fdUpdateWalking().

Definition at line 7 of file field_engine_walking.c.

HEAVY_DAMAGE

#define HEAVY_DAMAGE 10

A loss of more HP than this plays SE_HEAVY_IMPACT rather than SE_IMPACT.

Referenced by fdPartyAddHp().

Definition at line 9 of file field_engine_walking.c.

POISON_DAMAGE_DIVISOR

#define POISON_DAMAGE_DIVISOR 20

Poison takes 1/POISON_DAMAGE_DIVISOR of a character's maximum HP, rounded to the nearest, and venom ("deadly poison") 1/VENOM_DAMAGE_DIVISOR.

Referenced by fdPartyApplyPoisonDamage().

Definition at line 12 of file field_engine_walking.c.

VENOM_DAMAGE_DIVISOR

#define VENOM_DAMAGE_DIVISOR 10

Referenced by fdPartyApplyPoisonDamage().

Definition at line 13 of file field_engine_walking.c.

Functions in detail

fdEngineReturnZero

Sint32 fdEngineReturnZero(void)

Unused: returns 0.

References Sint32.

Definition at line 16 of file field_engine_walking.c.

fdClearRequests

void fdClearRequests(void)

Clears the field's twelve pending requests (see FIELD_STATE).

Referenced by fdEngineRun().

Definition at line 22 of file field_engine_walking.c.

fdCountRequests

Sint32 fdCountRequests(void)

Returns the sum of the field's twelve pending requests: non-zero while any request is pending.

References Sint32.

Referenced by fdEngineRun().

Definition at line 42 of file field_engine_walking.c.

fdUpdateHoverReady

void fdUpdateHoverReady(void)

Sets the field state's hoverReady when the ship flies (FLAG_SHIP_FLIES) and a party member knows Hover; clears it otherwise. The world map's pad movement reads it.

References gmPartyFindOwnerWithActionStub() and syGameFlagGet().

Referenced by fdEngineRun().

Definition at line 67 of file field_engine_walking.c.

fdGetCollisionAheadOfLeader

Sint32 fdGetCollisionAheadOfLeader(void)

Returns the metatile behavior of the map metatile 16 pixels ahead of the party leader (on the World Map, of its 32-pixel metatile), or 0 without a leader.

References fdGetPartyActor(), Sint32 and syVectorAddPolarOffset().

Referenced by fdFindItemCue() and fdSelectPsynergyTarget().

Definition at line 81 of file field_engine_walking.c.

fdGetCollisionUnderLeader

Sint32 fdGetCollisionUnderLeader(void)

The collision code of the metatile under the leader (on the world map, of its block), or 0 with no leader. Teleport's cues match it.

References fdGetPartyActor() and Sint32.

Referenced by fdSelectPsynergyTarget().

Definition at line 125 of file field_engine_walking.c.

fdCheckExitRegions

void fdCheckExitRegions(FIXED posX, FIXED posY, FIXED posZ)

Takes the exit of the first of the scene's exit regions that contains the position (x, y, z), in 16.16 pixels, and whose condition holds: records the region's exit value for fdEngineRun, plays the exit sound and starts leaving the scene.

References fdGameFlagIsConditionActive(), fdLeaderStopMoving(), Sint32 and sySoundPlayStub().

Referenced by fdUpdateWalking().

Definition at line 158 of file field_engine_walking.c.

btDjinnRecoveryCountDownStub

Sint32 btDjinnRecoveryCountDownStub(void)

Brings the party's recovering Djinn one turn nearer, setting each that is ready, and returns 1 when any was set.

Referenced by fdUpdateWalking() and mnDjinnMenuSelectDjinn().

Definition at line 208 of file field_engine_walking.c.

fdUpdateWalking

void fdUpdateWalking(Uint32 layer, FIXED x, FIXED y, FIXED z)

Handles one tick of the party leader's walking onto the metatile at (x, y, z) of map grid layer: records step cues and push metatiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.

References btDjinnRecoveryCountDownStub(), fdCheckExitRegions(), fdEffectSetAttached(), fdEncounterRollMapStep(), fdEncounterRollWorldMap(), fdGetPartyActor(), fdPartyAddHp(), fdPartyAddPp(), fdPartyApplyPoisonDamage(), fdPartyClearUnusableShortcuts(), fdPartyGetLeaderActor(), gmPartyCountMembersStub(), gmUnitGet(), MainRoutineStateWork, Sint32, syGameFlagGet() and sySoundPlayStub().

Referenced by fdEngineRun().

Definition at line 214 of file field_engine_walking.c.

fdPartyAddPp

void fdPartyAddPp(Sint32 amount, Sint32 unused)

Gives each character in the party amount PP (PP regenerates as the party walks).

References gmPartyCountMembersStub(), gmUnitAddPpStub(), MainRoutineStateWork and Sint32.

Referenced by fdTalkToActor(), fdUpdateWalking(), scAirsRockInsideCheckPsynergyStone() and scAquaRockInsideCheckPsynergyStone().

Definition at line 390 of file field_engine_walking.c.

fdPartyAddHp

void fdPartyAddHp(Sint32 amount, Sint32 scaled)

Changes each party member's HP by amount, or by that percentage of maximum HP when scaled is set; a loss flashes the screen orange.

References fdPaletteFadeSetSource(), fdPaletteFadeStartInterpolation(), gmPartyCountMembersStub(), gmUnitAddHpStub(), gmUnitGet(), MainRoutineStateWork, Sint32 and sySoundPlayStub().

Referenced by fdUpdateWalking() and gmPartyTakeFallDamage().

Definition at line 401 of file field_engine_walking.c.

fdPartyApplyPoisonDamage

Sint32 fdPartyApplyPoisonDamage(void)

Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and deadly poison a tenth, rounded to the nearest and at least 1. Returns the worst poison found: 0 none, 1 poison, 2 deadly poison.

References fdPaletteFadeSetSource(), fdPaletteFadeStartInterpolation(), gmPartyCountMembersStub(), gmUnitAddHpStub(), gmUnitGet(), MainRoutineStateWork, result, Sint32 and sySoundPlayStub().

Referenced by fdUpdateWalking().

Definition at line 449 of file field_engine_walking.c.

fdWorldMapFreeze

void fdWorldMapFreeze(void)

On the World Map, with no area graphics already pending: marks them pending, pauses the camera's actor and, when a screen transition is running, ends it at once and waits 2 ticks; then shows the still image (fdWorldMapStartStillImageStub).

References fdWorldMapStartStillImageStub(), syHeapSlotAllocateEWRAM() and sySynch().

Referenced by fdDjinnJoinParty(), fdEngineRun(), fdPsynergyShowAvoidWoreOff(), scStaffCreditPlayLighthouseTransition(), scStaffCreditShowBeacon(), scWorldMapDeliverLohoCannon(), scWorldMapDriftNorthOfContinent(), scWorldMapExplainGivingDjinn(), scWorldMapFightBanditAndThieves(), scWorldMapMeetEcho(), scWorldMapPlayLighthouseTransition(), scWorldMapRefuseToRunAway(), scWorldMapSetUpFlyingShip(), scWorldMapTakeOff(), scWorldMapTakeTheTiller() and scWorldMapWatchVenusLighthouseCollapse().

Definition at line 506 of file field_engine_walking.c.

fdWorldMapReloadPendingAreaGraphics

void fdWorldMapReloadPendingAreaGraphics(void)

On the World Map, loads the area graphics fdWorldMapFreeze left pending and lets the camera's actor move again.

References fdWorldMapLoadAreaGraphicsStub() and syHeapSlotAllocateEWRAM().

Referenced by fdDjinnJoinParty(), fdEngineRun(), fdPsynergyShowAvoidWoreOff(), scStaffCreditShowBeacon(), scWorldMapDeliverLohoCannon(), scWorldMapDriftNorthOfContinent(), scWorldMapExplainGivingDjinn(), scWorldMapFightBanditAndThieves(), scWorldMapMeetEcho(), scWorldMapRefuseToRunAway(), scWorldMapSetUpFlyingShip(), scWorldMapTakeOff(), scWorldMapTakeTheTiller() and scWorldMapWatchVenusLighthouseCollapse().

Definition at line 535 of file field_engine_walking.c.

fdGetPartyActor

ACTOR *fdGetPartyActor(void)

Returns the actor that stands for the party: the leader's, or the first placed actor while MainRoutineStateWork.ownerOverride gives the party's control to it (the ship, when the party sails it).

References MainRoutineStateWork.

Referenced by fdActorGetCueMetatileAheadOfCurrent(), fdEngineRun(), fdGetCollisionAheadOfLeader(), fdGetCollisionUnderLeader() and fdUpdateWalking().

Definition at line 552 of file field_engine_walking.c.