Skip to Content
The Alchemy Project

src/field/field_engine_targets.c

The actor a field Psynergy or item aims at, and the helpers that follow it. More…

Included by field_engine.c.

Macros

NameDescription
#defineFACING_STEP_SHIFT 12A facing's sixteenths of a turn (FACING_STEP), as a shift.

Functions

NameDescription
Sint32fdFindNearbyTalkTarget (Sint32 id)Picks the actor nearest actor id, under 32 pixels away and 48 pixels in height.
const FIELD_PSYNERGY_REACH *fdGetPsynergyReach (Sint32 id)Returns the row of FieldPsynergyReach for a field Psynergy kind: its range, height and facing width.
Sint32fdMeasurePsynergyHeight (Sint32 id, ACTOR *actor, Sint32 *pos)Returns how far the ground at position lies above or below the actor's, made positive, when that is within the kind's reach in height, else -1.
Sint32fdMeasurePsynergyReach (Sint32 kind, Sint32 selfId, Sint32 otherId)How far actor otherId stands from actor selfId, in pixels over the ground, when it lies within the reach of field Psynergy kind in front of selfId; -1 when it does not.
Sint32fdFindNearbyPsynergyTarget (Sint32 self, Sint32 kind)Returns the actor nearest in front of actor self that field Psynergy kind can reach, or -1.
Sint32fdChestOpenAndShowItem (Sint32 actorId, Sint32 target, Sint32 itemId)Unused: only the stub table refers to it.
BoolfdLeaderCanPushObjectAhead (void)Whether the actor 16 pixels in front of the leader, along its facing rounded to a quarter turn, can be pushed on by 16 pixels: 1 when nothing solid stands on the metatile beyond it or above it and its terrain test passes there, else 0.
voidfdLeaderPushObjectAhead (void)Pushes the actor ahead of the leader on by 16 pixels, as fdLeaderCanPushObjectAhead allowed.

Description

The actor a field Psynergy or item aims at, and the helpers that follow it. Part of field_engine.c.

Macros in detail

FACING_STEP_SHIFT

#define FACING_STEP_SHIFT 12

A facing's sixteenths of a turn (FACING_STEP), as a shift.

Referenced by fdLeaderCanPushObjectAhead() and fdLeaderPushObjectAhead().

Definition at line 111 of file field_engine_targets.c.

Functions in detail

fdFindNearbyTalkTarget

Sint32 fdFindNearbyTalkTarget(Sint32 id)

Picks the actor nearest actor id, under 32 pixels away and 48 pixels in height. Distances to treasure spots count double and to actors with ACTOR_NEAR_TALK ten thirteenths; beyond 11 pixels the actor must also lie within three sixteenths of a turn of id's facing. Returns -1 when none qualifies.

References fdActorLookup(), Sint32, syAtan() and sySquartIWRAM().

Referenced by fdEngineRun(), fdFindItemCue(), fdRopeUpdate(), fdRunPushMetatile(), fdTightropeUpdate(), fdUseItem(), scAnemosInnerSanctumDullahanStepWhilePushing(), scDehkanPlateauPushVinePillar(), scEasternAlhafraPushAhead(), scMadraCatacombsPushVinePillar(), scMarsLighthouseTowersJumpGapOrPushStone(), scTrialRoadJumpMeltedPuddle(), scTrialRoadPutItemInChest() and scWorldMapBoardShip().

Definition at line 9 of file field_engine_targets.c.

fdGetPsynergyReach

const FIELD_PSYNERGY_REACH *fdGetPsynergyReach(Sint32 id)

Returns the row of FieldPsynergyReach for a field Psynergy kind: its range, height and facing width. A kind not found returns the -1 terminator.

References FieldPsynergyReach and Sint32.

Referenced by fdMeasurePsynergyHeight() and fdMeasurePsynergyReach().

Definition at line 88 of file field_engine_targets.c.

fdMeasurePsynergyHeight

Sint32 fdMeasurePsynergyHeight(Sint32 id, ACTOR *actor, Sint32 *pos)

Returns how far the ground at position lies above or below the actor's, made positive, when that is within the kind's reach in height, else -1.

References fdGetPsynergyReach(), fdMapGridGetTerrainHeightAboveStub() and Sint32.

Referenced by fdPsynergyGatherNearbyMetatiles(), fdPsynergyParch(), fdPsynergyPound() and fdPsynergyScoop().

Definition at line 99 of file field_engine_targets.c.

fdMeasurePsynergyReach

Sint32 fdMeasurePsynergyReach(Sint32 kind, Sint32 selfId, Sint32 otherId)

How far actor otherId stands from actor selfId, in pixels over the ground, when it lies within the reach of field Psynergy kind in front of selfId; -1 when it does not.

References fdActorLookup(), fdGetPsynergyReach(), Sint32, syAtan() and sySquartIWRAM().

Referenced by fdFindNearbyPsynergyTarget(), fdPsynergyBlaze(), fdSelectPsynergyTarget() and fdViewMoveSaveNearbySprites().

Definition at line 116 of file field_engine_targets.c.

fdFindNearbyPsynergyTarget

Sint32 fdFindNearbyPsynergyTarget(Sint32 self, Sint32 kind)

Returns the actor nearest in front of actor self that field Psynergy kind can reach, or -1.

References fdMeasurePsynergyReach() and Sint32.

Referenced by fdPsynergyRun() and scPillarLowerHeldMetatiles().

Definition at line 185 of file field_engine_targets.c.

fdChestOpenAndShowItem

Sint32 fdChestOpenAndShowItem(Sint32 actorId, Sint32 target, Sint32 itemId)

Unused: only the stub table refers to it. Opens a chest: if actor target exists, plays SE_CHEST_OPEN, opens its lid and, 12 ticks later, shows itemId in front of actor actorId with sparkles.

References fdActorGetById(), fdActorSelectAnimationStub(), fdItemDisplayShowItemInFront(), Sint32, sySoundPlayStub() and sySynch().

Definition at line 210 of file field_engine_targets.c.

fdLeaderCanPushObjectAhead

Bool fdLeaderCanPushObjectAhead(void)

Whether the actor 16 pixels in front of the leader, along its facing rounded to a quarter turn, can be pushed on by 16 pixels: 1 when nothing solid stands on the metatile beyond it or above it and its terrain test passes there, else 0. fdLeaderPushObjectAhead, after it, makes the push. In every edition but the Japanese the actor Halt has stopped (MainRoutineStateWork.haltedActor) cannot be pushed; the Japanese release has no such test.

References fdActorFindAtMetatile(), fdActorGetById(), fdMapGridCheckCollisionStub(), MainRoutineStateWork, result, Sint32 and syVectorAddPolarOffset().

Referenced by fdRunPushMetatile(), scAnemosInnerSanctumDullahanStepWhilePushing(), scDehkanPlateauPushVinePillar(), scEasternAlhafraPushAhead(), scMadraCatacombsPushVinePillar() and scTrialRoadLandOnPillar().

Definition at line 233 of file field_engine_targets.c.

fdLeaderPushObjectAhead

void fdLeaderPushObjectAhead(void)

Pushes the actor ahead of the leader on by 16 pixels, as fdLeaderCanPushObjectAhead allowed.

References fdActorFindAtMetatile(), fdActorGetById(), fdActorSelectAnimationStub(), fdActorSetPosAndResetMotionStub(), fdActorWaitForMoveStub(), fdMapGridCheckCollisionStub(), fdScriptNoOperation(), MainRoutineStateWork, result, Sint32, sySoundPlayStub(), sySynch() and syVectorAddPolarOffset().

Referenced by fdRunPushMetatile(), scAnemosInnerSanctumDullahanStepWhilePushing(), scDehkanPlateauPushTightropesSecondPillar(), scDehkanPlateauPushVinePillar(), scIsletsPushCrateOffLedge(), scJupiterLighthouseJumpOrPushBlock(), scMadraCatacombsPushVinePillar(), scMarsLighthouseTowersJumpGapOrPushStone(), scMarsLighthouseTowersPushStoneAlongLedge(), scMarsLighthouseTowersPushVenusStatueOffLedge() and scTrialRoadLandOnPillar().

Definition at line 290 of file field_engine_targets.c.