Skip to Content
The Alchemy Project

src/field/field_engine_items.c

Using an item on the field. More…

Included by field_engine.c.

Enumerations

NameDescription
enumPSYNERGY_END_SKIP { END_SKIP_REVEAL, END_SKIP_RING, END_SKIP_SAND }What fdScriptEndLastingPsynergy leaves running, as bits of its skip.

Functions

NameDescription
voidfdScriptRunMessage (Sint32 actor, Sint32 msg)Runs message as a script of its own, shown at actor.
voidfdScriptEndAllLastingPsynergy (void)Ends every lasting Psynergy (fdScriptEndLastingPsynergy with none skipped).
voidfdScriptEndLastingPsynergy (Sint32 skip)Ends the lasting Psynergy and runs their end scripts: Reveal, the ring of light and Sand (while the party is sand, MainRoutineStateWork.sandActive), each unless skip holds its bit (PSYNERGY_END_SKIP).
Sint32fdPartyGetLeaderActor (void)Returns the leader's actor id, or ACTOR_FIRST_PLACED while MainRoutineStateWork.ownerOverride is set.
BoolfdItemMatchesFilter (Sint32 filter, Sint32 itemId)Returns 1 when itemId answers filter: the item itself, ITEM_FILTER_ANY any item, or ITEM_FILTER_HEAVY any weapon, armor, shield or helm; else 0.
const CUE *fdFindItemCue (Sint32 item)Returns the scene's item cue (CUE_ITEM) for item that applies to what the leader faces, or NULL (item 0 matches any): its item or item filter takes item (fdItemMatchesFilter), and its target is the actor the leader can talk to (CUE_ITEM_ON_ACTOR) or the metatile ahead.
Sint32fdUseItem (Sint32 packedItem, Sint32 slot)Uses an item on the field. packedItem holds the item (bits 0 to 9) and the character using it (bits 10 to 13; UNIT_NONE for whoever holds it in the most inventory slots); slot is its inventory slot.
Sint32fdSelectPsynergyTarget (Sint32 kind)Chooses what a Psynergy of the given kind acts on, for fdFindPsynergyCue: among the scene's Psynergy cues for that kind whose condition holds (and whose direction, if any, the leader faces), the metatile the leader faces, or for Teleport the metatile under it; else the nearest target in reach (with PSYNERGY_TARGET_ACTOR); else PSYNERGY_TARGET_ANYWHERE for a cue that applies anywhere, or -1.
CUE *fdFindPsynergyCue (Sint32 filter, Sint32 kind, Sint32 selector)Psynergy kind whose condition holds, whose facing (when it has one) the leader faces, whose stage matches filter (PSYNERGY_CUE_ANY takes any) and whose target is what selector names (fdSelectPsynergyTarget: a metatile, an actor, or anything); NULL when there is none.
Sint32fdRunPsynergyEndScripts (Uint32 packed)Runs the scene's scripts for Psynergy without paying its PP or showing its usual effect (PSYNERGY_PHASE_BEFORE_END and PSYNERGY_PHASE_AFTER_END, around the kind's ending), as for a Psynergy that ends by itself: packed holds the Psynergy (bits 0 to 9) and its user (bits 10 to 13).

Description

Using an item on the field. Part of field_engine.c.

Enumerations in detail

PSYNERGY_END_SKIP

enum PSYNERGY_END_SKIP

What fdScriptEndLastingPsynergy leaves running, as bits of its skip.

EnumeratorValueDescription
END_SKIP_REVEAL1 << 0
END_SKIP_RING1 << 1the ring of light (ABILITY_MAGNET)
END_SKIP_SAND1 << 2

Definition at line 6 of file field_engine_items.c.

Functions in detail

fdScriptRunMessage

void fdScriptRunMessage(Sint32 actor, Sint32 msg)

Runs message as a script of its own, shown at actor.

References fdScriptEnd(), fdScriptSetMessageId(), fdScriptShowMessageAndWait(), fdScriptStart() and Sint32.

Referenced by fdRunPushMetatile(), fdRunRaisedCue(), fdRunStepCueOrExit() and fdTalkToActor().

Definition at line 14 of file field_engine_items.c.

fdScriptEndAllLastingPsynergy

void fdScriptEndAllLastingPsynergy(void)

Ends every lasting Psynergy (fdScriptEndLastingPsynergy with none skipped).

References fdScriptEndLastingPsynergy().

Referenced by fdEngineRun(), fdLeaderStopIfPending() and fdScriptStart().

Definition at line 23 of file field_engine_items.c.

fdScriptEndLastingPsynergy

void fdScriptEndLastingPsynergy(Sint32 skip)

Ends the lasting Psynergy and runs their end scripts: Reveal, the ring of light and Sand (while the party is sand, MainRoutineStateWork.sandActive), each unless skip holds its bit (PSYNERGY_END_SKIP).

References fdRunPsynergyEndScripts(), MainRoutineStateWork and Sint32.

Referenced by dbIncreaseItemAndLevelRunMotionTest(), dbIncreaseItemAndLevelShowCharacterName(), dbIncreaseItemAndLevelShowName(), fdActorAppearInWhirlwind(), fdActorDescendInWhirlwind(), fdScriptEndAllLastingPsynergy(), fdScriptShowMessageAndOfferScoop(), fdTalkToActor(), scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideCheckPsynergyStone(), scAirsRockInsideFinishPushingPillar(), scAirsRockInsideJumpDownLedge(), scAirsRockInsideLandInHall(), scAirsRockInsideMoveTurningBridgePillar(), scAirsRockInsideOpenTabletRoomDoor(), scAirsRockInsideReadRevealTablet(), scAirsRockInsideRideFaceVent(), scAirsRockInsideRideStatuesVent(), scAirsRockInsideRideWhirlwind(), scAirsRockInsideRiseOnLift(), scAirsRockInsideStartWhirlwind(), scAirsRockInsideStepOntoStake(), scAirsRockInsideVanishStone(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAirsRockInsideWalkToRevealTablet(), scAirsRockRideWhirlwind(), scAirsRockStartWhirlwind(), scAlhafraFindGoldCoins(), scAlhafraGiveBreadToHungryBoy(), scAlhafraMadransArrive(), scAlhafraManorBriggsEscapes(), scAlhafraManorComplainAboutTheMayor(), scAlhafraManorDefendTheMayor(), scAlhafraManorPointOutAirsRock(), scAlhafraManorTellOfTheEasternSea(), scAlhafraOpenDoorAndEnter(), scAncientLemuriaHeadForTheDock(), scAncientLemuriaMeetTheLemurians(), scAnemosInnerSanctumDullahanLightRises(), scAnemosInnerSanctumDullahanOpenTheWay(), scAnemosInnerSanctumDullahanShadowChallenges(), scAnemosInnerSanctumFinishMovingBlock(), scApojiiIslandsDouseAquaStone(), scAquaRockArriveFromInside(), scAquaRockArriveFromPassage(), scAquaRockArriveUpStream(), scAquaRockDouseSummitWaterStone(), scAquaRockDouseWaterStone() and 401 more.

Definition at line 31 of file field_engine_items.c.

fdPartyGetLeaderActor

Sint32 fdPartyGetLeaderActor(void)

Returns the leader's actor id, or ACTOR_FIRST_PLACED while MainRoutineStateWork.ownerOverride is set.

References MainRoutineStateWork and Sint32.

Referenced by dbShopTestTalkToSunshine(), dbShopTestTalkToSunshinesWife(), fdActorRestore(), fdCycloneCopyTouchedMetatiles(), fdEffectCheckCloakTile(), fdEngineRun(), fdFindItemCue(), fdFindPsynergyCue(), fdFlagBlockPlaceAllMarkingEdges(), fdHangingVineSwing(), fdHangingVineUpdate(), fdHoverGlowUpdate(), fdItemDisplayRaiseAboveLeader(), fdItemDisplayShowItem(), fdItemDisplayShowItemInFront(), fdItemDisplayShowPicture(), fdLeaderStopMoving(), fdMadPlantLeapAtLeader(), fdMapScreenGetLeaderPoint(), fdMapScreenInit(), fdMapScreenPlaceLeaderAt(), fdMapScreenStepToPlace(), fdMapScreenUpdateMarkers(), fdMessageShowAtActor(), fdPsynergyEndHover(), fdPsynergyTeleport(), fdRequestBattleFromEncounterTable(), fdRequestDjinnBattle(), fdRunPsynergyEndScripts(), fdScreenTransitionUpdateScanlineTable(), fdScriptAskYesNoAndShowResponse(), fdScriptResetLeaderAndWait(), fdSelectPsynergyTarget(), fdSummonTabletPlayRunes(), fdTeleportPlaySparks(), fdTeleportPlayWhirl(), fdTileCopiesCopyTouchedMetatiles(), fdTreasureSpotMoveLeaderAway(), fdUpdateWalking(), fdUseItem(), fdUsePsynergy(), scAirsRockInsideRestoreMetatileBehindLeader(), scAirsRockInsideSetLedgeMetatilesByLevel(), scAirsRockInsideStampMetatileUnderLeader(), scAirsRockInsideStampOtherMetatileUnderLeader(), scAirsRockInsideStampWideMetatileUnderLeader(), scAlhafraAskWhetherIndraMoved(), scAlhafraBackloggedWithCanoes(), scAlhafraFatherLetsPartyToCave(), scAlhafraManorAskAboutAlhafra() and 47 more.

Definition at line 46 of file field_engine_items.c.

fdItemMatchesFilter

Bool fdItemMatchesFilter(Sint32 filter, Sint32 itemId)

Returns 1 when itemId answers filter: the item itself, ITEM_FILTER_ANY any item, or ITEM_FILTER_HEAVY any weapon, armor, shield or helm; else 0.

References gmItemGetDefinitionStub() and Sint32.

Referenced by fdFindItemCue().

Definition at line 60 of file field_engine_items.c.

fdFindItemCue

const CUE *fdFindItemCue(Sint32 item)

Returns the scene's item cue (CUE_ITEM) for item that applies to what the leader faces, or NULL (item 0 matches any): its item or item filter takes item (fdItemMatchesFilter), and its target is the actor the leader can talk to (CUE_ITEM_ON_ACTOR) or the metatile ahead.

References fdActorLookup(), fdFindNearbyTalkTarget(), fdGameFlagIsConditionActive(), fdGetCollisionAheadOfLeader(), fdItemMatchesFilter(), fdPartyGetLeaderActor() and Sint32.

Referenced by fdHasItemCue() and fdUseItem().

Definition at line 77 of file field_engine_items.c.

fdUseItem

Sint32 fdUseItem(Sint32 packedItem, Sint32 slot)

Uses an item on the field. packedItem holds the item (bits 0 to 9) and the character using it (bits 10 to 13; UNIT_NONE for whoever holds it in the most inventory slots); slot is its inventory slot. The scene's item cue for what the leader faces runs if there is one; otherwise an item with a field action casts it, Retreat asking first. Returns 0 when the scene's script ran or Retreat was declined, else -1.

References fdFindItemCue(), fdFindNearbyTalkTarget(), fdPartyGetLeaderActor(), fdPsynergyEnd(), fdPsynergyLoadResources(), fdPsynergyRun(), fdScriptEnd(), fdScriptSetMessageId(), fdScriptShowMessageAndWait(), fdScriptStart(), fdYesNoAsk(), gmInventoryRemoveStub(), gmItemGetDefinitionStub(), gmPartyCountMembersStub(), gmUnitGet(), MainRoutineStateWork, mnFieldMessageShowStub(), mnMessageArgumentPushStub(), mnMessageCloseFinishedWindowsStub(), result, Sint32, syGameFlagClear(), syGameFlagGet() and syGameFlagSet().

Referenced by fdEngineRun().

Definition at line 126 of file field_engine_items.c.

fdSelectPsynergyTarget

Sint32 fdSelectPsynergyTarget(Sint32 kind)

Chooses what a Psynergy of the given kind acts on, for fdFindPsynergyCue: among the scene's Psynergy cues for that kind whose condition holds (and whose direction, if any, the leader faces), the metatile the leader faces, or for Teleport the metatile under it; else the nearest target in reach (with PSYNERGY_TARGET_ACTOR); else PSYNERGY_TARGET_ANYWHERE for a cue that applies anywhere, or -1.

References fdActorLookup(), fdGameFlagIsConditionActive(), fdGetCollisionAheadOfLeader(), fdGetCollisionUnderLeader(), fdMeasurePsynergyReach(), fdPartyGetLeaderActor(), gmAbilityGetDefinitionStub(), result and Sint32.

Referenced by fdHasPsynergyCue(), fdPsynergyBurst(), fdPsynergyDouse(), fdPsynergyEndReveal(), fdPsynergyEndSand(), fdPsynergyForce(), fdPsynergyFrost(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyPound(), fdPsynergyReveal(), fdPsynergyScoop(), fdPsynergySteerPushedTarget(), fdRunPsynergyEndScripts() and fdUsePsynergy().

Definition at line 289 of file field_engine_items.c.

fdFindPsynergyCue

CUE *fdFindPsynergyCue(Sint32 filter, Sint32 kind, Sint32 selector)

Psynergy kind whose condition holds, whose facing (when it has one) the leader faces, whose stage matches filter (PSYNERGY_CUE_ANY takes any) and whose target is what selector names (fdSelectPsynergyTarget: a metatile, an actor, or anything); NULL when there is none.

References fdActorLookup(), fdGameFlagIsConditionActive(), fdPartyGetLeaderActor(), gmAbilityGetDefinitionStub() and Sint32.

Referenced by fdHasPsynergyCue(), fdPsynergyBlaze(), fdPsynergyBurst(), fdPsynergyDouse(), fdPsynergyEndReveal(), fdPsynergyEndSand(), fdPsynergyForce(), fdPsynergyFrost(), fdPsynergyGrindOnTarget(), fdPsynergyHover(), fdPsynergyParch(), fdPsynergyPound(), fdPsynergyReveal(), fdPsynergyRunTouchedScripts(), fdPsynergyScoop(), fdPsynergySteerPushedTarget(), fdRunPsynergyEndScripts() and fdUsePsynergy().

Definition at line 371 of file field_engine_items.c.

fdRunPsynergyEndScripts

Sint32 fdRunPsynergyEndScripts(Uint32 packed)

Runs the scene's scripts for Psynergy without paying its PP or showing its usual effect (PSYNERGY_PHASE_BEFORE_END and PSYNERGY_PHASE_AFTER_END, around the kind's ending), as for a Psynergy that ends by itself: packed holds the Psynergy (bits 0 to 9) and its user (bits 10 to 13).

References fdBattleEffectStopMainActor(), fdFindPsynergyCue(), fdPartyGetLeaderActor(), fdPsynergyEnd(), fdPsynergyLoadResources(), fdPsynergyRunEnd(), fdPsynergySetupActorPair(), fdRunPsynergyScript(), fdSelectPsynergyTarget(), gmAbilityGetDefinitionStub() and Sint32.

Referenced by fdScriptEndLastingPsynergy() and fdUsePsynergy().

Definition at line 432 of file field_engine_items.c.