Skip to Content
The Alchemy Project

src/battle/battle_objects.c

Each tick's sprite priorities, the status icons, the poses and the sprites of the battle objects, and the camera they are projected through. More…

Included by battle.c.

Macros

NameDescription
#defineLAYER_ORDER_SHADOW 0The drawing order of a unit's sprite layers (SPR_ANIMATION.priority): its shadow, its body and the overlay drawn with it, and its status icon.
#defineLAYER_ORDER_BODY 1
#defineLAYER_ORDER_STATUS_ICON 3
#defineICON_POISON 0x01The status icons' bits in BATTLE_OBJECT.activeStatuses.
#defineICON_VENOM 0x02deadly poison
#defineICON_STUN 0x04
#defineICON_PSY_SEAL 0x08
#defineICON_SLEEP 0x10
#defineICON_DELUSION 0x20
#defineICON_HAUNT 0x40
#defineICON_GRIM_REAPER_SHIFT 6The curse's turns left, 1 to 7, shown as bits 7 to 13.
#defineICON_MAX 14the kinds of icon
#defineICON_CYCLE_TICKS 80The ticks each status icon shows before the next one's turn.
#defineICON_ANIMATION_NARROW SPRITE_STATUS_POISONThe icons' first animations, for units 32 pixels wide and for the rest: each adds the icon's bit number.
#defineICON_ANIMATION_WIDE SPRITE_STATUS_WIDE_POISON

Functions

NameDescription
voidbtUnitBuildStatusFlags (Sint32 id, BATTLE_OBJECT *object)Builds the status icon bits of unit id's statuses into its battle object's activeStatuses, which btStatusIconCycle shows; a called beast's object (BATTLE_OBJECT.borrowed) keeps its bits.
voidbtStatusIconCycle (BATTLE_OBJECT *slot)Shows the unit's status icons in turn, each for ICON_CYCLE_TICKS, and moves on at once when the shown status ends.
voidbtObjectUpdatePose (Sint32 id)Sets a unit's pose to match its state, held, down or standing, and sets its sway a little out of step with its neighbours': from two steps below normal speed to one above, by its id.
voidbtObjectDestroySprites (Sint32 unitId)Destroys a unit's sprites, its status icon and shadow with them, leaving its battle object with none.
voidbtObjectSpawnObjectsForList (Sint16 *unitIds, Sint32 refreshPoses, Sint32 releaseOthers)Readies the sprites of the units in unitIds (ended by BATTLE_UNIT_LIST_END): with releaseOthers, first destroys those of every unit not listed; then creates each listed unit's sprites (body, overlay, status icon and shadow; or the two parts of a two-part enemy) unless it has them, builds its status icons and sets its pose.
voidbtActorSpawnObjectsForList (Sint16 *list, Sint32 refresh)Readies the sprites of the units in list, ended by BATTLE_UNIT_LIST_END, and destroys every other unit's; with refresh, sets the listed units' poses again.
voidbtSpriteDetachScripts (void *recordGroup)Detaches the scripts from the four sprite entries of one sprite.
static __inline__ BATTLE_OBJECT *btObjectFindSlot (Sint32 id)Returns a unit's battle object, through its place in BATTLE_STATE.placement, or null for a unit with no place.
voidbtObjectUpdateSpritePriorities (void)Event, each tick of a battle: advances every unit's status icon, sets its shadow's priority by whether it is airborne, draws the nearer side in front and draws a unit under Haze (DEFEND_VANISHED) as an outline.
voidbtActorDetachSpriteScripts (MOTION_OBJECT *object)Unused: detaches the scripts from every sprite of a unit's actor.
Sint32btObjectMarkForRelease (Sint32 objectId)Frees the enemy sprite slots a unit holds and marks its actor for release at the end of the action.
voidbtMotionDestroyAllSlotObjects (void)Releases the actor of every battle object marked for release.
Sint32btObjectGetAnchor (Sint32 slot, POS *out)Unused: writes the anchor of the battle object in place slot to out, at height 0.
UNREAD_RESULTbtCameraApplyTransform (void)Sets up the camera's view for projecting points, tilted further while commands are chosen.
Sint32btMotionProjectPos (Sint32 id, Sint32 *projected)Projects a battle object's position to the screen, in projected.
void *btActorGetSprite (MOTION_OBJECT *object, Sint32 recordIndex)Returns sprite recordIndex of an actor (0 only, for a single sprite), or null when it has no such sprite.
voidbtCameraSetDefaultView (void)Puts the battle camera at its default view of the battlefield's centre.
BATTLE_OBJECT *btObjectGet (Sint32 objectId)Returns a unit's battle object, through its place in BATTLE_STATE.placement, or null for a unit with no place: the same lookup as btObjectFindSlot, for the other parts of the battle.

Description

Each tick's sprite priorities, the status icons, the poses and the sprites of the battle objects, and the camera they are projected through. Part of battle.c.

Macros in detail

LAYER_ORDER_SHADOW

#define LAYER_ORDER_SHADOW 0

The drawing order of a unit's sprite layers (SPR_ANIMATION.priority): its shadow, its body and the overlay drawn with it, and its status icon. A shadow takes SPRITE_LAYER_NOT_DRAWN while its unit is in the air.

Referenced by btObjectSpawnObjectsForList() and btObjectUpdateSpritePriorities().

Definition at line 8 of file battle_objects.c.

LAYER_ORDER_BODY

#define LAYER_ORDER_BODY 1

Referenced by btObjectSpawnObjectsForList().

Definition at line 9 of file battle_objects.c.

LAYER_ORDER_STATUS_ICON

#define LAYER_ORDER_STATUS_ICON 3

Referenced by btObjectSpawnObjectsForList() and btStatusIconCycle().

Definition at line 10 of file battle_objects.c.

ICON_POISON

#define ICON_POISON 0x01

The status icons' bits in BATTLE_OBJECT.activeStatuses.

Referenced by btUnitBuildStatusFlags().

Definition at line 13 of file battle_objects.c.

ICON_VENOM

#define ICON_VENOM 0x02

deadly poison

Definition at line 14 of file battle_objects.c.

ICON_STUN

#define ICON_STUN 0x04

Referenced by btUnitBuildStatusFlags().

Definition at line 15 of file battle_objects.c.

ICON_PSY_SEAL

#define ICON_PSY_SEAL 0x08

Referenced by btUnitBuildStatusFlags().

Definition at line 16 of file battle_objects.c.

ICON_SLEEP

#define ICON_SLEEP 0x10

Referenced by btUnitBuildStatusFlags().

Definition at line 17 of file battle_objects.c.

ICON_DELUSION

#define ICON_DELUSION 0x20

Referenced by btUnitBuildStatusFlags().

Definition at line 18 of file battle_objects.c.

ICON_HAUNT

#define ICON_HAUNT 0x40

Referenced by btUnitBuildStatusFlags().

Definition at line 19 of file battle_objects.c.

ICON_GRIM_REAPER_SHIFT

#define ICON_GRIM_REAPER_SHIFT 6

The curse's turns left, 1 to 7, shown as bits 7 to 13.

Referenced by btUnitBuildStatusFlags().

Definition at line 21 of file battle_objects.c.

ICON_MAX

#define ICON_MAX 14

the kinds of icon

Referenced by btStatusIconCycle().

Definition at line 71 of file battle_objects.c.

ICON_CYCLE_TICKS

#define ICON_CYCLE_TICKS 80

The ticks each status icon shows before the next one's turn.

Referenced by btStatusIconCycle().

Definition at line 74 of file battle_objects.c.

ICON_ANIMATION_NARROW

#define ICON_ANIMATION_NARROW SPRITE_STATUS_POISON

The icons' first animations, for units 32 pixels wide and for the rest: each adds the icon's bit number.

Referenced by btStatusIconCycle().

Definition at line 78 of file battle_objects.c.

ICON_ANIMATION_WIDE

#define ICON_ANIMATION_WIDE SPRITE_STATUS_WIDE_POISON

Referenced by btStatusIconCycle().

Definition at line 79 of file battle_objects.c.

Functions in detail

btUnitBuildStatusFlags

void btUnitBuildStatusFlags(Sint32 id, BATTLE_OBJECT *object)

Builds the status icon bits of unit id's statuses into its battle object's activeStatuses, which btStatusIconCycle shows; a called beast's object (BATTLE_OBJECT.borrowed) keeps its bits. A stun shows no icon on the Serpent, the Kraken or the Fusion Dragon.

References gmUnitGet() and Sint32.

Referenced by btObjectSpawnObjectsForList(), btPlaybackRun(), btPlaybackRunAll() and btUnitClearStatuses().

Definition at line 27 of file battle_objects.c.

btStatusIconCycle

void btStatusIconCycle(BATTLE_OBJECT *slot)

Shows the unit's status icons in turn, each for ICON_CYCLE_TICKS, and moves on at once when the shown status ends.

References btActorGetSprite(), fdSpriteAddAnimationStub(), fdSpriteAnimationStartStub(), fdSpriteRemoveAnimationStub() and Sint32.

Referenced by btObjectUpdateSpritePriorities().

Definition at line 83 of file battle_objects.c.

btObjectUpdatePose

void btObjectUpdatePose(Sint32 id)

Sets a unit's pose to match its state, held, down or standing, and sets its sway a little out of step with its neighbours': from two steps below normal speed to one above, by its id.

References btObjectGet(), fdActorSelectAnimationStub(), fdActorSetAnimationSpeedStub(), gmUnitGet() and Sint32.

Referenced by btObjectSpawnObjectsForList(), btPlaybackRun() and btPlaybackRunAll().

Definition at line 171 of file battle_objects.c.

btObjectDestroySprites

void btObjectDestroySprites(Sint32 unitId)

Destroys a unit's sprites, its status icon and shadow with them, leaving its battle object with none.

References btActorGetSprite(), btObjectGet(), fdSpriteDestroyStub() and Sint32.

Referenced by btMotionCallBeast(), btMotionDismissBeast() and btObjectSpawnObjectsForList().

Definition at line 200 of file battle_objects.c.

btObjectSpawnObjectsForList

void btObjectSpawnObjectsForList(Sint16 *unitIds, Sint32 refreshPoses, Sint32 releaseOthers)

Readies the sprites of the units in unitIds (ended by BATTLE_UNIT_LIST_END): with releaseOthers, first destroys those of every unit not listed; then creates each listed unit's sprites (body, overlay, status icon and shadow; or the two parts of a two-part enemy) unless it has them, builds its status icons and sets its pose. With refreshPoses, sets every listed unit's pose again afterwards.

References btObjectDestroySprites(), btObjectGet(), btObjectUpdatePose(), btPlacementContainsId(), btUnitBuildStatusFlags(), EventsRunning, fdResourceGetMetadataRecordStubStub(), fdSpriteAddAnimationStub(), fdSpriteAnimationStartStub(), fdSpriteCreateStub(), Sint32 and sySynch().

Referenced by btActorSpawnObjectsForList(), btMotionCallBeast() and btMotionDismissBeast().

Definition at line 231 of file battle_objects.c.

btActorSpawnObjectsForList

void btActorSpawnObjectsForList(Sint16 *list, Sint32 refresh)

Readies the sprites of the units in list, ended by BATTLE_UNIT_LIST_END, and destroys every other unit's; with refresh, sets the listed units' poses again.

References btObjectSpawnObjectsForList() and Sint32.

Referenced by btAutoBattleRunPsynergy(), btObjectPut(), btObjectPutKeepingPoses(), btStagingRunAttack(), btStagingRunFullScreen() and btTransitionRun().

Definition at line 387 of file battle_objects.c.

btSpriteDetachScripts

void btSpriteDetachScripts(void *recordGroup)

Detaches the scripts from the four sprite entries of one sprite.

References Sint32.

Referenced by btActorDetachSpriteScripts().

Definition at line 393 of file battle_objects.c.

btObjectFindSlot

static __inline__ BATTLE_OBJECT *btObjectFindSlot(Sint32 id)

Returns a unit's battle object, through its place in BATTLE_STATE.placement, or null for a unit with no place.

References Sint32.

Referenced by btMotionDestroyAllSlotObjects(), btMotionProjectPos(), btObjectMarkForRelease() and btObjectUpdateSpritePriorities().

Definition at line 411 of file battle_objects.c.

btObjectUpdateSpritePriorities

void btObjectUpdateSpritePriorities(void)

Event, each tick of a battle: advances every unit's status icon, sets its shadow's priority by whether it is airborne, draws the nearer side in front and draws a unit under Haze (DEFEND_VANISHED) as an outline.

References btActorGetSprite(), btObjectFindSlot(), btStatusIconCycle(), btUnitListIds(), gmUnitGet() and Sint32.

Referenced by btRun().

Definition at line 426 of file battle_objects.c.

btActorDetachSpriteScripts

void btActorDetachSpriteScripts(MOTION_OBJECT *object)

Unused: detaches the scripts from every sprite of a unit's actor.

References btSpriteDetachScripts() and Sint32.

Definition at line 570 of file battle_objects.c.

btObjectMarkForRelease

Sint32 btObjectMarkForRelease(Sint32 objectId)

Frees the enemy sprite slots a unit holds and marks its actor for release at the end of the action. Returns 0.

References btObjectFindSlot(), btObjectReleaseSpriteSlots() and Sint32.

Referenced by btChangeEnemyForm(), btMotionDismissBeast(), btMotionPlayFall(), btMotionShowDowned(), btPlaybackRun(), btStagingRunFlee() and btUnitRemoveEnemy().

Definition at line 603 of file battle_objects.c.

btMotionDestroyAllSlotObjects

void btMotionDestroyAllSlotObjects(void)

Releases the actor of every battle object marked for release.

References btObjectFindSlot(), fdActorReleaseStub() and Sint32.

Referenced by btChangeEnemyForm(), btMotionDismissBeast(), btRun() and btStagingDispatchAction().

Definition at line 614 of file battle_objects.c.

btObjectGetAnchor

Sint32 btObjectGetAnchor(Sint32 slot, POS *out)

Unused: writes the anchor of the battle object in place slot to out, at height 0.

References result and Sint32.

Definition at line 639 of file battle_objects.c.

btCameraApplyTransform

UNREAD_RESULT btCameraApplyTransform(void)

Sets up the camera's view for projecting points, tilted further while commands are chosen.

References BattleCameraCommandMatrix, syGameFlagGet(), syInitMatrix(), syLookAt(), syLookAtLoad() and syMultiMatrix().

Referenced by btMotionProjectCursorPoint(), btMotionProjectPos() and btMotionProjectScaledPos().

Definition at line 653 of file battle_objects.c.

btMotionProjectPos

Sint32 btMotionProjectPos(Sint32 id, Sint32 *projected)

Projects a battle object's position to the screen, in projected.

References btActorGetSprite(), btCameraApplyTransform(), btObjectFindSlot(), Sint32 and syConvert3Dto2D().

Definition at line 670 of file battle_objects.c.

btActorGetSprite

void *btActorGetSprite(MOTION_OBJECT *object, Sint32 recordIndex)

Returns sprite recordIndex of an actor (0 only, for a single sprite), or null when it has no such sprite.

References Sint32.

Referenced by btMotionProjectCursorPoint(), btMotionProjectPos(), btMotionProjectScaledPos(), btMotionReleaseBuffer(), btMotionShowDowned(), btObjectDestroySprites(), btObjectSetColorMode(), btObjectUpdateSpritePriorities(), btPlaybackRun(), btStagingRunAttack(), btStagingRunFullScreen(), btStagingRunItem(), btStagingRunPsynergyCast() and btStatusIconCycle().

Definition at line 693 of file battle_objects.c.

btCameraSetDefaultView

void btCameraSetDefaultView(void)

Puts the battle camera at its default view of the battlefield's centre.

References Sint32, syCalcPoint(), syInitMatrix(), syMatrixTranslateVector(), syRotX() and syRotY().

Referenced by btGatherActions() and btRun().

Definition at line 715 of file battle_objects.c.

btObjectGet

BATTLE_OBJECT *btObjectGet(Sint32 objectId)

Returns a unit's battle object, through its place in BATTLE_STATE.placement, or null for a unit with no place: the same lookup as btObjectFindSlot, for the other parts of the battle.

References Sint32.

Referenced by btAbilityApplyToTarget(), btActionRunBuild(), btAutoBattleApplyDamage(), btAutoBattleRunApproachAttack(), btAutoBattleRunAttackOrItem(), btAutoBattleRunPsynergy(), btCameraSetViewAtPairMidpoint(), btChangeEnemyForm(), btDjinnRecoveryCountDownSide(), btHighlightSetSpriteMode(), btMotionApplyKnockback(), btMotionApplyPairMidpoint(), btMotionApproachTarget(), btMotionCallBeast(), btMotionDismissBeast(), btMotionFlashHit(), btMotionGetSlotPalette(), btMotionHopBack(), btMotionLeapBack(), btMotionPlayFall(), btMotionPlayHitFlash(), btMotionProjectCursorPoint(), btMotionProjectScaledPos(), btMotionReleaseBuffer(), btMotionRestartLeap(), btMotionReturnToSpot(), btMotionSetupEscapeObject(), btMotionShowDowned(), btObjectDestroySprites(), btObjectSpawnObjectsForList(), btObjectUpdatePose(), btPartySwapInReserves(), btPlacementRelayoutEnemies(), btPlaybackRun(), btPlaybackRunAll(), btProcessTurnEnd(), btStagingRunAttack(), btStagingRunFullScreen(), btStagingRunItem(), btStagingRunPsynergyCast(), btTransitionRun(), btUnitClearStatuses(), btUnitProcessActionEnd(), btUnitRefreshPlacement() and btUnitRemoveEnemy().

Definition at line 741 of file battle_objects.c.