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. More…

Included by battle.c.

Macros

NameDescription
#defineANIM_PRIORITY_SHADOW 0The order a battle unit's sprite animations are drawn into its picture (SPR_ANIMATION.priority), the lowest first: the shadow under the body and its weapon, the status icon over them.
#defineANIM_PRIORITY_BODY 1
#defineANIM_PRIORITY_STATUS_ICON 3
#defineANIM_PRIORITY_HIDDEN 9
#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 Grim Reaper's countdown, 1 to 7, as one of 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 (ICON_POISON's 0 up).
#defineICON_ANIMATION_WIDE SPRITE_STATUS_WIDE_POISON

Functions

NameDescription
voidbtObjectUpdateSpritePriorities (void)Runs each tick of a battle: advances the status icons, hides an airborne unit's shadow, and draws whichever side is nearer the camera in front.
UNREAD_RESULTbtUnitBuildStatusFlags (Sint32 unitId, BATTLE_OBJECT *battleObject)Builds the status icon bits of unit id's statuses into its battle object's activeStatuses, which btStatusIconCycle shows.
UNREAD_RESULTbtStatusIconCycle (BATTLE_OBJECT *battleObject)Shows a unit's status icons one after another, and removes the icon when no status is left.
UNREAD_RESULTbtObjectUpdatePose (Sint32 unitId)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'.
voidbtObjectDestroySprites (Sint32 unitId)Releases every sprite unitId's actor holds and leaves it with none, clearing the battle object's animationEntry and shadowEntry.
voidbtObjectSpawnObjectsForList (Sint16 *unitIds, Sint32 refreshPoses)Readies the sprites of the units in the list and releases everyone else's; with refreshPoses, sets every listed unit's pose again.
BATTLE_OBJECT *btObjectGet (Sint32 unitId)Returns unitId's battle object, through its place, or null for a unit with no place.
voidbtSpriteDetachScripts (void *untypedSprite)Detaches the scripts from the four layers (SPR.entries) of one sprite.
voidbtActorDetachSpriteScripts (ACTOR *actor)Unused: detaches the scripts from every sprite of a unit's actor.
Sint32btObjectMarkForRelease (Sint32 unitId)Frees the enemy sprite slots a unit holds and marks its actor for release at the end of the action.
void *btObjectDestroyAll (void)
Sint32btObjectGetAnchor (Sint32 place, POS *pos)Unused: writes the battlefield spot of place (its anchor, on the ground) to pos, and returns 0.
UNREAD_RESULTbtCameraApplyTransform (void)Sets up the camera's view for projecting points, tilted further while commands are chosen.
Sint32btMotionProjectPos (Sint32 unitId, Sint32 *projected)Projects unit id's position onto the screen, into projected (its pixel x and y, then its depth; syConvert3Dto2D).
void *btActorGetSprite (ACTOR *actor, Sint32 spriteIndex)Returns sprite spriteIndex 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.

Description

Each tick's sprite priorities, the status icons, the poses and the sprites of the battle objects. Part of battle.c.

Macros in detail

ANIM_PRIORITY_SHADOW

#define ANIM_PRIORITY_SHADOW 0

The order a battle unit's sprite animations are drawn into its picture (SPR_ANIMATION.priority), the lowest first: the shadow under the body and its weapon, the status icon over them. Any order above 3 is not drawn.

Referenced by btObjectSpawnObjectsForList() and btObjectUpdateSpritePriorities().

Definition at line 9 of file battle_objects.c.

ANIM_PRIORITY_BODY

#define ANIM_PRIORITY_BODY 1

Referenced by btObjectSpawnObjectsForList().

Definition at line 10 of file battle_objects.c.

ANIM_PRIORITY_STATUS_ICON

#define ANIM_PRIORITY_STATUS_ICON 3

Referenced by btObjectSpawnObjectsForList() and btStatusIconCycle().

Definition at line 11 of file battle_objects.c.

ANIM_PRIORITY_HIDDEN

#define ANIM_PRIORITY_HIDDEN 9

Referenced by btObjectUpdateSpritePriorities().

Definition at line 12 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 161 of file battle_objects.c.

ICON_VENOM

#define ICON_VENOM 0x02

Deadly poison.

Definition at line 163 of file battle_objects.c.

ICON_STUN

#define ICON_STUN 0x04

Referenced by btUnitBuildStatusFlags().

Definition at line 164 of file battle_objects.c.

ICON_PSY_SEAL

#define ICON_PSY_SEAL 0x08

Referenced by btUnitBuildStatusFlags().

Definition at line 165 of file battle_objects.c.

ICON_SLEEP

#define ICON_SLEEP 0x10

Referenced by btUnitBuildStatusFlags().

Definition at line 166 of file battle_objects.c.

ICON_DELUSION

#define ICON_DELUSION 0x20

Referenced by btUnitBuildStatusFlags().

Definition at line 167 of file battle_objects.c.

ICON_HAUNT

#define ICON_HAUNT 0x40

Referenced by btUnitBuildStatusFlags().

Definition at line 168 of file battle_objects.c.

ICON_GRIM_REAPER_SHIFT

#define ICON_GRIM_REAPER_SHIFT 6

The Grim Reaper's countdown, 1 to 7, as one of bits 7 to 13.

Referenced by btUnitBuildStatusFlags().

Definition at line 170 of file battle_objects.c.

ICON_MAX

#define ICON_MAX 14

The kinds of icon.

Referenced by btStatusIconCycle().

Definition at line 173 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 211 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 (ICON_POISON's 0 up).

Referenced by btStatusIconCycle().

Definition at line 215 of file battle_objects.c.

ICON_ANIMATION_WIDE

#define ICON_ANIMATION_WIDE SPRITE_STATUS_WIDE_POISON

Referenced by btStatusIconCycle().

Definition at line 216 of file battle_objects.c.

Functions in detail

btObjectUpdateSpritePriorities

void btObjectUpdateSpritePriorities(void)

Runs each tick of a battle: advances the status icons, hides an airborne unit's shadow, and draws whichever side is nearer the camera in front.

References btActorGetSprite(), btObjectGet(), btStatusIconCycle(), btUnitListIds() and Sint32.

Referenced by btRun().

Definition at line 16 of file battle_objects.c.

btUnitBuildStatusFlags

UNREAD_RESULT btUnitBuildStatusFlags(Sint32 unitId, BATTLE_OBJECT *battleObject)

Builds the status icon bits of unit id's statuses into its battle object's activeStatuses, which btStatusIconCycle shows.

References gmUnitGetStub() and Sint32.

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

Definition at line 177 of file battle_objects.c.

btStatusIconCycle

UNREAD_RESULT btStatusIconCycle(BATTLE_OBJECT *battleObject)

Shows a unit's status icons one after another, and removes the icon when no status is left.

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

Referenced by btObjectUpdateSpritePriorities().

Definition at line 220 of file battle_objects.c.

btObjectUpdatePose

UNREAD_RESULT btObjectUpdatePose(Sint32 unitId)

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'.

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

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

Definition at line 317 of file battle_objects.c.

btObjectDestroySprites

void btObjectDestroySprites(Sint32 unitId)

Releases every sprite unitId's actor holds and leaves it with none, clearing the battle object's animationEntry and shadowEntry.

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

Referenced by btObjectSpawnObjectsForList().

Definition at line 346 of file battle_objects.c.

btObjectSpawnObjectsForList

void btObjectSpawnObjectsForList(Sint16 *unitIds, Sint32 refreshPoses)

Readies the sprites of the units in the list and releases everyone else's; with refreshPoses, sets every listed unit's pose again.

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

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

Definition at line 375 of file battle_objects.c.

btObjectGet

BATTLE_OBJECT *btObjectGet(Sint32 unitId)

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

References Sint32.

Referenced by btAbilityApplyToTarget(), btActionRunBuild(), btAutoBattleApplyDamage(), btAutoBattleRunApproachAttack(), btAutoBattleRunAttackOrItem(), btAutoBattleRunPsynergy(), btCameraSetViewAtPairMidpoint(), btDjinnRecoveryReconcile(), btHighlightSetSpriteMode(), btMotionApplyKnockback(), btMotionApplyPairMidpoint(), btMotionApproachTarget(), btMotionFlashHit(), btMotionHopBack(), btMotionLeapBack(), btMotionPlayFall(), btMotionPlayHitFlash(), btMotionProjectCursorPoint(), btMotionProjectPos(), btMotionProjectScaledPos(), btMotionRestartLeap(), btMotionReturnToSpot(), btMotionSetupEscapeObject(), btMotionShowDowned(), btObjectDestroyAll(), btObjectDestroySprites(), btObjectGetPalette(), btObjectMarkForRelease(), btObjectSpawnObjectsForList(), btObjectUpdatePose(), btObjectUpdateSpritePriorities(), btPlacementRelayoutEnemies(), btPlaybackRun(), btPlaybackRunAll(), btProcessTurnEnd(), btStagingRunAttack(), btStagingRunFullScreen(), btStagingRunItem(), btStagingRunPlainAttack(), btStagingRunPsynergyCast(), btTransitionRun(), btUnitClearStatuses(), btUnitProcessActionEnd(), btUnitRefreshPlacement() and btUnitRemoveEnemy().

Definition at line 516 of file battle_objects.c.

btSpriteDetachScripts

void btSpriteDetachScripts(void *untypedSprite)

Detaches the scripts from the four layers (SPR.entries) of one sprite.

References Sint32.

Referenced by btActorDetachSpriteScripts().

Definition at line 532 of file battle_objects.c.

btActorDetachSpriteScripts

void btActorDetachSpriteScripts(ACTOR *actor)

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

References btSpriteDetachScripts() and Sint32.

Definition at line 548 of file battle_objects.c.

btObjectMarkForRelease

Sint32 btObjectMarkForRelease(Sint32 unitId)

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

References btObjectGet(), btObjectReleaseSpriteSlots() and Sint32.

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

Definition at line 571 of file battle_objects.c.

btObjectDestroyAll

void *btObjectDestroyAll(void)

References btObjectGet(), fdActorReleaseStub() and Sint32.

Referenced by btRun() and btStagingDispatchAction().

Definition at line 586 of file battle_objects.c.

btObjectGetAnchor

Sint32 btObjectGetAnchor(Sint32 place, POS *pos)

Unused: writes the battlefield spot of place (its anchor, on the ground) to pos, and returns 0.

References Sint32.

Definition at line 611 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, gmFlagGetStub(), syInitMatrix(), syLookAt(), syLookAtLoad() and syMultiMatrix().

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

Definition at line 622 of file battle_objects.c.

btMotionProjectPos

Sint32 btMotionProjectPos(Sint32 unitId, Sint32 *projected)

Projects unit id's position onto the screen, into projected (its pixel x and y, then its depth; syConvert3Dto2D). Returns 0.

References btActorGetSprite(), btCameraApplyTransform(), btObjectGet(), Sint32, syConvert3Dto2D() and syMulFX().

Definition at line 639 of file battle_objects.c.

btActorGetSprite

void *btActorGetSprite(ACTOR *actor, Sint32 spriteIndex)

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

References Sint32.

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

Definition at line 657 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 675 of file battle_objects.c.