src/battle/battle_placement.c
Battle objects made and placed on the battlefield. More…
Included by battle.c.
Macros
| Name | Description | |
|---|---|---|
#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. |
#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. |
#define | ENEMY_COLUMN_X (-80) | The enemies' column, in pixels from the battlefield's centre, and the nearer place the Kraken, the Fusion Dragon and the Serpent take. |
#define | ENEMY_COLUMN_NEAR_X (-50) | |
#define | ENEMY_SPACING_LARGE 38 | Pixels of the column a large enemy, a small one and an empty place take. |
#define | ENEMY_SPACING_SMALL 27 | |
#define | ENEMY_SPACING_EMPTY 25 | |
#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. |
Functions
| Name | Description | |
|---|---|---|
void | btObjectReset (BATTLE_OBJECT *battleObject, Sint32 keep) | Resets a battle object, making its actor when it has none: nine tenths size, the anchors at the centre unless keep is set, no sprite, animation, shadow or status, turned half a turn, borrowed, then the empty script. |
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. |
void | btPlacementGetStepPair (Sint32 partyPlace, Sint32 *x, Sint32 *y) | Unused: reads the battlefield position of a party place. |
void | btPlacementLayoutEnemies (Uint16 *actorIds, 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. |
Sint32 | btEnemyGetFreeUnitId (void) | Returns the id of the first free enemy unit, or -1 when all six are taken. |
void | btPlacementRelayoutEnemies (void) | Lays the enemies out again and moves each one's battle object anchor to its new place, skipping the removed places before the first enemy and laying out up to the last one still there. |
void | btUnitRefreshPlacement (void) | Places every unit at the start of a battle and creates its battle object at its spot, the reserve party members too. |
Bool | btPlacementContainsId (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() and btObjectReset().
Definition at line 5 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 344 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, the Fusion Dragon and the Serpent take.
Referenced by btPlacementLayoutEnemies().
Definition at line 348 of file battle_placement.c.
ENEMY_COLUMN_NEAR_X
#define ENEMY_COLUMN_NEAR_X (-50)
Referenced by btPlacementLayoutEnemies().
Definition at line 349 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 351 of file battle_placement.c.
ENEMY_SPACING_SMALL
#define ENEMY_SPACING_SMALL 27
Referenced by btPlacementLayoutEnemies().
Definition at line 352 of file battle_placement.c.
ENEMY_SPACING_EMPTY
#define ENEMY_SPACING_EMPTY 25
Referenced by btPlacementLayoutEnemies().
Definition at line 353 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 356 of file battle_placement.c.
Functions in detail
btObjectReset
void btObjectReset(BATTLE_OBJECT *battleObject, Sint32 keep)
Resets a battle object, making its actor when it has none: nine tenths size, the anchors at the centre unless keep is set, no sprite, animation, shadow or status, turned half a turn, borrowed, then the empty script.
References BattleObjectEmptyScript, fdActorCreateStub(), fdActorStartScriptStub(), Sint32 and syAtan().
Referenced by btMotionCallBeast().
Definition at line 10 of file battle_placement.c.
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(), gmUnitGet(), Sint32 and syAtan().
Referenced by btAbilityApplyToTarget(), btChangeEnemyForm() and btUnitRefreshPlacement().
Definition at line 51 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 335 of file battle_placement.c.
btPlacementLayoutEnemies
void btPlacementLayoutEnemies(Uint16 *actorIds, 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(), gmUnitGet() and Sint32.
Referenced by btPlacementRelayoutEnemies() and btUnitRefreshPlacement().
Definition at line 360 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 gmUnitGet() and Sint32.
Referenced by btAbilityApplyToTarget().
Definition at line 416 of file battle_placement.c.
btPlacementRelayoutEnemies
void btPlacementRelayoutEnemies(void)
Lays the enemies out again and moves each one's battle object anchor to its new place, skipping the removed places before the first enemy and laying out up to the last one still there.
References btObjectGet(), btPlacementLayoutEnemies() and Sint32.
Referenced by btAbilityApplyToTarget(), btChangeEnemyForm() and btStagingDispatchAction().
Definition at line 435 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, the reserve party members too.
References BattlePlacementSpots, btObjectGet(), btObjectMake(), btPartyPrepareMembers(), btPartyPrepareReserveOwners(), btPlacementLayoutEnemies() and Sint32.
Referenced by btRun().
Definition at line 480 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 539 of file battle_placement.c.