14 if ((group <= 3U) && (index <= 19U)) {
15 entry = (group * 20) + index;
26 s32 leastLoadedOwner = 0;
27 s32 fewestDjinn = 999;
36 for (partyIndex = 0; partyIndex < partySize; partyIndex++) {
42 for (elementIndex = 0; elementIndex <
NUM_ELEMENTS; elementIndex++)
44 if (fewestDjinn > ownedDjinn) {
45 fewestDjinn = ownedDjinn;
51 if (fewestDjinn == 999)
57 return leastLoadedOwner;
95 if ((unit->
djinnActive[element] & (1 << djinnIndex)) != 0)
99 (owner < 0 || owner > 7)))
101 for (entryIndex = 0; entryIndex < recoveryList->
count; entryIndex++) {
108 if (entryIndex == recoveryList->
count ||
109 ((recoveryTurns = recoveryList->
entries[entryIndex].
turns) <= 0 &&
110 recoveryTurns != -2))
119 return (
u32)(-activeBit | activeBit) >> 31;
148 if (wasActive != 0) {
165 (owner < 0 || owner > 7)))
167 for (entryIndex = 0; entryIndex < recoveryList->
count; entryIndex++) {
169 djinnIndex == recoveryList->
entries[entryIndex].
index) {
170 recoveryList->
count--;
175 for (; entryIndex < recoveryList->
count; entryIndex++) {
176 recoveryList->
entries[entryIndex] = recoveryList->
entries[entryIndex + 1];
192 entryIndex = recoveryList->
count;
197 recoveryList->
count = entryIndex + 1;
215 if (wasActive != 0) {
231 s32 standbyCount = 0;
240 *slot = standbyCount;
242 *slot = standbyCount;
244 *slot = standbyCount;
245 counts[0] = standbyCount;
250 if (entry->
turns == -1) {
257 }
while (entryIndex != recoveryTable->
list.
count);
276 if (djinnCount < partySize) {
277 u16 *ownerCursor = owners;
278 s32 remainingOwners = partySize;
292 }
while (remainingOwners != 0);
s32 GameFlag_Test(s32 flag)
Returns 1 when flag is set.
s32 GameFlag_SetBit(s32 flag)
Sets flag and returns its byte number.
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
void Unit_UpdateClass(s32 ownerId)
Works out a character's class again after its Djinn change, then its Psynergy list and its base eleme...
s32 Djinn_AddToOwner(s32 owner, s32 element, s32 djinnIndex)
Gives Djinni djinnIndex of element to a unit: sets its bit in djinnAvailable and counts it.
s32 Djinn_GetAbilityId(u32 group, u32 index)
Returns the ability ID used when the Djinni is unleashed.
u32 Djinn_IsActive(s32 owner, s32 element, s32 djinnIndex)
Returns 1 when the Djinni is set on the unit.
const struct DjinnDefinition * Djinn_GetDefinition(u32 group, u32 index)
Returns the definition of Djinn index (0 to 19) of element group (0 to 3); anything out of range give...
s32 Djinn_AddToLeastLoadedOwner(s32 element, s32 djinn)
Gives a newly found Djinni to the party member holding the fewest Djinn who has room in that element,...
s32 Djinn_IsReady(s32 owner, s32 element, s32 djinnIndex)
Returns 1 when the unit holds the Djinni and it can be set: it is not set already,...
s32 Party_SumDjinnCounts(s32 element)
Returns how many Djinn of element the party holds, or of all elements for -1.
u32 Djinn_Deactivate(s32 owner, s32 element, s32 djinnIndex)
Takes a set Djinni off the unit and works out its class again.
s32 Djinn_Activate(s32 owner, s32 element, s32 djinnIndex)
Sets a ready Djinni on the unit, counts it and works out the unit's class again.
u32 * DjinnRecovery_AddStandby(u32 owner, u32 element, u32 djinnIndex)
Puts the owner's Djinni at the end of its side's list on standby (turns -1), moving it there if it wa...
s32 DjinnRecovery_Remove(s32 owner, s32 element, s32 djinnIndex)
Takes the Djinni off its side's standby and recovery list, closing the gap.
s32 Djinn_Transfer(s32 source, s32 element, s32 djinnIndex, s32 target)
Moves a Djinni from one unit to another, keeping it set or on standby.
s32 DjinnRecovery_CountStandby(u8 *counts)
Counts the party's Djinn on standby, by element into counts when it is given.
const struct DjinnDefinition gDjinn_DefinitionTable[]
What every part of the game object shares: its includes and the inventory helper two parts use.
struct GameState gGameState
s32 Party_CountActiveOwners(void)
Returns the number of party members, counted from game flags 0 to 7.
s32 Party_ListActiveOwners(s16 *owners)
Writes the party members to owners, ending with 0xff, and returns how many there are.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
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 djinnActiveCounts[4]
the Djinn set in each element; the class's element levels are read from these
struct BattleElementStats element[4]
Power and resistance in each element, 0 to 200, after equipment, element levels and Resistance stages...
u32 djinnAvailable[4]
The Djinn held, one bit per Djinni (by its index) in each element's word.
A Djinni: its ability and the stat bonuses it gives while set.
u16 abilityId
the action the Djinni unleashes
A Djinni on standby or recovering: its element and index, its owner, and the turns until it is set ag...
s8 turns
Turns until it is set again; -1 on standby (DJINN_RECOVERY_AFTER_BATTLE), -2 while a summon uses it.
u8 index
the Djinni within its element, 0 to 19
One side's Djinn recovery list: up to 64 entries and their count.
struct DjinnRecoveryEntry entries[64]
One side's Djinn recovery table, as Djinn_GetRecoveryTable returns it.
struct DjinnRecoveryList list
u8 activeOwners[8]
the party in order
struct BattleUnit * UnitGet(u32 owner)
Returns the unit record of owner: 0 to 7 are the playable characters in the game state,...
void * Djinn_GetRecoveryTable(s32 enemySide)
Returns the party's Djinn recovery bank (the standby Djinn and their turns to recover),...