1#ifndef ALCHEMY_BATTLE_UNIT_H
2#define ALCHEMY_BATTLE_UNIT_H
46#define ABILITY_RANGE_ALL 255
52#define ABILITY_KIND_MASK 15
355#define Unit_UpdateGauges(unit) \
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; \
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.
@ ABILITY_KIND_PP_DAMAGE
Crazy Voice: the target loses PP.
@ ABILITY_KIND_DAMAGE
HP damage from the power (Psynergy).
@ ABILITY_KIND_HEAL_PP
Ember, Psy Crystal, Adept Ring.
@ ABILITY_KIND_HEAL_HP
Cure, Fizz, healing items.
@ ABILITY_KIND_EFFECT
damage only if the effect lands
@ ABILITY_KIND_ATTACK
Attack vs Defense, plus the power.
@ ABILITY_KIND_UNLEASHED_DAMAGE
an enemy's. Shown as X unleashes Y!
@ ABILITY_KIND_SUMMON
the summons: damage scaled by distance
@ ABILITY_KIND_ATTACK_MULTIPLIED
that attack times power / 10
Element
The elements, in the order of every table kept per element: a unit's element stats,...
AbilityEffect
BattleAct.effect: what an ability does besides its damage or healing, applied by BattleTargetExec unl...
@ 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.
@ ABILITY_EFFECT_POISON
Taint.
@ 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.
@ ABILITY_EFFECT_ATTACK_UP_2
Impact: two stages.
@ ABILITY_EFFECT_ATTACK_UP
High Impact: one stage.
@ 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.
@ ABILITY_EFFECT_SLEEP
Sleep.
@ ABILITY_EFFECT_CHARM
Charm.
@ ABILITY_EFFECT_RESISTANCE_DOWN_2
Weaken.
@ ABILITY_EFFECT_DEFENSE_UP
Protect.
@ ABILITY_EFFECT_REGENERATE
Regenerate.
@ ABILITY_EFFECT_RESTORE
Restore, Elixir.
@ ABILITY_EFFECT_REVIVE_80
Dew: 80% of max HP.
@ ABILITY_EFFECT_ATTACK_DOWN_2
Dull.
@ ABILITY_EFFECT_DEFENSE_DOWN
Debilitate.
@ ABILITY_EFFECT_HEAL_HP_60
Fizz: 60% of max HP.
@ ABILITY_EFFECT_CRITICAL_1_IN_32
@ ABILITY_EFFECT_RESISTANCE_UP_2
Ward.
@ 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_CRITICAL_1_IN_4
@ ABILITY_EFFECT_RESISTANCE_DOWN
Enfeeble.
@ ABILITY_EFFECT_DEFENSE_UP_2
Guard.
@ ABILITY_EFFECT_AGILITY_DOWN
Vine.
@ ABILITY_EFFECT_DEFEND
Defend, Granite.
@ ABILITY_EFFECT_REVIVE
Revive, Water of Life: full HP.
@ ABILITY_EFFECT_GROUND
Ground: the target's turn lost.
@ ABILITY_EFFECT_DELUSION
Delude.
@ 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.
@ ABILITY_EFFECT_HEAL_PP_7
Ember: 7% of max PP.
@ ABILITY_EFFECT_REFLECT
Reflect.
@ ABILITY_EFFECT_DEADLY_POISON
Poison.
@ ABILITY_EFFECT_PSY_LEECH
Psy Leech.
@ ABILITY_EFFECT_CURE_POISON
Cure Poison, Antidote.
@ ABILITY_EFFECT_AGILITY_UP
Zephyr.
@ ABILITY_EFFECT_TRIPLE_BLOW_1_IN_8
@ ABILITY_EFFECT_DEFENSE_DOWN_2
Impair.
@ ABILITY_EFFECT_FLEE
Flee.
@ ABILITY_EFFECT_ACT_TWICE
Kite.
BattleActionUse
BattleAct.flags: where an ability can be used.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
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)
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 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.
s16 resistance
Elemental resistance to it.
s16 power
Elemental power in the element.
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...
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 ...
u16 unk02
Not named by any TBS code.
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.