Alchemy
Loading...
Searching...
No Matches

battle_session.h

Go to the documentation of this file.
1#ifndef ALCHEMY_BATTLE_SESSION_H
2#define ALCHEMY_BATTLE_SESSION_H
3
4/// @file
5/// A battle's objects and sprites, each unit's command and action record, and
6/// the spoils.
7
8#include "types.h"
9#include "static_assert.h"
10
11struct MotionObject;
12struct SpriteEntry;
13
14/// A unit's place on the battlefield: its sprite object, resources and
15/// animations, its anchor spot and scale, and the conditions it shows.
16struct BattleObj {
17 struct MotionObject *object; ///< NULL once released
18 u16 resource; ///< the unit's sprite
19 u16 overlay; ///< a second sprite drawn over it, the weapon; 0 for none
20 u16 animation; ///< the status icon's animation shown; 0 for none
21 u16 effect; ///< an effect sprite drawn with the unit
22 s32 anchorX; ///< 16.16 fixed-point pixels
23 s32 anchorZ; ///< 16.16 fixed-point pixels
24 s32 palette; ///< the unit sprite's palette
25 s32 scale; ///< 16.16 fixed point, 0x10000 full size
26 u16 activeConditions; ///< a bit per status with an icon (ICON_)
27 u8 selectedCondition; ///< the status whose icon is shown
28 s8 cycleTimer; ///< frames until the next status icon
29 struct SpriteEntry *animationEntry; ///< the status icon's sprite, or NULL
30 struct SpriteEntry *effectEntry; ///< the effect sprite, or NULL
31 /// Set by BattleObj_MarkForRelease: the object is released with the
32 /// others by BattleMotion_DestroyAllSlotObjects.
34 s16 fading; ///< set while a fallen enemy's picture is being removed
35};
36
37/// BattleActionRecord.command and BattlePlan's copy of it: what a unit does
38/// on its turn.
44 CMD_ABILITY = 4, ///< an enemy's ability
47 CMD_DEFEND2 = 7, ///< an enemy's Total Defense (effect 47)
48 CMD_NONE = 8, ///< nothing this turn
50};
51
52/// A unit's chosen action for the turn: its command, the command's parameter,
53/// its target and range, and its priority in the turn order.
56 u16 slot; ///< in a link battle, unitId as the opponent knows it
57 u16 priority; ///< from the unit's Agility; higher acts first
58 s16 command; ///< enum BattleCommand
59 s16 parameter; ///< an ability id, or CMD_ITEM's inventory index (-1 gone)
60 s16 target; ///< the aimed unit's id
61 s16 range; ///< the action's range
62 s16 unk0e; ///< not named by TBS code
63};
64
65/// A battle's spoils so far: coins, experience, enemies defeated and up to
66/// four items.
70 s32 defeated; ///< enemies defeated
72};
73
74STATIC_ASSERT(sizeof(struct BattleObj) == 0x2c);
75STATIC_ASSERT(offsetof(struct BattleObj, anchorX) == 0x0c);
76STATIC_ASSERT(offsetof(struct BattleObj, activeConditions) == 0x1c);
77STATIC_ASSERT(offsetof(struct BattleObj, cycleTimer) == 0x1f);
78STATIC_ASSERT(offsetof(struct BattleObj, active) == 0x28);
79
80STATIC_ASSERT(sizeof(struct BattleActionRecord) == 0x10);
81STATIC_ASSERT(offsetof(struct BattleActionRecord, priority) == 0x04);
82STATIC_ASSERT(offsetof(struct BattleActionRecord, command) == 0x06);
83STATIC_ASSERT(offsetof(struct BattleActionRecord, parameter) == 0x08);
84STATIC_ASSERT(offsetof(struct BattleActionRecord, target) == 0x0a);
85STATIC_ASSERT(sizeof(struct BattleSpoils) == 0x14);
86
87#endif
BattleCommand
BattleActionRecord.command and BattlePlan's copy of it: what a unit does on its turn.
@ CMD_DJINN
@ CMD_ABILITY
an enemy's ability
@ CMD_DEFEND
@ CMD_NONE
nothing this turn
@ CMD_ITEM
@ CMD_PSYNERGY
@ CMD_ATTACK
@ CMD_FLEE
@ CMD_SUMMON
@ CMD_DEFEND2
an enemy's Total Defense (effect 47)
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A unit's chosen action for the turn: its command, the command's parameter, its target and range,...
s16 target
the aimed unit's id
s16 parameter
an ability id, or CMD_ITEM's inventory index (-1 gone)
s16 unk0e
not named by TBS code
u16 slot
in a link battle, unitId as the opponent knows it
s16 command
enum BattleCommand
s16 range
the action's range
u16 priority
from the unit's Agility; higher acts first
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct SpriteEntry * effectEntry
the effect sprite, or NULL
struct MotionObject * object
NULL once released.
u16 animation
the status icon's animation shown; 0 for none
u16 activeConditions
a bit per status with an icon (ICON_)
u8 selectedCondition
the status whose icon is shown
s8 cycleTimer
frames until the next status icon
u16 resource
the unit's sprite
s32 palette
the unit sprite's palette
s16 fading
set while a fallen enemy's picture is being removed
s32 scale
16.16 fixed point, 0x10000 full size
u16 effect
an effect sprite drawn with the unit
s16 active
Set by BattleObj_MarkForRelease: the object is released with the others by BattleMotion_DestroyAllSlo...
struct SpriteEntry * animationEntry
the status icon's sprite, or NULL
s32 anchorZ
16.16 fixed-point pixels
u16 overlay
a second sprite drawn over it, the weapon; 0 for none
s32 anchorX
16.16 fixed-point pixels
A battle's spoils so far: coins, experience, enemies defeated and up to four items.
s32 defeated
enemies defeated
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
A sprite of an animation record, as battle objects set its palette and drawing priority.
Definition motobj.h:68
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed char s8
Definition types.h:10
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11