17 if (entryIndex >= 519U) {
19 if (entryIndex >= 0x208U) {
39 currentAction &= actionMask;
41 if (currentAction == actionId) {
45 }
while (index <= 31);
57#define PSYNERGY_ACTION_AT(slots, index) ((slots)[index].encodedAction)
59#define PSYNERGY_ACTION_AT(slots, index) (((u16 *)(slots))[(index) * 2])
85 for (sourceIndex = 0; sourceIndex < 32; sourceIndex++) {
90 for (sourceIndex = 0; sourceIndex < 32; sourceIndex++) {
95 for (slot = 31, sourceIndex = 31; slot >= 0;) {
105 for (; sourceIndex >= 0; sourceIndex--)
110 for (sourceIndex = 0; sourceIndex < 16; sourceIndex++) {
111 classAbility = &classDefinition->
abilities[sourceIndex];
122 for (slot = 0; slot < 32; slot++) {
125 classAbility->
ability | originFlag;
141 for (slot = 0; slot < 32; slot++) {
148 for (slot = 0; slot < 32; slot++) {
160 for (slot = 0, sourceIndex = 0; slot < 32;) {
170 for (; sourceIndex < 32; sourceIndex++)
194 for (index = 0; index <= 30; index++) {
197 if ((masked ^ key) == 0) {
208 for (index = 0; index <= 30; index++) {
212 if (*(
u16 *)((
u8 *)state + offset) == 0) {
213 *(
u16 *)((
u8 *)state + offset) = key;
224 for (index = 0; index <= 31; index++) {
262 for (owner = 0; owner <= 7; owner++) {
266 name[0] = nameBuf[0];
268 if (nameBuf[0] != 0) {
273 name[i] = nameBuf[i];
274 }
while (nameBuf[i] != 0);
281 if (*startingOwner != -1) {
283 unit =
UnitGet(*startingOwner);
285 unit->
classId = *startingOwner;
288 for (i = 14; i >= 0; i--)
291 for (i = 0; i <
sizeof(character->
items) /
sizeof(character->
items[0]);
304 }
while (*startingOwner != -1);
337 u32 requiredExperience;
339 s32 growthDifference;
359 if (requiredExperience != -1 && unit->
experience < requiredExperience)
363 if (gains->
level == 1) {
374 growthBand = gains->
level / 20;
375 CLAMP(growthBand, 0, 4);
378 gains->
hp += ((
Random16() * 20 >> 16) + growthDifference) / 20;
381 gains->
pp += ((
Random16() * 20 >> 16) + growthDifference) / 20;
384 gains->
atk += ((
Random16() * 20 >> 16) + growthDifference) / 20;
387 gains->
def += ((
Random16() * 20 >> 16) + growthDifference) / 20;
390 gains->
agi += ((
Random16() * 20 >> 16) + growthDifference) / 20;
393 gains->
luck += ((
Random16() * 20 >> 16) + growthDifference) / 20;
434 while (currentLevel < targetLevel) {
441#undef PSYNERGY_ACTION_AT
struct CharacterDefinition gCharacter_DefinitionTable[]
void Ui_AdjustValueWithoutLimitFar(s32 message, u16 *buf)
void Unit_UpdateClass(s32 ownerId)
Works out a character's class again after its Djinn change, then its Psynergy list and its base eleme...
struct ClassDefinition * Class_GetDefinition(s32 classId)
Returns class classId's definition: its series, element requirements, stat multipliers and the Psyner...
struct BattleAct gBattleAction_DefinitionTable[]
u32 gCharacter_LevelExpTable[]
What every part of the game object shares: its includes and the inventory helper two parts use.
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
s32 Inventory_AddItem(s32 owner, s32 itemId)
Gives a unit one item, joining its first matching stack (up to 30) or taking the first free slot.
s32 Inventory_Equip(s32 owner, s32 slot)
Equips the item in slot, clearing the equipped bit of the item of the same type it replaces.
struct ItemDefinition * Item_GetDirect(s32 item)
Returns item item's definition; an inventory entry may be passed, its equipped and quantity bits are ...
#define ITEM_USE_TEACHES
Not used up: equipped, it teaches its actionId as Psynergy.
u32 Unit_GetExperienceForLevel(s32 owner, s32 level)
Returns the experience a character needs for level (0 for level 0 and below); -1 for an enemy or a le...
#define PSYNERGY_ACTION_AT(slots, index)
s32 Unit_KnowsAction(s32 owner, s32 actionId)
Returns 1 when actionId is in the unit's action list.
UNUSED void Owner_LevelNoOp(void)
Unused reserved entry; keeps its place in the far-call table.
struct LevelUpResult * Owner_LevelUp(s32 owner, struct LevelUpResult *gains)
Raises a character one level (up to 99), adding to each base stat the growth between the two points o...
void Unit_LevelUpTo(s32 owner, s32 targetLevel)
Levels character owner up one level at a time until targetLevel, then recomputes its stats.
s32 Unit_RefreshPsynergy(s32 owner)
Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list,...
struct CharacterDefinition * Character_GetDefinition(s32 index)
Returns character index's definition: growth curves, starting level and equipment.
struct LevelUpResult * Unit_TryLevelUp(s32 owner, struct LevelUpResult *gains)
Levels the character up once if its experience reaches the next level.
s32 Unit_LearnPsynergy(s32 stateIndex, s32 value)
Teaches a character action value for good (or makes a class action permanent by clearing its marks),...
struct LevelUpResult * Unit_CheckLevelUp(s32 owner, struct LevelUpResult *gains)
Levels the character up once if it has the experience.
void Party_InitCharacters(void)
Sets up all eight characters for a new game: names from the message table, starting equipment equippe...
struct BattleAct * BattleAction_GetDirect(s32 actionId)
Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void MemFree(void *buffer)
const s32 gCharacter_StartingEquipOwnerIds[6]
Characters given starting equipment, terminated by -1.
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u16 baseDefense
before equipment, Djinn, class and stages
u16 baseAttack
before equipment, Djinn, class and stages
u16 baseAgility
before equipment, Djinn, class and stages
s16 hpGauge
hp / maxHp in 0..0x4000; 1 while any HP remains
u8 name[0x0f]
The name, one byte a character, ending in 0.
s16 ppGauge
pp / maxPp in 0..0x4000; 1 while any PP remains
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
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
s16 basePp
before equipment, Djinn and class (UnitCalc)
u32 experience
a character's experience points
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,...
s16 baseHp
before equipment, Djinn and class (UnitCalc)
u8 level
1 to 99 for a character
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
A character's definition: the growth curves of its stats, its element bonus, starting level and start...
u16 items[13]
The starting items, each added and equipped at a new game; the low nine bits are the item.
s16 hp[6]
The growth curves: each stat at levels 0, 20, 40, 60, 80 and 100.
u8 startingLevel
the level a new game raises the character to
An ability a class teaches, and the level it is learned at.
u8 level
the level it is taught at
u8 ability
the action taught, 0 for none
A class: its series, the element levels it needs, its stat multipliers and the abilities it teaches.
struct ClassAbility abilities[16]
the Psynergy the class teaches
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
u8 useType
what using it costs (ITEM_USE_), or 0 for nothing
u16 actionId
the ability used, or taught as Psynergy
A level up's result: the level reached, an ability learned and the gain in each stat.
Scratch for Owner_LevelUp, in the alternate pool.
s32 level
the level before this one
struct CharacterDefinition * growth
the character's growth curves
u8 unk0c[0x20]
never written
s32 classIndex
the unit's class, written and not read again
An entry in a unit's action list: the action's id (OWNER_ACTION_ID_MASK) and marks for an action its ...
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.
void UnitCalc(s32 owner)
Recomputes a unit's stats from its base stats, equipment, set Djinn, class and battle stat levels,...
struct BattleUnit * UnitGet(u32 owner)
Returns the unit record of owner: 0 to 7 are the playable characters in the game state,...