Skip to Content
The Alchemy Project

src/field/field_engine_actors.c

The party's sprites, placing a scene's actors, and the actor table. More…

Included by field_engine.c.

Macros

NameDescription
#definePLACEMENT_PARTY_COUNT 8A placement row's sprite: below PLACEMENT_PARTY_COUNT a party member, who keeps that actor id; one up to PLACEMENT_SPRITE_MAX takes the next free slot, and one above it, which no table names, takes the slot of the row before.
#definePLACEMENT_SPRITE_MAX 9989
#definePLACEMENT_SHIP 8A placement's character after the party: the ship.
#defineLOOKUP_ID_COUNT 192The ids fdActorLookup answers: more than the FIELD_ACTOR_COUNT slots.
#defineFLAG_IN_VIEW 0x164kept clear, so a placement using it appears
#defineFLAG_OUT_OF_VIEW 0x165kept set, so a placement using it does not

Enumerations

NameDescription
enumanonymous enum { DJINN_FLAG_COUNT }

Functions

NameDescription
Sint32fdPartyGetCharacterSprite (Sint32 character)Picks the sprite a scene placement's character id shows: the ship (PLACEMENT_SHIP) is SPRITE_WINGED_SHIP_SMALL on the world map and SPRITE_WINGED_SHIP elsewhere, each one's flying picture once FLAG_SHIP_FLIES is set.
voidfdActorReservedNoOperation (void)Does nothing; nothing calls it, nor its stub call in engine_stubs.s.
voidfdScriptSpawnActorTable (ACTOR_PLACE *entry, Sint32 slot)Creates the actors of a scene's actor placement table (ended by sprite -1), and records the table among the scene's tables.
Sint32fdScenePointGetPos (Sint32 id, FIXED *pos)Looks point id up in the map's scene points (its points.tsv, ended by id 0xff) and writes its x and z, in 16.16 pixels, to position; returns 0, or -1 when the map has no such point.
voidfdActorReleaseAtIndex (Uint32 actorIndex)Releases the actor in slot actorIndex of the field state's table, if there is one, and empties the slot.
Uint8 *fdSpriteAddAnimationStub (void *resource, Sint32 id)Stub calls the parts make, each passing its own view of the record: fdSpriteAddAnimation and fdSpriteAnimationStart (field.c, resource_slot/) take the metadata slot state and the animation entry.
voidfdActorResetForLeader (Sint32 table)Creates a scene's actors on entering it, as The Broken Seal's fdActorResetForLeader does: the party leader where the main routine's state puts it, the scene's placement table from actor slot 8, and the camera that follows the leader; it also chooses the leader's control mode.
Sint32fdActorFindLastActiveId (void)Returns the slot after the last placed actor (8 when there is none), or -1 when the last slot is occupied.
voidfdAssignViewFlags (VIEWED_PLACEMENT *entry)Gives each actor placement with condition 0 a condition saying whether it lies within the map's view bounds, so that only those inside appear.
voidfdActorTableClear (void)Empties all the actor slots, without releasing the actors.
ACTOR *fdActorLookup (Uint32 actorId)Returns the actor in slot actorId (below LOOKUP_ID_COUNT), or NULL.
voidfdActorTableSnapshot (void)Saves up to 32 actors into SnapshotObjects, with each one's slot, animation, sprite flags and priority, so that they can be put back.
voidfdActorRestore (void)Puts back the actors the snapshot saved, and moves the camera to the party leader's height.

Description

The party's sprites, placing a scene's actors, and the actor table. Part of field_engine.c.

Macros in detail

PLACEMENT_PARTY_COUNT

#define PLACEMENT_PARTY_COUNT 8

A placement row's sprite: below PLACEMENT_PARTY_COUNT a party member, who keeps that actor id; one up to PLACEMENT_SPRITE_MAX takes the next free slot, and one above it, which no table names, takes the slot of the row before.

Referenced by fdScriptSpawnActorTable().

Definition at line 14 of file field_engine_actors.c.

PLACEMENT_SPRITE_MAX

#define PLACEMENT_SPRITE_MAX 9989

Referenced by fdScriptSpawnActorTable().

Definition at line 15 of file field_engine_actors.c.

PLACEMENT_SHIP

#define PLACEMENT_SHIP 8

A placement's character after the party: the ship.

Referenced by fdPartyGetCharacterSprite().

Definition at line 17 of file field_engine_actors.c.

LOOKUP_ID_COUNT

#define LOOKUP_ID_COUNT 192

The ids fdActorLookup answers: more than the FIELD_ACTOR_COUNT slots.

Referenced by fdActorLookup().

Definition at line 20 of file field_engine_actors.c.

FLAG_IN_VIEW

#define FLAG_IN_VIEW 0x164

kept clear, so a placement using it appears

Referenced by fdAssignViewFlags().

Definition at line 380 of file field_engine_actors.c.

FLAG_OUT_OF_VIEW

#define FLAG_OUT_OF_VIEW 0x165

kept set, so a placement using it does not

Referenced by fdAssignViewFlags().

Definition at line 381 of file field_engine_actors.c.

Enumerations in detail

anonymous enum

enum { DJINN_FLAG_COUNT }

EnumeratorValueDescription
DJINN_FLAG_COUNTELEMENT_COUNT * DJINN_PER_ELEMENTDJINN_PER_ELEMENT flags per element: the Djinn flags are 48 to 127, their hiding flags the next 80.

Definition at line 4 of file field_engine_actors.c.

Functions in detail

fdPartyGetCharacterSprite

Sint32 fdPartyGetCharacterSprite(Sint32 character)

Picks the sprite a scene placement's character id shows: the ship (PLACEMENT_SHIP) is SPRITE_WINGED_SHIP_SMALL on the world map and SPRITE_WINGED_SHIP elsewhere, each one's flying picture once FLAG_SHIP_FLIES is set.

References MainRoutineStateWork, Sint32 and syGameFlagGet().

Referenced by fdScriptSpawnActorTable().

Definition at line 26 of file field_engine_actors.c.

fdActorReservedNoOperation

void fdActorReservedNoOperation(void)

Does nothing; nothing calls it, nor its stub call in engine_stubs.s.

Definition at line 46 of file field_engine_actors.c.

fdScriptSpawnActorTable

void fdScriptSpawnActorTable(ACTOR_PLACE *entry, Sint32 slot)

Creates the actors of a scene's actor placement table (ended by sprite -1), and records the table among the scene's tables.

References fdActorCreateStub(), fdActorLookup(), fdActorSelectAnimationStub(), fdActorSetMovementType(), fdActorSetPosAndResetMotionStub(), fdGameFlagIsConditionActive(), fdMapGridGetTerrainHeightStub(), fdPartyGetCharacterSprite(), fdScenePointGetPos(), MainRoutineStateWork, SceneLocalState, Sint32, syGameFlagGet(), syRandom() and syVRAMCacheFreeEntry().

Referenced by fdActorResetForLeader() and fdScriptSpawnActorsAfterLast().

Definition at line 52 of file field_engine_actors.c.

fdScenePointGetPos

Sint32 fdScenePointGetPos(Sint32 id, FIXED *pos)

Looks point id up in the map's scene points (its points.tsv, ended by id 0xff) and writes its x and z, in 16.16 pixels, to position; returns 0, or -1 when the map has no such point.

References fdStreamReadU16() and Sint32.

Referenced by fdSceneItemFindPos() and fdScriptSpawnActorTable().

Definition at line 211 of file field_engine_actors.c.

fdActorReleaseAtIndex

void fdActorReleaseAtIndex(Uint32 actorIndex)

Releases the actor in slot actorIndex of the field state's table, if there is one, and empties the slot.

References fdActorLookup() and fdActorReleaseStub().

Referenced by fdTreasureSpotRemove().

Definition at line 233 of file field_engine_actors.c.

fdActorResetForLeader

void fdActorResetForLeader(Sint32 table)

Creates a scene's actors on entering it, as The Broken Seal's fdActorResetForLeader does: the party leader where the main routine's state puts it, the scene's placement table from actor slot 8, and the camera that follows the leader; it also chooses the leader's control mode.

References fdActorCreateStub(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdActorStartCameraStub(), fdActorTableClear(), fdMapGridGetTerrainHeightStub(), fdScriptSpawnActorTable(), fdSpriteAddAnimationStub(), FieldDefaultPlacements, MainRoutineStateWork and Sint32.

Referenced by fdEngineRun() and fdScriptResetLeaderAndWait().

Definition at line 251 of file field_engine_actors.c.

fdActorFindLastActiveId

Sint32 fdActorFindLastActiveId(void)

Returns the slot after the last placed actor (8 when there is none), or -1 when the last slot is occupied.

References Sint32.

Referenced by fdScriptSpawnActorsAfterLast().

Definition at line 363 of file field_engine_actors.c.

fdAssignViewFlags

void fdAssignViewFlags(VIEWED_PLACEMENT *entry)

Gives each actor placement with condition 0 a condition saying whether it lies within the map's view bounds, so that only those inside appear.

References Sint32, syGameFlagClear() and syGameFlagSet().

Definition at line 385 of file field_engine_actors.c.

fdActorTableClear

void fdActorTableClear(void)

Empties all the actor slots, without releasing the actors.

References Sint32.

Referenced by fdActorResetForLeader().

Definition at line 414 of file field_engine_actors.c.

fdActorLookup

ACTOR *fdActorLookup(Uint32 actorId)

Returns the actor in slot actorId (below LOOKUP_ID_COUNT), or NULL.

Referenced by fdActorAppearInSparks(), fdActorCenterOnColumn(), fdActorClearDestinationAndStand(), fdActorConfigureSpriteColor(), fdActorFaceActorById(), fdActorFaceDirectionAndRefreshById(), fdActorFaceDirectionById(), fdActorGetById(), fdActorGetScreenPos(), fdActorGetSpriteShape(), fdActorJump(), fdActorLaunchFromLeader(), fdActorMoveToAndWaitById(), fdActorPlaceOnActor(), fdActorReleaseAtIndex(), fdActorReleaseById(), fdActorResetTargetsAndVelocity(), fdActorRestore(), fdActorReturnHome(), fdActorSetAnimationById(), fdActorSetAnimationSpeedById(), fdActorSetDestinationById(), fdActorSetDestinationOffsetById(), fdActorSetHorizontalPosAndAngleWithTerrain(), fdActorSetHorizontalPosWithTerrain(), fdActorSetMovementTypeAndWaitById(), fdActorSetMovementTypeById(), fdActorSetOthersPaused(), fdActorSetPosWithTerrain(), fdActorSetSpeedParams(), fdActorSetSpritePriority(), fdActorSetSquareSprite(), fdActorSetWideSprite(), fdActorShakeAngle(), fdActorShowEmoteById(), fdActorStartRepeatedMotion(), fdActorStop(), fdActorTableSnapshot(), fdActorTakeLeaderLayer(), fdActorTurnToFaceEachOther(), fdActorWaitForAnimationChange(), fdActorWaitForAnimationEnd(), fdActorWaitForMoveById(), fdActorWaitForScriptEndById(), fdActorWalkByAndWaitById(), fdActorWalkByById(), fdActorWalkToAndWaitById(), fdActorWalkToById(), fdActorWatchAndSetScript(), fdActorWatchAndStartScript() and 70 more.

Definition at line 424 of file field_engine_actors.c.

fdActorTableSnapshot

void fdActorTableSnapshot(void)

Saves up to 32 actors into SnapshotObjects, with each one's slot, animation, sprite flags and priority, so that they can be put back.

References fdActorLookup(), Sint32, SnapshotObjects and syDMAXCopy().

Referenced by fdEngineRun(), fdMapScreenShow(), scAnkohlRuinsPushFaceHalfIntoGap(), scApojiiIslandsDouseAquaStone(), scContigoOfferLuckyDice(), scContigoOfferLuckyWheels(), scContigoOfferSuperLuckyDice(), scGabombaStatueHearTheOffering(), scGabombaStatueSeeHowItWorks(), scGaiaRockInsideCycloneClearsCobweb(), scGaiaRockInsideCycloneClearsTwinAltarsBushes(), scGaiaRockInsidePlaceDollOnCobwebAltar(), scGaiaRockInsidePlaceDollOnEastAltar(), scGaiaRockInsidePlaceDollOnWestAltar(), scMarsLighthouseEntranceGrindIce() and scMarsLighthouseTowersRouteFireThroughPipeline().

Definition at line 441 of file field_engine_actors.c.

fdActorRestore

void fdActorRestore(void)

Puts back the actors the snapshot saved, and moves the camera to the party leader's height.

References fdActorLookup(), fdActorSelectAnimationStub(), fdActorSetSpriteFlagsStub(), fdPartyGetLeaderActor(), Sint32, SnapshotObjects and syDMAXCopy().

Referenced by fdEngineRun().

Definition at line 491 of file field_engine_actors.c.