Skip to Content
The Alchemy Project

src/battle/battle_placement.c

Battle objects made and placed on the battlefield. More…

Included by battle.c.

Macros

NameDescription
#defineBATTLE_OBJECT_ACTOR_KIND 15The fdActorCreate kind a battle object's actor is made with: one that makes no sprite, its battle sprites being attached afterwards.
#defineIS_PLACEHOLDER_ID (id) ((Uint16)((id) - BATTLE_UNIT_REMOVED) <= 1)BATTLE_STATE.enemyIds of an enemy that left the battle, and of a place held for one: unit ids 254 and 255 in the list.
#defineENEMY_COLUMN_X (-80)The enemies' column, in pixels from the battlefield's centre, and the nearer place the Kraken and the Fusion Dragon would take.
#defineENEMY_COLUMN_NEAR_X (-50)
#defineENEMY_SPACING_LARGE 38Pixels of the column a large enemy, a small one and an empty place take.
#defineENEMY_SPACING_SMALL 27
#defineENEMY_SPACING_EMPTY 25
#defineESTIMATED_ENEMY_SPACING 30The spacing the column's length is first estimated from for up to four enemies; five or six are estimated at a small enemy's.

Functions

NameDescription
voidbtObjectMake (BATTLE_OBJECT *battleObject, Sint32 unitId, Sint32 x, Sint32 y)Creates the battle object of a unit at (x, y) on the battlefield: its sprite, palette, size and weapon, turned to face the centre.
voidbtPlacementGetStepPair (Sint32 partyPlace, Sint32 *x, Sint32 *y)Unused: reads the battlefield position of a party place.
voidbtPlacementLayoutEnemies (Uint16 *unitIds, Sint32 count, Sint32 *xPositions, Sint32 *zPositions)Lays out count enemies in a column left of the centre, spaced by their size, from a rough estimate of the column's length.
Sint32btEnemyGetFreeUnitId (void)Returns the id of the first free enemy unit, or -1 when all six are taken.
UNREAD_RESULTbtPlacementRelayoutEnemies (void)Lays the enemies out again and moves each one's battle object anchor to its new place.
voidbtUnitRefreshPlacement (void)Places every unit at the start of a battle and creates its battle object at its spot.
BoolbtPlacementContainsId (Sint16 *list, Sint32 place)Returns 1 if the unit at place is in list.

Description

Battle objects made and placed on the battlefield. Part of battle.c.

Macros in detail

BATTLE_OBJECT_ACTOR_KIND

#define BATTLE_OBJECT_ACTOR_KIND 15

The fdActorCreate kind a battle object's actor is made with: one that makes no sprite, its battle sprites being attached afterwards.

Referenced by btObjectMake().

Definition at line 7 of file battle_placement.c.

IS_PLACEHOLDER_ID

#define IS_PLACEHOLDER_ID(id) ((Uint16)((id) - BATTLE_UNIT_REMOVED) <= 1)

BATTLE_STATE.enemyIds of an enemy that left the battle, and of a place held for one: unit ids 254 and 255 in the list.

Referenced by btPlacementLayoutEnemies().

Definition at line 215 of file battle_placement.c.

ENEMY_COLUMN_X

#define ENEMY_COLUMN_X (-80)

The enemies' column, in pixels from the battlefield's centre, and the nearer place the Kraken and the Fusion Dragon would take.

Referenced by btPlacementLayoutEnemies().

Definition at line 219 of file battle_placement.c.

ENEMY_COLUMN_NEAR_X

#define ENEMY_COLUMN_NEAR_X (-50)

Referenced by btPlacementLayoutEnemies().

Definition at line 220 of file battle_placement.c.

ENEMY_SPACING_LARGE

#define ENEMY_SPACING_LARGE 38

Pixels of the column a large enemy, a small one and an empty place take.

Referenced by btPlacementLayoutEnemies().

Definition at line 222 of file battle_placement.c.

ENEMY_SPACING_SMALL

#define ENEMY_SPACING_SMALL 27

Referenced by btPlacementLayoutEnemies().

Definition at line 223 of file battle_placement.c.

ENEMY_SPACING_EMPTY

#define ENEMY_SPACING_EMPTY 25

Referenced by btPlacementLayoutEnemies().

Definition at line 224 of file battle_placement.c.

ESTIMATED_ENEMY_SPACING

#define ESTIMATED_ENEMY_SPACING 30

The spacing the column's length is first estimated from for up to four enemies; five or six are estimated at a small enemy's.

Referenced by btPlacementLayoutEnemies().

Definition at line 227 of file battle_placement.c.

Functions in detail

btObjectMake

void btObjectMake(BATTLE_OBJECT *battleObject, Sint32 unitId, Sint32 x, Sint32 y)

Creates the battle object of a unit at (x, y) on the battlefield: its sprite, palette, size and weapon, turned to face the centre.

References BattleObjectEmptyScript, btEnemySpriteLoadIntoSlots(), btSpriteGetPalette(), btSpriteGetSprite(), btUnitGetWeaponSprite(), fdActorCreateStub(), fdActorStartScriptStub(), gmInventoryGetEquippedItemStub(), gmUnitGetStub(), Sint32 and syAtan().

Referenced by btAbilityApplyToTarget() and btUnitRefreshPlacement().

Definition at line 11 of file battle_placement.c.

btPlacementGetStepPair

void btPlacementGetStepPair(Sint32 partyPlace, Sint32 *x, Sint32 *y)

Unused: reads the battlefield position of a party place.

References BattlePlacementSpots and Sint32.

Definition at line 206 of file battle_placement.c.

btPlacementLayoutEnemies

void btPlacementLayoutEnemies(Uint16 *unitIds, Sint32 count, Sint32 *xPositions, Sint32 *zPositions)

Lays out count enemies in a column left of the centre, spaced by their size, from a rough estimate of the column's length.

References btSpriteIsSmall(), gmUnitGetStub() and Sint32.

Referenced by btPlacementRelayoutEnemies() and btUnitRefreshPlacement().

Definition at line 231 of file battle_placement.c.

btEnemyGetFreeUnitId

Sint32 btEnemyGetFreeUnitId(void)

Returns the id of the first free enemy unit, or -1 when all six are taken.

References gmUnitGetStub() and Sint32.

Referenced by btAbilityApplyToTarget().

Definition at line 280 of file battle_placement.c.

btPlacementRelayoutEnemies

UNREAD_RESULT btPlacementRelayoutEnemies(void)

Lays the enemies out again and moves each one's battle object anchor to its new place.

References btObjectGet(), btPlacementLayoutEnemies() and Sint32.

Referenced by btAbilityApplyToTarget().

Definition at line 298 of file battle_placement.c.

btUnitRefreshPlacement

void btUnitRefreshPlacement(void)

Places every unit at the start of a battle and creates its battle object at its spot.

References BattlePlacementSpots, btObjectGet(), btObjectMake(), btPartyPrepareMembers(), btPlacementLayoutEnemies() and Sint32.

Referenced by btRun().

Definition at line 330 of file battle_placement.c.

btPlacementContainsId

Bool btPlacementContainsId(Sint16 *list, Sint32 place)

Returns 1 if the unit at place is in list.

References Sint32.

Referenced by btObjectSpawnObjectsForList().

Definition at line 389 of file battle_placement.c.