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
#defineTARGET_RANGE_DEFAULT 16How far, in pixels, a field Psynergy reaches when FieldEffectTargetRangeByMode does not list its kind.

Functions

NameDescription
Sint32fdGetPsynergyTargetRange (Sint32 kind)Returns how far, in pixels, a field Psynergy of the given kind reaches: FieldEffectTargetRangeByMode (field_engine_tables.c) pairs kinds with ranges, ended by -1.
Sint32fdFindNearbyTalkTarget (Sint32 id)Returns the actor nearest to actor id that it could talk to, or -1: within 48 pixels of height and 32 pixels of distance (an ACTOR_NEAR_TALK actor's counted ten thirteenths) and, beyond 11 pixels, within 3/16 of a turn (67.5 degrees) of the direction it faces.
Sint32fdFindNearbyPsynergyTarget (Sint32 id, Sint32 kind)Returns the actor nearest in front of actor id that a field Psynergy of the given kind can reach, or -1: within its range (an ACTOR_NEAR_PSYNERGY actor's counted two thirds), within 8 pixels of height (more for Catch, Douse and Mind Read) and, beyond 11 pixels, within a cone either side of its facing's quarter turn, narrower beyond 19 pixels and wider for Mind Read.
Sint32fdChestOpenAndShowItem (Sint32 actorId, Sint32 target, Sint32 itemId)Opens the chest that is actor target (SE_CHEST_OPEN, the lid lifting on treasure) and, 12 ticks later, shows itemId in front of actor actorId with sparkles; returns the actor that shows the item, or 0 when there is no chest.
voidfdActorSetLayersColorMode (ACTOR *actor, Sint32 colorModePlusOne)Gives each running layer of an actor's one sprite the colour mode colorModePlusOne - 1 (SPRITE_COLOR_NORMAL for 1), or for 0 the next of Mind Read's caster cycle, a mode every 2 ticks; a hidden layer stays hidden.
voidfdEndBusyAndReveal (void)Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs its ending scripts.

Description

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

Macros in detail

TARGET_RANGE_DEFAULT

#define TARGET_RANGE_DEFAULT 16

How far, in pixels, a field Psynergy reaches when FieldEffectTargetRangeByMode does not list its kind.

Referenced by fdGetPsynergyTargetRange().

Definition at line 8 of file field_engine_targets.c.

Functions in detail

fdGetPsynergyTargetRange

Sint32 fdGetPsynergyTargetRange(Sint32 kind)

Returns how far, in pixels, a field Psynergy of the given kind reaches: FieldEffectTargetRangeByMode (field_engine_tables.c) pairs kinds with ranges, ended by -1.

References FieldEffectTargetRangeByMode and Sint32.

Referenced by fdFindNearbyPsynergyTarget().

Definition at line 13 of file field_engine_targets.c.

fdFindNearbyTalkTarget

Sint32 fdFindNearbyTalkTarget(Sint32 id)

Returns the actor nearest to actor id that it could talk to, or -1: within 48 pixels of height and 32 pixels of distance (an ACTOR_NEAR_TALK actor's counted ten thirteenths) and, beyond 11 pixels, within 3/16 of a turn (67.5 degrees) of the direction it faces.

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

Referenced by fdEngineRun(), fdFindItemCue() and fdUseItem().

Definition at line 37 of file field_engine_targets.c.

fdFindNearbyPsynergyTarget

Sint32 fdFindNearbyPsynergyTarget(Sint32 id, Sint32 kind)

Returns the actor nearest in front of actor id that a field Psynergy of the given kind can reach, or -1: within its range (an ACTOR_NEAR_PSYNERGY actor's counted two thirds), within 8 pixels of height (more for Catch, Douse and Mind Read) and, beyond 11 pixels, within a cone either side of its facing's quarter turn, narrower beyond 19 pixels and wider for Mind Read.

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

Referenced by fdFindPsynergyCue(), fdPsynergyRun() and fdUsePsynergy().

Definition at line 127 of file field_engine_targets.c.

fdChestOpenAndShowItem

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

Opens the chest that is actor target (SE_CHEST_OPEN, the lid lifting on treasure) and, 12 ticks later, shows itemId in front of actor actorId with sparkles; returns the actor that shows the item, or 0 when there is no chest.

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

Referenced by scLogRoomsAReturnStolenGoods(), scLunpaFortressTryTakeChestItem() and scMcCoyPalaceClaimReward().

Definition at line 228 of file field_engine_targets.c.

fdActorSetLayersColorMode

void fdActorSetLayersColorMode(ACTOR *actor, Sint32 colorModePlusOne)

Gives each running layer of an actor's one sprite the colour mode colorModePlusOne - 1 (SPRITE_COLOR_NORMAL for 1), or for 0 the next of Mind Read's caster cycle, a mode every 2 ticks; a hidden layer stays hidden.

References MindReadCasterPaletteCycle, Sint32 and TickCount.

Referenced by fdPsynergyStopMindReadWave() and fdPsynergyUpdateMindReadWave().

Definition at line 249 of file field_engine_targets.c.

fdEndBusyAndReveal

void fdEndBusyAndReveal(void)

Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs its ending scripts.

References fdRunPsynergyEndScripts() and state.

Referenced by fdEngineRun(), fdScriptStart(), scAltinPeakRideCart(), scAltmillerCaveMeetInvisibleBabi(), scAltmillerCaveRestoreBabiAndInviteParty(), scAltmillerCaveTurnRock(), scBabiLighthouseExplainTruthDoor(), scBabiLighthouseFaranAsksPartyToOpenDoor(), scBabiPalaceHearSoldiersReport(), scBabiPalaceOfferCloakBall(), scBabiPalaceOfferRest(), scBabiPalacePassOnBabisWord(), scBabiPalaceRestInPalaceBeds(), scBabiPalaceShowBeds(), scColossoGreetAtStage(), scFuchinFallsCaveLightDragonWithEye(), scKalayTolbiDocksGaretSeesTheKaragol(), scKalayTolbiDocksPassengersBlameTourGuide(), scKolimaForestTreeUseHermesWater(), scLemurianShipRaiseTheShip(), scShipRoomsFightRowingDeckMonsters(), scShipRoomsReturnLuckyAnchor(), scShipRoomsTalkToCaptainsQuartersCrewman(), scShipRoomsWatchCrewWonderAtDelay(), scShipRoomsWatchWarriorsStormOff(), scSolSanctumEntranceSetFirstSmallJewel(), scSolSanctumEntranceSetSecondSmallJewel(), scTimberRoomsBCIodemCallsOut(), scTimberRoomsBCTalkToInnWorker(), scTolbiShipDeckCatchCrewmanFromEast(), scTolbiShipDeckCatchCrewmanFromWest(), scTolbiShipDeckWatchCrewDecideToSail(), scTolbiSpringRunSpringGame() and scVenusLighthouseMoveSocketPillar().

Definition at line 285 of file field_engine_targets.c.