Alchemy
Loading...
Searching...
No Matches

battle_unit.h

Go to the documentation of this file.
1#ifndef ALCHEMY_BATTLE_UNIT_H
2#define ALCHEMY_BATTLE_UNIT_H
3
4/// @file
5/// BattleUnit, a party member's or enemy's battle state, with the elements,
6/// abilities and actions it uses.
7
8#include "edition.h"
9#include "static_assert.h"
10
11enum {
15};
16
17/// An entry in a unit's action list: the action's id (OWNER_ACTION_ID_MASK)
18/// and marks for an action its class or an equipped item gave.
20 /// bits: 15 from the class | 14 from an equipped item | 13..0 action id.
21 /// Entries with neither mark were taught for good; 0 is empty.
23 u16 unk02; ///< Not named by any TBS code.
24};
25
26/// A unit's elemental power and resistance in one element.
28 s16 power; ///< Elemental power in the element.
29 s16 resistance; ///< Elemental resistance to it.
30};
31
32/// The elements, in the order of every table kept per element: a unit's
33/// element stats, the Djinn and the summons. ELEMENT_NONE marks an ability or
34/// a weapon that has no element.
35enum Element {
42};
43
44/// BattleAct.range of an ability that reaches every unit on the side, each
45/// as if aimed at.
46#define ABILITY_RANGE_ALL 255
47
48/// The low four bits of BattleAct.flags: how BattleTargetExec applies
49/// the ability's power. Kinds 0, 7 and 9 apply none: 0 is no ability, 7 is
50/// Granite, Flash and Kite, 9 the field Psynergy, Defend, Flee and enemies'
51/// commands.
52#define ABILITY_KIND_MASK 15
53
54/// The kinds of ability, by the low four bits of BattleAct.flags. Three kinds
55/// have no enumerator, because BattleTargetExec applies no power for them:
56/// 0 is no ability; 7 is Granite, Flash and Kite, whose effect is all they
57/// do; 9 is the field Psynergy (Move, Catch...), the field-only stat items
58/// (Apple, Power Bread...), Defend, Flee and the enemies' commands (Threaten,
59/// Ally Search...). The targeting check treats kind 9 as a summon: worth it
60/// on a living unit only when the power is nonzero.
62 ABILITY_KIND_HEAL_HP = 1, ///< Cure, Fizz, healing items
63 ABILITY_KIND_EFFECT = 2, ///< damage only if the effect lands
64 ABILITY_KIND_ATTACK = 3, ///< Attack vs Defense, plus the power
65 ABILITY_KIND_ATTACK_MULTIPLIED = 4, ///< that attack times power / 10
66 ABILITY_KIND_DAMAGE = 5, ///< HP damage from the power (Psynergy)
67 ABILITY_KIND_UNLEASHED_DAMAGE = 6, ///< an enemy's. Shown as `X unleashes Y!`
68 ABILITY_KIND_SUMMON = 8, ///< the summons: damage scaled by distance
69 ABILITY_KIND_PP_DAMAGE = 10, ///< Crazy Voice: the target loses PP
70 ABILITY_KIND_HEAL_PP = 11 ///< Ember, Psy Crystal, Adept Ring
71};
72
73/// BattleAct.effect: what an ability does besides its damage or healing,
74/// applied by BattleTargetExec unless noted. Each is named for the abilities
75/// that have it (actions.tsv, with their English names and descriptions).
76/// Sidestep (48) and Crazy Voice (52) have effects no code here reads.
79 ABILITY_EFFECT_CURE_POISON = 3, ///< Cure Poison, Antidote
80 ABILITY_EFFECT_RESTORE = 4, ///< Restore, Elixir
81 ABILITY_EFFECT_REVIVE = 5, ///< Revive, Water of Life: full HP
82 ABILITY_EFFECT_ATTACK_UP_2 = 6, ///< Impact: two stages
83 ABILITY_EFFECT_ATTACK_UP = 7, ///< High Impact: one stage
87 ABILITY_EFFECT_DEFENSE_UP = 11, ///< Protect
89 ABILITY_EFFECT_DEFENSE_DOWN = 13, ///< Debilitate
94 ABILITY_EFFECT_POISON = 18, ///< Taint
96 ABILITY_EFFECT_DELUSION = 20, ///< Delude
97 ABILITY_EFFECT_CONFUSION = 21, ///< Confuse
98 ABILITY_EFFECT_CHARM = 22, ///< Charm
99 ABILITY_EFFECT_STUN = 23, ///< Paralyze
100 ABILITY_EFFECT_SLEEP = 24, ///< Sleep
101 ABILITY_EFFECT_SEAL = 25, ///< Bind: Psynergy sealed
102 ABILITY_EFFECT_HAUNT = 26, ///< Haunt
104 ABILITY_EFFECT_CURSE = 28, ///< Curse: the Grim Reaper's countdown
105 ABILITY_EFFECT_REGENERATE = 29, ///< Regenerate
106 ABILITY_EFFECT_REFLECT = 30, ///< Reflect
107 ABILITY_EFFECT_DRAIN_HP = 31, ///< Drain
108 ABILITY_EFFECT_DRAIN_PP = 32, ///< Psy Drain
109 ABILITY_EFFECT_BREAK = 33, ///< Break: raised stats undone
110 ABILITY_EFFECT_LEAVE_ONE_HP = 34, ///< Severe Blow, Thrash
112 /// A 1 in 64 to 1 in 4 chance of an ability's critical hit, rolled by
113 /// BattleCommand_BuildPlan.
119 /// A chance of a double or triple blow, rolled by BattleCommand_BuildPlan.
121 ABILITY_EFFECT_DOUBLE_BLOW_1_IN_4 = 42, ///< Double Fang, Twin Beaks
123 ABILITY_EFFECT_TRIPLE_BLOW_1_IN_4 = 44, ///< Swift Strike
124 ABILITY_EFFECT_THREATEN = 45, ///< Contain, Threaten, Tremble
125 ABILITY_EFFECT_DEFEND = 46, ///< Defend, Granite
126 ABILITY_EFFECT_TOTAL_DEFENSE = 47, ///< Total Defense, Flash
127 ABILITY_EFFECT_FLEE = 49, ///< Flee
128 ABILITY_EFFECT_CALL_ALLY = 50, ///< Ally Search, Speed Surge
129 ABILITY_EFFECT_CALL_HELP = 51, ///< Search for Help
130 ABILITY_EFFECT_GROUND = 53, ///< Ground: the target's turn lost
131 ABILITY_EFFECT_CHALLENGE = 54, ///< no ability has it
132 ABILITY_EFFECT_SELF_DESTRUCT = 55, ///< Dynamite, Mortal Blow
134 ABILITY_EFFECT_REVIVE_80 = 57, ///< Dew: 80% of max HP
138 ABILITY_EFFECT_HEAL_HP_60 = 61, ///< Fizz: 60% of max HP
139 ABILITY_EFFECT_HEAL_HP_30 = 62, ///< Spritz: 30%
140 ABILITY_EFFECT_HEAL_PP_7 = 63, ///< Ember: 7% of max PP
141 ABILITY_EFFECT_CURE_ALL = 64, ///< Tonic
142 ABILITY_EFFECT_DOUBLE_BLOW_60 = 65, ///< Gust, Rapid Smash: 153 in 256
145 ABILITY_EFFECT_TRIPLE_BLOW_60 = 68, ///< Sonic Smash
146 ABILITY_EFFECT_PSY_LEECH = 69 ///< Psy Leech
147};
148
149/// An ability's definition, a row of gBattleAction_DefinitionTable: its
150/// targeting, kind, element, effect, range, PP cost and power.
151struct BattleAct {
152 u8 targetMode; ///< TARGET_MODE_NONE, _FOES, _ALLIES or _SELF
153 /// bits: 7 usable in battle | 6 usable in the field | 5..4 clear in every
154 /// row | 3..0 kind (ABILITY_KIND_MASK, enum AbilityKind).
156 u8 element; ///< enum Element
157 u8 effect; ///< enum AbilityEffect
158 /// [0] the icon the menus draw; [1] to [3] are 0 in every row.
160 u8 range; ///< the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
161 u8 ppCost; ///< PP the ability costs
162 u16 power; ///< what the kind applies, 0 for none
163 /// The field Psynergy the ability works as, 1 (Move) to 16 (Avoid); 0 for
164 /// none. The field effects branch on it, and the status screen counts it as
165 /// usable in the field.
167 u8 unk0d[3]; ///< 0 in every row.
168};
169
170/// BattleAct.flags: where an ability can be used.
172 ACTION_USABLE_IN_FIELD = 0x40, ///< can be used outside battle
173 ACTION_USABLE_IN_BATTLE = 0x80 ///< can be used in battle; else greyed there
174};
175
176/// A unit in battle: a party member's or an enemy's stats, Psynergy, items,
177/// Djinn and ailments.
179 /// The name, one byte a character, ending in 0. An enemy's is its message
180 /// name cut to 14 characters, with the suffix letter BattleUnitSet is given
181 /// (a digit in Japanese); name[14] is always 0.
182 u8 name[0x0f];
183 u8 level; ///< 1 to 99 for a character
184 s16 baseHp; ///< before equipment, Djinn and class (UnitCalc)
185 s16 basePp; ///< before equipment, Djinn and class (UnitCalc)
186 s16 hpGauge; ///< hp / maxHp in 0..0x4000; 1 while any HP remains
187 s16 ppGauge; ///< pp / maxPp in 0..0x4000; 1 while any PP remains
188 u16 baseAttack; ///< before equipment, Djinn, class and stages
189 u16 baseDefense; ///< before equipment, Djinn, class and stages
190 u16 baseAgility; ///< before equipment, Djinn, class and stages
191 u8 baseLuck; ///< before equipment, Djinn and class
192 /// Actions a round before equipment: the low four bits are read. An enemy's
193 /// comes from its definition's turns; a level up sets a character's to 1.
195 u8 baseHpRegen; ///< HP regained each turn before equipment; 0 for a character
196 u8 basePpRegen; ///< PP regained each turn before equipment and lighthouses
197 u8 unk022[2]; ///< Not named by any TBS code.
198 /// Power and resistance before equipment and stages: an enemy's from its
199 /// element preset, a character's from its element levels
200 /// (Unit_CalcBaseElements).
202 s16 maxHp; ///< 0 to 1999 for a character, 9999 for an enemy (UnitCalc)
203 s16 maxPp; ///< 0 to 1999 for a character, 9999 for an enemy (UnitCalc)
204 s16 hp; ///< current HP, 0 when downed
205 s16 pp; ///< current PP
206 u16 atk; ///< Attack, 0 to 999 (UnitCalc)
207 u16 def; ///< Defense, 0 to 999 (UnitCalc)
208 u16 agi; ///< Agility, 0 to 999: the order of the round's actions
209 u8 luck; ///< 0 to 99 (UnitCalc)
210 /// Actions each round, 0 to 2: baseActionCount, one more while ready, and
211 /// the equipment's extra turns (UnitCalc). Each gives the unit a place in
212 /// the round's queue.
214 u8 hpRegen; ///< HP regained at each turn's end (UnitCalc)
215 /// PP regained at each turn's end, 0 to 200 (UnitCalc): 4 more once the
216 /// lighthouse of the character's element is lit.
218 u8 unk046[2]; ///< Not named by any TBS code.
219 /// Power and resistance in each element, 0 to 200, after equipment,
220 /// element levels and Resistance stages (UnitCalc).
222 /// The action list: Psynergy taught for good, then the class's and the
223 /// equipment's (Unit_RefreshPsynergy). An empty entry is 0.
225 /// Items held, one entry each: bits 15..11 quantity | 10 broken |
226 /// 9 equipped | 8..0 item id (INVENTORY_*). An empty entry is 0.
228 u8 unk0f6[2]; ///< Not named by any TBS code.
229 /// The Djinn held, one bit per Djinni (by its index) in each element's word.
231 /// The Djinn set, one bit per Djinni; only these add their stat bonuses.
233 u8 djinnOwnedCounts[4]; ///< the Djinn held in each element, at most 10
234 u8 djinnActiveCounts[4]; ///< the Djinn set in each element; the class's
235 ///< element levels are read from these
236 /// Copied from the enemy's definition, where it is 0 in every row. During
237 /// a battle the enemy's action choice keeps its place in its action list
238 /// here (BattleCommand_SelectAutomatic).
240 u32 experience; ///< a character's experience points
241 /// Who the unit is: a character's id (ISAAC to JENNA, below 8) or an
242 /// enemy's id (BattleUnitSet). The class tables are indexed by classIndex.
244 /// The character's class, worked out from its Djinn (Unit_UpdateClass); 0
245 /// marks an enemy, and code throughout tests it to tell the two apart.
247 /// BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2).
248 /// Enemies 158 to 171 are put on side 2 (BattleUnitSet).
250 /// 0, GUARD_DEFEND (1, half the damage) or GUARD_TOTAL_DEFENSE (2, a
251 /// tenth); set by Defend and Granite, cleared each round.
253 /// A summon's boost to each element: the Djinn of that element the summon
254 /// spent, adding (n * n + n) * 5 power (UnitCalc). Cleared at the battle's
255 /// start and by Break.
257 /// The curse. bits: 3 item effect 25 (UnitCalc clears it again with bit 0)
258 /// | 2 keeps bit 0 | 1 cursed item equipped | 0 bound. UnitCalc rebuilds
259 /// bits 1 and 0 from the equipment. A bound unit loses one action in four,
260 /// except Defend (BattleCommand_BuildPlan); any bit set shows the curse in
261 /// the status screens and lets the sanctum remove it.
263 s8 poison; ///< 1 poisoned, 2 deadly poison
264 /// Each stat change: the turns it has left, and its stage (UnitCalc: an
265 /// eighth of Attack, Defense or Agility, or 20 Resistance, a stage).
266 /// Stages run -4 to 4 and last 7 turns.
267 ///@{
274 ///@}
275 /// Delusion to sleep: the turns each status has left, 7 when it lands; each
276 /// may end sooner at the end of a turn. Sleep, confusion, charm and stun
277 /// cost the unit its actions.
278 ///@{
284 ///@}
285 /// bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns
286 /// (7 when cast). Psynergy is sealed while any bit is set.
288 u8 refrain; ///< Regenerate's turns left, 7 when cast
289 s8 reflect; ///< Reflect's turns left, 7 when cast
290 u8 haunt; ///< set while an evil spirit grips the unit
291 /// The Grim Reaper's countdown: 7 when cursed, down one at each turn's
292 /// end; at 0 the unit falls.
294 /// The totals of equipment effects 23 (unleash chance) and 24 that UnitCalc
295 /// sums; TBS never reads them back
297 /// Kite's extra action: 2 when cast, down one at each turn's end; while
298 /// nonzero UnitCalc gives the unit one more action a round.
300 u8 immobile; ///< set by Ground: the next action is lost
301 u8 agilityTurns; ///< the Agility change's turns left, 5 when cast
302 /// The Agility stage: -4 (Vine) to 8 (Zephyr, twice the Agility).
304 /// Set by the challenge effect: an enemy with it never chooses to flee.
306 u8 unk149; ///< Not named by any TBS code.
307 u16 enemyId; ///< Not named by any TBS code; TLA reads it as the unit's id.
308};
309
311STATIC_ASSERT(offsetof(struct BattleAct, effect) == 0x03);
312STATIC_ASSERT(offsetof(struct BattleAct, power) == 0x0a);
313STATIC_ASSERT(offsetof(struct BattleAct, type0c) == 0x0c);
314
315STATIC_ASSERT(sizeof(struct OwnerActionSlot) == 4);
318STATIC_ASSERT(offsetof(struct BattleUnit, baseHp) == 0x10);
319STATIC_ASSERT(offsetof(struct BattleUnit, baseAttack) == 0x18);
320STATIC_ASSERT(offsetof(struct BattleUnit, actionSlots) == 0x58);
321STATIC_ASSERT(offsetof(struct BattleUnit, djinnAvailable) == 0xf8);
322STATIC_ASSERT(offsetof(struct BattleUnit, djinnActive) == 0x108);
323STATIC_ASSERT(offsetof(struct BattleUnit, rewards) == 0x120);
324STATIC_ASSERT(offsetof(struct BattleUnit, hp) == 0x038);
325STATIC_ASSERT(offsetof(struct BattleUnit, baseElement) == 0x024);
326STATIC_ASSERT(offsetof(struct BattleUnit, level) == 0x00f);
327STATIC_ASSERT(offsetof(struct BattleUnit, element) == 0x048);
328STATIC_ASSERT(offsetof(struct BattleUnit, ready) == 0x144);
329STATIC_ASSERT(offsetof(struct BattleUnit, inventory) == 0x0d8);
330STATIC_ASSERT(offsetof(struct BattleUnit, djinnOwnedCounts) == 0x118);
331STATIC_ASSERT(offsetof(struct BattleUnit, djinnActiveCounts) == 0x11c);
332STATIC_ASSERT(offsetof(struct BattleUnit, guardLevel) == 0x12b);
333STATIC_ASSERT(offsetof(struct BattleUnit, charm) == 0x13a);
334STATIC_ASSERT(offsetof(struct BattleUnit, haunt) == 0x140);
335
336STATIC_ASSERT(offsetof(struct BattleUnit, enemyId) == 0x14a);
337
338/// Clamps a gauge ratio to 0..0x4000, where 0x4000 means full.
339static __inline__ s32 Vitals_Clamp(s32 ratio) {
340 s32 clamped;
341
342 if (ratio > 0x4000)
343 clamped = 0x4000;
344 else if (ratio < 0)
345 clamped = 0;
346 else
347 clamped = ratio;
348 return clamped;
349}
350
351/// Recalculates HP and PP gauges, keeping at least one when any points remain.
352// A statement macro, written do { } while (0): every site matches through that
353// shape. Written out at each site, or as an inline function, the gauge loads
354// are scheduled across the store before them.
355#define Unit_UpdateGauges(unit) \
356 do { \
357 (unit)->hpGauge = Vitals_Clamp(((unit)->hp << 14) / (unit)->maxHp); \
358 if ((unit)->hpGauge == 0 && (unit)->hp != 0) \
359 (unit)->hpGauge = 1; \
360 (unit)->ppGauge = Vitals_Clamp(((unit)->pp << 14) / (unit)->maxPp); \
361 if ((unit)->ppGauge == 0 && (unit)->pp != 0) \
362 (unit)->ppGauge = 1; \
363 } while (0)
364
365#endif
static __inline__ s32 Vitals_Clamp(s32 ratio)
Clamps a gauge ratio to 0..0x4000, where 0x4000 means full.
AbilityKind
The kinds of ability, by the low four bits of BattleAct.flags.
Definition battle_unit.h:61
@ ABILITY_KIND_PP_DAMAGE
Crazy Voice: the target loses PP.
Definition battle_unit.h:69
@ ABILITY_KIND_DAMAGE
HP damage from the power (Psynergy).
Definition battle_unit.h:66
@ ABILITY_KIND_HEAL_PP
Ember, Psy Crystal, Adept Ring.
Definition battle_unit.h:70
@ ABILITY_KIND_HEAL_HP
Cure, Fizz, healing items.
Definition battle_unit.h:62
@ ABILITY_KIND_EFFECT
damage only if the effect lands
Definition battle_unit.h:63
@ ABILITY_KIND_ATTACK
Attack vs Defense, plus the power.
Definition battle_unit.h:64
@ ABILITY_KIND_UNLEASHED_DAMAGE
an enemy's. Shown as X unleashes Y!
Definition battle_unit.h:67
@ ABILITY_KIND_SUMMON
the summons: damage scaled by distance
Definition battle_unit.h:68
@ ABILITY_KIND_ATTACK_MULTIPLIED
that attack times power / 10
Definition battle_unit.h:65
Element
The elements, in the order of every table kept per element: a unit's element stats,...
Definition battle_unit.h:35
@ NUM_ELEMENTS
Definition battle_unit.h:41
@ ELEMENT_MARS
Definition battle_unit.h:38
@ ELEMENT_MERCURY
Definition battle_unit.h:37
@ ELEMENT_VENUS
Definition battle_unit.h:36
@ ELEMENT_JUPITER
Definition battle_unit.h:39
@ ELEMENT_NONE
Definition battle_unit.h:40
AbilityEffect
BattleAct.effect: what an ability does besides its damage or healing, applied by BattleTargetExec unl...
Definition battle_unit.h:77
@ ABILITY_EFFECT_CHALLENGE
no ability has it
@ ABILITY_EFFECT_LEAVE_ONE_HP
Severe Blow, Thrash.
@ ABILITY_EFFECT_TRIPLE_BLOW_60
Sonic Smash.
@ ABILITY_EFFECT_SEAL_2_TURNS
Luff.
@ ABILITY_EFFECT_HAUNT
Haunt.
@ ABILITY_EFFECT_DOUBLE_BLOW_1_IN_4
Double Fang, Twin Beaks.
@ ABILITY_EFFECT_INSTANT_DEATH
Condemn.
@ ABILITY_EFFECT_DRAIN_HALF_HP
Sap.
@ ABILITY_EFFECT_ATTACK_DOWN
Blunt.
Definition battle_unit.h:85
@ ABILITY_EFFECT_POISON
Taint.
Definition battle_unit.h:94
@ ABILITY_EFFECT_BREAK
Break: raised stats undone.
@ ABILITY_EFFECT_CRITICAL_1_IN_16
@ ABILITY_EFFECT_HALVE_DEFENSE
Torch.
@ ABILITY_EFFECT_SELF_DESTRUCT
Dynamite, Mortal Blow.
@ ABILITY_EFFECT_HEAL_HP_30
Spritz: 30%.
@ ABILITY_EFFECT_SEAL
Bind: Psynergy sealed.
@ ABILITY_EFFECT_CURE_ALL
Tonic.
@ ABILITY_EFFECT_RESISTANCE_UP
Resist.
Definition battle_unit.h:91
@ ABILITY_EFFECT_ATTACK_UP_2
Impact: two stages.
Definition battle_unit.h:82
@ ABILITY_EFFECT_ATTACK_UP
High Impact: one stage.
Definition battle_unit.h:83
@ ABILITY_EFFECT_CRITICAL_1_IN_64
A 1 in 64 to 1 in 4 chance of an ability's critical hit, rolled by BattleCommand_BuildPlan.
@ ABILITY_EFFECT_TRIPLE_BLOW_1_IN_4
Swift Strike.
@ ABILITY_EFFECT_THREATEN
Contain, Threaten, Tremble.
@ ABILITY_EFFECT_TOTAL_DEFENSE
Total Defense, Flash.
@ ABILITY_EFFECT_CRITICAL_1_IN_8
@ ABILITY_EFFECT_REVIVE_HALF
Quartz.
@ ABILITY_EFFECT_DRAIN_HP
Drain.
@ ABILITY_EFFECT_STUN
Paralyze.
Definition battle_unit.h:99
@ ABILITY_EFFECT_SLEEP
Sleep.
@ ABILITY_EFFECT_CHARM
Charm.
Definition battle_unit.h:98
@ ABILITY_EFFECT_RESISTANCE_DOWN_2
Weaken.
Definition battle_unit.h:92
@ ABILITY_EFFECT_DEFENSE_UP
Protect.
Definition battle_unit.h:87
@ ABILITY_EFFECT_REGENERATE
Regenerate.
@ ABILITY_EFFECT_RESTORE
Restore, Elixir.
Definition battle_unit.h:80
@ ABILITY_EFFECT_REVIVE_80
Dew: 80% of max HP.
@ ABILITY_EFFECT_ATTACK_DOWN_2
Dull.
Definition battle_unit.h:84
@ ABILITY_EFFECT_DEFENSE_DOWN
Debilitate.
Definition battle_unit.h:89
@ ABILITY_EFFECT_HEAL_HP_60
Fizz: 60% of max HP.
@ ABILITY_EFFECT_CRITICAL_1_IN_32
@ ABILITY_EFFECT_RESISTANCE_UP_2
Ward.
Definition battle_unit.h:90
@ ABILITY_EFFECT_CALL_ALLY
Ally Search, Speed Surge.
@ ABILITY_EFFECT_DOUBLE_BLOW_1_IN_8
A chance of a double or triple blow, rolled by BattleCommand_BuildPlan.
@ ABILITY_EFFECT_CURSE
Curse: the Grim Reaper's countdown.
@ ABILITY_EFFECT_NONE
Definition battle_unit.h:78
@ ABILITY_EFFECT_CRITICAL_1_IN_4
@ ABILITY_EFFECT_RESISTANCE_DOWN
Enfeeble.
Definition battle_unit.h:93
@ ABILITY_EFFECT_DEFENSE_UP_2
Guard.
Definition battle_unit.h:86
@ ABILITY_EFFECT_AGILITY_DOWN
Vine.
@ ABILITY_EFFECT_DEFEND
Defend, Granite.
@ ABILITY_EFFECT_REVIVE
Revive, Water of Life: full HP.
Definition battle_unit.h:81
@ ABILITY_EFFECT_GROUND
Ground: the target's turn lost.
@ ABILITY_EFFECT_DELUSION
Delude.
Definition battle_unit.h:96
@ ABILITY_EFFECT_CALL_HELP
Search for Help.
@ ABILITY_EFFECT_DRAIN_PP
Psy Drain.
@ ABILITY_EFFECT_DOUBLE_BLOW_60
Gust, Rapid Smash: 153 in 256.
@ ABILITY_EFFECT_CONFUSION
Confuse.
Definition battle_unit.h:97
@ ABILITY_EFFECT_HEAL_PP_7
Ember: 7% of max PP.
@ ABILITY_EFFECT_REFLECT
Reflect.
@ ABILITY_EFFECT_DEADLY_POISON
Poison.
Definition battle_unit.h:95
@ ABILITY_EFFECT_PSY_LEECH
Psy Leech.
@ ABILITY_EFFECT_CURE_POISON
Cure Poison, Antidote.
Definition battle_unit.h:79
@ ABILITY_EFFECT_AGILITY_UP
Zephyr.
@ ABILITY_EFFECT_TRIPLE_BLOW_1_IN_8
@ ABILITY_EFFECT_DEFENSE_DOWN_2
Impair.
Definition battle_unit.h:88
@ ABILITY_EFFECT_FLEE
Flee.
@ ABILITY_EFFECT_ACT_TWICE
Kite.
@ BATTLE_UNIT_SIZE
Definition battle_unit.h:13
@ BATTLE_ACTION_SIZE
Definition battle_unit.h:12
@ OWNER_ACTION_ID_MASK
Definition battle_unit.h:14
BattleActionUse
BattleAct.flags: where an ability can be used.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
#define ACTION_USABLE_IN_FIELD
BattleAct.flags: where an ability or item can be used, as the Psynergy list says ("Usable in the fiel...
#define ACTION_USABLE_IN_BATTLE
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
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 unk0d[3]
0 in every row.
u8 type0c
The field Psynergy the ability works as, 1 (Move) to 16 (Avoid); 0 for none.
u8 ppCost
PP the ability costs.
u8 effect
enum AbilityEffect
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
u8 unk04[4]
[0] the icon the menus draw; [1] to [3] are 0 in every row.
u8 element
enum Element
u8 targetMode
TARGET_MODE_NONE, _FOES, _ALLIES or _SELF.
u8 flags
bits: 7 usable in battle | 6 usable in the field | 5..4 clear in every row | 3..0 kind (ABILITY_KIND_...
u16 power
what the kind applies, 0 for none
A unit's elemental power and resistance in one element.
Definition battle_unit.h:27
s16 resistance
Elemental resistance to it.
Definition battle_unit.h:29
s16 power
Elemental power in the element.
Definition battle_unit.h:28
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u16 enemyId
Not named by any TBS code; TLA reads it as the unit's id.
u8 agilityTurns
the Agility change's turns left, 5 when cast
u8 luck
0 to 99 (UnitCalc)
u16 baseDefense
before equipment, Djinn, class and stages
u8 immobile
set by Ground: the next action is lost
u16 baseAttack
before equipment, Djinn, class and stages
u16 baseAgility
before equipment, Djinn, class and stages
u8 hpRegen
HP regained at each turn's end (UnitCalc).
s8 elementLevels[4]
A summon's boost to each element: the Djinn of that element the summon spent, adding (n * n + n) * 5 ...
u32 rewards
Copied from the enemy's definition, where it is 0 in every row.
u32 djinnActive[4]
The Djinn set, one bit per Djinni; only these add their stat bonuses.
u8 djinnOwnedCounts[4]
the Djinn held in each element, at most 10
u8 grimReaper
The Grim Reaper's countdown: 7 when cursed, down one at each turn's end; at 0 the unit falls.
u8 psySeal
bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast).
u8 ppRegen
PP regained at each turn's end, 0 to 200 (UnitCalc): 4 more once the lighthouse of the character's el...
u8 side
BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2).
s16 maxPp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
s16 hpGauge
hp / maxHp in 0..0x4000; 1 while any HP remains
s8 poison
1 poisoned, 2 deadly poison
u8 unk149
Not named by any TBS code.
u8 djinnActiveCounts[4]
the Djinn set in each element; the class's element levels are read from these
u8 name[0x0f]
The name, one byte a character, ending in 0.
u8 haunt
set while an evil spirit grips the unit
s16 hp
current HP, 0 when downed
s16 ppGauge
pp / maxPp in 0..0x4000; 1 while any PP remains
struct BattleElementStats element[4]
Power and resistance in each element, 0 to 200, after equipment, element levels and Resistance stages...
s16 pp
current PP
s8 restraint
The curse.
u8 baseActionCount
Actions a round before equipment: the low four bits are read.
u8 baseHpRegen
HP regained each turn before equipment; 0 for a character.
struct OwnerActionSlot actionSlots[32]
The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy...
u8 baseLuck
before equipment, Djinn and class
s8 challenge
Set by the challenge effect: an enemy with it never chooses to flee.
u8 unk022[2]
Not named by any TBS code.
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
struct BattleElementStats baseElement[4]
Power and resistance before equipment and stages: an enemy's from its element preset,...
s16 basePp
before equipment, Djinn and class (UnitCalc)
s16 maxHp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
u32 experience
a character's experience points
u8 unk046[2]
Not named by any TBS code.
s8 agilityStage
The Agility stage: -4 (Vine) to 8 (Zephyr, twice the Agility).
u8 basePpRegen
PP regained each turn before equipment and lighthouses.
u8 classIndex
The character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy,...
u8 refrain
Regenerate's turns left, 7 when cast.
s16 baseHp
before equipment, Djinn and class (UnitCalc)
s8 reflect
Reflect's turns left, 7 when cast.
u16 atk
Attack, 0 to 999 (UnitCalc).
u8 equipBonus[2]
The totals of equipment effects 23 (unleash chance) and 24 that UnitCalc sums; TBS never reads them b...
s8 guardLevel
0, GUARD_DEFEND (1, half the damage) or GUARD_TOTAL_DEFENSE (2, a tenth); set by Defend and Granite,...
u8 level
1 to 99 for a character
u8 attackTurns
Each stat change: the turns it has left, and its stage (UnitCalc: an eighth of Attack,...
u16 agi
Agility, 0 to 999: the order of the round's actions.
u16 def
Defense, 0 to 999 (UnitCalc).
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
u8 delusion
Delusion to sleep: the turns each status has left, 7 when it lands; each may end sooner at the end of...
u8 ready
Kite's extra action: 2 when cast, down one at each turn's end; while nonzero UnitCalc gives the unit ...
u8 actionEntryCount
Actions each round, 0 to 2: baseActionCount, one more while ready, and the equipment's extra turns (U...
u32 djinnAvailable[4]
The Djinn held, one bit per Djinni (by its index) in each element's word.
u8 unk0f6[2]
Not named by any TBS code.
An entry in a unit's action list: the action's id (OWNER_ACTION_ID_MASK) and marks for an action its ...
Definition battle_unit.h:19
u16 unk02
Not named by any TBS code.
Definition battle_unit.h:23
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.
Definition battle_unit.h:22
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
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