Alchemy
Loading...
Searching...
No Matches

character.h

Go to the documentation of this file.
1#ifndef ALCHEMY_CHARACTER_H
2#define ALCHEMY_CHARACTER_H
3
4/// @file
5/// The definitions of characters, classes, Djinn and enemies, and a level up's
6/// result.
7
8#include "unit/game/game.h"
9#include "types.h"
10#include "owner_value.h"
11#include "static_assert.h"
12
13struct BattleUnit;
14
15/// A character's definition: the growth curves of its stats, its element
16/// bonus, starting level and starting equipment.
18 u8 unk00[0x50]; ///< Twenty words in chars.tsv; not named by any TBS code.
19 /// The growth curves: each stat at levels 0, 20, 40, 60, 80 and 100. A
20 /// level up adds a twentieth of the step around the new level, with a
21 /// random part; level 1 adds the first point (Owner_LevelUp).
22 ///@{
23 s16 hp[6];
24 s16 pp[6];
25 u16 atk[6];
26 u16 def[6];
27 u16 agi[6];
28 u8 luck[6];
29 ///@}
30 /// Added to ten times the Djinn set in each element to give the
31 /// character's element levels (Unit_GetElementLevels).
33 u8 startingLevel; ///< the level a new game raises the character to
34 u8 unk097; ///< Padding in chars.tsv.
35 /// The starting items, each added and equipped at a new game; the low nine
36 /// bits are the item.
38 u8 unk0b2[2]; ///< Padding in chars.tsv.
39};
40
41/// An ability a class teaches, and the level it is learned at.
43 u8 ability; ///< the action taught, 0 for none
44 u8 level; ///< the level it is taught at
45 u8 unk02[2]; ///< Padding in classes.tsv.
46};
47
48/// A class: its series, the element levels it needs, its stat multipliers and
49/// the abilities it teaches.
51 /// The series the class belongs to; Class_Determine picks the series from
52 /// the character's two strongest elements.
53 long series;
54 /// The element levels the class needs, in tens: the last class of the
55 /// series the character meets in all four is its class.
57 u8 hp; ///< tenths of the base stat
58 u8 pp; ///< tenths of the base stat
59 u8 atk; ///< tenths of the base stat
60 u8 def; ///< tenths of the base stat
61 u8 agi; ///< tenths of the base stat
62 u8 luck; ///< tenths of the base stat
63 u8 unk0e[2]; ///< Padding in classes.tsv.
64 struct ClassAbility abilities[16]; ///< the Psynergy the class teaches
65 /// [0] to [2]: the ability effects the class is weak to
66 /// (BattleTarget_IsWeakToEffect); [3] is not read there.
68};
69
70/// A Djinni: its ability and the stat bonuses it gives while set.
72 u16 abilityId; ///< the action the Djinni unleashes
73 u8 unk02[2]; ///< Reserved in djinn.tsv; not named by any TBS code.
74 /// Added to the base stats while the Djinni is set (UnitCalc), before the
75 /// class multiplies them.
76 ///@{
83 ///@}
84 u8 unk0a[2]; ///< Reserved in djinn.tsv.
85};
86
87/// An enemy's definition: its level and stats, items, element preset, the
88/// actions it chooses from and its rewards.
90 /// The enemy's name: enemies.tsv's name column, 15 bytes, blank in every
91 /// row. BattleUnitSet takes the name from the messages instead.
92 u8 unk00[15];
94 /// The base stats BattleUnitSet copies into the unit.
95 ///@{
102 u8 turns; ///< actions a round (BattleUnit.baseActionCount)
105 ///@}
106 u8 unk1e[2]; ///< Reserved in enemies.tsv: 0 in every row.
107 u32 rewards; ///< 0 in every row; copied to BattleUnit.rewards
108 u8 unk24[4]; ///< Reserved in enemies.tsv: 0 in every row.
109 u16 items[4]; ///< items the enemy carries, 0 for none
110 u8 counts[4]; ///< how many of each item it carries
111 u8 elementPreset; ///< row of gEnemy_ElementPresetTable, 0 to 43
112 /// Whom a single-target attack favours: the target with the most HP left
113 /// (0), the most maximum HP (1) or no one (2). The action choice also skips
114 /// an ability the enemy lacks PP for unless it is 0, and a sealed one when
115 /// it is 2.
117 /// How the action is chosen from `actions` (BattleCommand_SelectAutomatic):
118 /// one of three weight tables (0 to 2), a random place then in order (3),
119 /// in order (4), the next place (5) or the same place (6).
121 u8 itemActions; ///< one bit per place in `actions`: use an item held instead
122 u16 actions[8]; ///< the abilities the enemy chooses from
123 /// [0] to [2]: the ability effects the enemy is weak to
124 /// (BattleTarget_IsWeakToEffect); [3] is 0 in every row.
126 u16 coins; ///< coins won
127 s16 item; ///< the item it may leave, 0 for none
128 /// The chance of the item: 1 in 2 to the power itemChance - 1, two powers
129 /// better with BattleEnemy_RecordDefeat's Djinn bonus; 0 for none.
131 u16 experience; ///< experience won
132};
133
134/// A level up's result: the level reached, an ability learned and the gain in
135/// each stat.
145};
146
147STATIC_ASSERT(sizeof(struct CharacterDefinition) == 0xb4);
149STATIC_ASSERT(offsetof(struct CharacterDefinition, startingLevel) == 0x96);
151STATIC_ASSERT(sizeof(struct ClassDefinition) == 0x54);
153STATIC_ASSERT(sizeof(struct ClassAbility) == 4);
154STATIC_ASSERT(offsetof(struct ClassDefinition, abilities) == 0x10);
155STATIC_ASSERT(sizeof(struct DjinnDefinition) == 0xc);
156STATIC_ASSERT(offsetof(struct DjinnDefinition, abilityId) == 0);
159STATIC_ASSERT(sizeof(struct EnemyDefinition) == 0x54);
160STATIC_ASSERT(offsetof(struct EnemyDefinition, rewards) == 0x20);
161STATIC_ASSERT(offsetof(struct EnemyDefinition, actionStrategy) == 0x36);
162STATIC_ASSERT(offsetof(struct EnemyDefinition, itemActions) == 0x37);
163STATIC_ASSERT(offsetof(struct EnemyDefinition, actions) == 0x38);
164STATIC_ASSERT(offsetof(struct EnemyDefinition, coins) == 0x4c);
165STATIC_ASSERT(offsetof(struct EnemyDefinition, experience) == 0x52);
166STATIC_ASSERT(sizeof(struct LevelUpResult) == 0x10);
167
170
171#endif
struct CharacterDefinition gCharacter_DefinitionTable[]
struct ClassDefinition gClass_DefinitionTable[]
Declares nothing of its own: it only includes types.h, edition.h and farcall.h.
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 in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
A character's definition: the growth curves of its stats, its element bonus, starting level and start...
Definition character.h:17
u8 unk097
Padding in chars.tsv.
Definition character.h:34
u16 items[13]
The starting items, each added and equipped at a new game; the low nine bits are the item.
Definition character.h:37
u8 unk0b2[2]
Padding in chars.tsv.
Definition character.h:38
s16 hp[6]
The growth curves: each stat at levels 0, 20, 40, 60, 80 and 100.
Definition character.h:23
u8 unk00[0x50]
Twenty words in chars.tsv; not named by any TBS code.
Definition character.h:18
u8 startingLevel
the level a new game raises the character to
Definition character.h:33
u8 elementBonus[4]
Added to ten times the Djinn set in each element to give the character's element levels (Unit_GetElem...
Definition character.h:32
An ability a class teaches, and the level it is learned at.
Definition character.h:42
u8 level
the level it is taught at
Definition character.h:44
u8 unk02[2]
Padding in classes.tsv.
Definition character.h:45
u8 ability
the action taught, 0 for none
Definition character.h:43
A class: its series, the element levels it needs, its stat multipliers and the abilities it teaches.
Definition character.h:50
struct ClassAbility abilities[16]
the Psynergy the class teaches
Definition character.h:64
u8 pp
tenths of the base stat
Definition character.h:58
u8 def
tenths of the base stat
Definition character.h:60
u8 atk
tenths of the base stat
Definition character.h:59
u8 unk0e[2]
Padding in classes.tsv.
Definition character.h:63
u8 luck
tenths of the base stat
Definition character.h:62
u8 agi
tenths of the base stat
Definition character.h:61
long series
The series the class belongs to; Class_Determine picks the series from the character's two strongest ...
Definition character.h:53
u8 unk50[4]
[0] to [2]: the ability effects the class is weak to (BattleTarget_IsWeakToEffect); [3] is not read t...
Definition character.h:67
u8 required[4]
The element levels the class needs, in tens: the last class of the series the character meets in all ...
Definition character.h:56
u8 hp
tenths of the base stat
Definition character.h:57
A Djinni: its ability and the stat bonuses it gives while set.
Definition character.h:71
u16 abilityId
the action the Djinni unleashes
Definition character.h:72
u8 unk02[2]
Reserved in djinn.tsv; not named by any TBS code.
Definition character.h:73
u8 unk0a[2]
Reserved in djinn.tsv.
Definition character.h:84
s8 hp
Added to the base stats while the Djinni is set (UnitCalc), before the class multiplies them.
Definition character.h:77
An enemy's definition: its level and stats, items, element preset, the actions it chooses from and it...
Definition character.h:89
s16 item
the item it may leave, 0 for none
Definition character.h:127
u8 unk00[15]
The enemy's name: enemies.tsv's name column, 15 bytes, blank in every row.
Definition character.h:92
u8 elementPreset
row of gEnemy_ElementPresetTable, 0 to 43
Definition character.h:111
u8 itemActions
one bit per place in actions: use an item held instead
Definition character.h:121
s8 targetStrategy
Whom a single-target attack favours: the target with the most HP left (0), the most maximum HP (1) or...
Definition character.h:116
s16 itemChance
The chance of the item: 1 in 2 to the power itemChance - 1, two powers better with BattleEnemy_Record...
Definition character.h:130
u16 items[4]
items the enemy carries, 0 for none
Definition character.h:109
u32 rewards
0 in every row; copied to BattleUnit.rewards
Definition character.h:107
u16 hp
The base stats BattleUnitSet copies into the unit.
Definition character.h:96
u8 counts[4]
how many of each item it carries
Definition character.h:110
s8 actionStrategy
How the action is chosen from actions (BattleCommand_SelectAutomatic): one of three weight tables (0 ...
Definition character.h:120
u8 unk48[4]
[0] to [2]: the ability effects the enemy is weak to (BattleTarget_IsWeakToEffect); [3] is 0 in every...
Definition character.h:125
u8 unk1e[2]
Reserved in enemies.tsv: 0 in every row.
Definition character.h:106
u8 unk24[4]
Reserved in enemies.tsv: 0 in every row.
Definition character.h:108
u16 actions[8]
the abilities the enemy chooses from
Definition character.h:122
u16 experience
experience won
Definition character.h:131
u8 turns
actions a round (BattleUnit.baseActionCount)
Definition character.h:102
u16 coins
coins won
Definition character.h:126
A level up's result: the level reached, an ability learned and the gain in each stat.
Definition character.h:136
The integer types, TRUE, UNUSED and the fixed-address macros.
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