Alchemy
Loading...
Searching...
No Matches

game.h File Reference

Go to the source code of this file.

Functions

void Game_Restart (void)
 Starts a new game: clears the game state and restarts at the opening.
void * Djinn_GetRecoveryTable (s32 enemySide)
 Returns the party's Djinn recovery bank (the standby Djinn and their turns to recover), or for the enemy side battle unit 0x83's record, read as a bank.
u32 Party_GetAverageLevel (void)
 Returns the average level of the party members, rounded down (0 with no members).
struct BattleUnit * UnitGet (u32 owner)
 Returns the unit record of owner: 0 to 7 are the playable characters in the game state, 0x80 to 0x85 the enemies of the current battle.
const u8 * Enemy_GetDefinition (s32 selector)
 Returns the definition of enemy selector - 8; an id past the first 250 gives the first.
void Runtime_CopyBytesDirectional (u8 *first, u8 *second, s32 count, s32 direction)
 Copies count bytes from first to second when direction is set, and from second to first otherwise.
void UnitCalc (s32 owner)
 Recomputes a unit's stats from its base stats, equipment, set Djinn, class and battle stat levels, clamps each to its range and writes them to the unit.
void GameFlag_RefreshLureCap (void)
 Sets FLAG_LURE_CAP when any party member has the Lure Cap (the one item with ITEM_EFFECT_LURE) equipped, and clears it otherwise.
u32 Runtime_GetBuildStampTime (void)
 Encodes the build-stamp time as ((hours * 16 + minutes) * 64 + seconds) with bit 12 set.
void GameState_InitDefaults (void)
 Clears the game-state header, scene state, flags and save stamp; sets a new game's defaults: Isaac alone in the party, the standard button layout, the message speed, the play time clock and the slot machine prize odds.
void Party_BeginChildhood (void)
 Sets FLAG_CHILDHOOD and recomputes Isaac, Garet and Jenna, whose classes then take their childhood forms.
void Party_EndChildhood (void)
 The party set-up after the prologue: flags, Jenna recomputed, Isaac and Garet healed with the Machete in their inventories replaced by the Short Sword and equipped, Move and Retreat taught to Isaac, Move to Garet, Mind Read to Ivan, and 300 coins.
void Party_RestoreHpPp (s32 cureConditions)
 Restores every party member's HP and PP; with cureConditions 1 it also cures poison and haunting.
void Party_RestorePpOfLitElements (void)
 Restores the PP of each party member whose element group has a lit lighthouse: Venus or Mars for group 0, Mercury or Jupiter for the others.
void Owner_RatioNoOp (void)
 Unused reserved entry; keeps its place in the far-call table.
void UnitRatio (s32 owner)
 Recomputes the HP and PP gauges of owner from its current HP and PP, so that UnitCalc keeps the same fractions.
void Unit_SetHp (struct BattleUnit *unit, s32 hp)
 Sets the unit's HP, clamped to 0..maxHp, and recomputes its HP and PP gauges.
void Unit_SetPp (struct BattleUnit *unit, s32 pp)
 Sets the unit's PP, clamped to 0..maxPp, and recomputes its HP and PP gauges.
s32 Unit_AddHp (s32 owner, s32 delta)
 Adds delta to the HP of unit owner, clamped to 0..maxHp, recomputes its gauges and returns the new HP.
s16 Unit_AddPp (s32 owner, s32 delta)
 Adds delta to the PP of unit owner, clamped to 0..maxPp, recomputes its gauges and returns the new PP.
s32 Party_AdjustShopCredit (s32 amount)
s32 Party_AdjustShopGifts (s32 amount)
struct ItemDefinition * Item_GetDirect (s32 item)
 Returns item item's definition; an inventory entry may be passed, its equipped and quantity bits are ignored.
s32 Item_CanOwnerEquipDirect (s32 owner, s32 item)
 Returns whether the character can equip item: bit classId of the item's equipMask.
s32 Item_IsCompatibleWithOwner (s32 unit, s32 item)
 Returns 1 for an item that is not a weapon or armor, and for those whether the character can equip it.
s32 Item_GetEquipmentGroup (s32 itemId)
 Returns what kind of thing an item is: 1 a weapon, 2 armor (armor, shields, helms, boots and shirts), 0 anything else, rings included.
s32 Inventory_GetQuantity (s32 owner, s32 slot)
 Returns how many of the item in slot the unit carries (0 for an empty slot).
s32 Inventory_Count (s32 owner)
 Counts filled inventory slots up to the first empty slot; the inventory is kept closed up, so this is how many items the unit carries.
s32 PartyInventory_HasSpace (void)
 Returns 1 when the selected character or any party member has a free inventory slot.
s32 PartyInventory_CountFreeSlots (void)
 Returns the free inventory slots of the whole party.
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 PartyInventory_Add (s32 itemId)
 Gives the item to the first party member with room.
s32 Inventory_Find (s32 owner, s32 itemId)
 Returns the first slot holding itemId (any quantity, equipped or not), or -1.
s32 PartyInventory_FindOwner (s32 itemId)
 Returns who carries itemId, asking the selected character first, or -1.
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.
s32 Inventory_FindEquipped (s32 owner, s32 type)
 Returns the slot of the equipped item of type, or -1.
struct ItemDefinition * Inventory_GetEquippedDefinition (struct BattleUnit *unit, s32 type)
 Returns the definition of the unit's equipped item of type, or NULL.
s32 Inventory_GetEquippedItem (struct BattleUnit *unit, s32 type)
 Returns the id of the unit's equipped item of type, or 0.
s32 Inventory_Remove (s32 owner, s32 slot)
 Takes one item out of slot: a stack shrinks by one (returns 1), a last item empties the slot and the inventory closes up (returns 2).
s32 Inventory_Discard (s32 owner, s32 slot)
 Removes one item as Inventory_Remove does, and puts a rare item back into circulation (its counter goes up by one) for the shops to sell.
s32 Inventory_CheckDiscard (s32 owner, s32 slot)
 Returns whether the item in slot may be dropped: 0 yes, -1 the slot is empty, -4 the item is indispensable, -3 it is equipped and cursed on.
s32 PartyInventory_Remove (s32 itemId)
 Removes one itemId from whoever carries it first; always returns 0.
s32 PartyInventory_Discard (s32 itemId)
 Discards one itemId from whoever carries it first, as Inventory_Discard does; always returns 0.
s32 Inventory_Break (s32 owner, s32 slot)
 Marks the item in slot broken; returns -1 for an empty slot.
s32 Inventory_Repair (s32 owner, s32 slot)
 Clears the broken mark of the item in slot; returns -1 for an empty slot.
u8 Item_GetTargetMode (s32 itemId)
 Returns how the action an item performs when used picks its targets.
s32 ItemCounter_Adjust (s32 index, s32 delta)
 Adds delta to rare item counter index, kept between 0 and 99, and returns the new count (0 for an index past 127).
s32 Item_AdjustCounter (s32 itemId, s32 delta)
 Adds delta to the counter of a rare item; ordinary items have none.
s32 Inventory_CountItem (s32 owner, s32 itemId)
 Counts matching nonstackable items, or the quantity in the first matching stack.
s32 PartyInventory_CountItem (s32 itemId)
 Counts itemId across the party.
struct BattleAct * BattleAction_GetDirect (s32 actionId)
 Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.
s32 Unit_KnowsAction (s32 owner, s32 actionId)
 Returns 1 when actionId is in the unit's action list.
s32 Unit_RefreshPsynergy (s32 owner)
 Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list, adds every class action learned by its level and the action of each equipped item that grants one, and closes it up again.
s32 Unit_LearnPsynergy (s32 stateIndex, s32 value)
 Teaches a character action value for good (or makes a class action permanent by clearing its marks), then rebuilds its list.
struct LevelUpResult * Unit_CheckLevelUp (s32 owner, struct LevelUpResult *gains)
 Levels the character up once if it has the experience.
struct CharacterDefinition * Character_GetDefinition (s32 index)
 Returns character index's definition: growth curves, starting level and equipment.
void Party_InitCharacters (void)
 Sets up all eight characters for a new game: names from the message table, starting equipment equipped, class and elements worked out, and levels raised to their starting level.
void Owner_LevelNoOp (void)
 Unused reserved entry; keeps its place in the far-call table.
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 level above 99.
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 of its growth curve around the new level (one point every 20 levels), a twentieth of it per level with a random part.
struct LevelUpResult * Unit_TryLevelUp (s32 owner, struct LevelUpResult *gains)
 Levels the character up once if its experience reaches the next level.
void Unit_LevelUpTo (s32 owner, s32 targetLevel)
 Levels character owner up one level at a time until targetLevel, then recomputes its stats.
s32 GameFlag_Test (s32 flag)
 Returns 1 when flag is set.
s32 GameFlag_SetBit (s32 flag)
 Sets flag and returns its byte number.
void GameFlag_ClearBit (s32 flag)
 Clears flag.
u32 GameFlag_Toggle (s32 flag)
 Flips flag and returns its new value.
s32 GameFlag_GetByte (s32 flag)
 Returns the whole byte flag is in, a counter kept among the flags.
void GameFlag_SetByte (s32 flag, s32 value)
 Sets the whole byte flag is in.
u8 GameFlag_IncrementByte (s32 flag)
 Adds 1 to the byte flag is in, stopping at 255, and returns it.
u8 GameFlag_DecrementByte (s32 flag)
 Takes 1 from the byte flag is in, stopping at 0, and returns it.
s32 GameFlag_GetNibble (u32 flag)
 Returns the four bits flag is in (bit 2 of the number picks the half).
void GameFlag_SetNibble (s32 flag, s32 value)
 Sets the four bits flag is in.
s32 BattleUnitSet (s32 unitId, s32 enemyId, s32 suffix)
 Fills battle unit unitId (0x80 to 0x86) with enemy enemyId: stats, name with its suffix letter, the items it carries, rewards and elements.
s32 Party_CountActiveOwners (void)
 Returns the number of party members, counted from game flags 0 to 7.
s32 Party_AddActiveOwner (s32 owner)
 Adds character owner to the end of the party: sets its game flag and appends it to gGameState.activeOwners unless it is already listed.
s32 Party_RemoveActiveOwner (s32 owner)
 Takes character owner out of the party: clears its game flag and closes the gap it leaves in gGameState.activeOwners.
s32 Party_ListActiveOwners (s16 *owners)
 Writes the party members to owners, ending with 0xff, and returns how many there are.
s32 Party_AdjustCoins (s32 amount)
 Adds amount to the party's coins, kept between 0 and 999999, and returns the new total.
s32 Summon_ListLearned (u8 *output)
 Writes the summons whose bit is set in the first word of the party's Djinn table to output, in menu order, ending with 32.
const struct SummonDefinition * SummonDefinition_GetNear (u32 summonId)
 Returns summon summonId's definition, or NULL past the sixteenth.
s32 Class_GetSeries (s32 primaryElement, s32 secondaryElement)
 Returns the class series of a character whose strongest element is primaryElement and second secondaryElement, from the 4 by 4 table.
s32 Unit_GetElementLevels (s32 record, const u8 *source, s32 output[4])
 Writes ten times each element level to output: an enemy's from its element preset, a character's from the Djinn set on it (source is its Djinn bits) plus its own element bonus.
s32 Unit_GetElementLevel (s32 owner, s32 element)
 Returns a unit's level in element (0 to 3).
s32 Enemy_GetAttackElement (struct BattleUnit *unit)
 Returns the element an enemy attacks with, from its element preset.
u32 Unit_CalcBaseElements (s32 owner, s16 destination[4][2])
s32 Class_Determine (s32 character, const u8 *djinn)
 Returns the class a character has with djinn set: the series is chosen by its two strongest elements, and the class is the last of the series whose element requirements it meets.
struct ClassDefinition * Class_GetDefinition (s32 classId)
 Returns class classId's definition: its series, element requirements, stat multipliers and the Psynergy it teaches by level.
void Unit_UpdateClass (s32 ownerId)
 Works out a character's class again after its Djinn change, then its Psynergy list and its base elements.
s32 Battle_GetElementMultiplier (s32 input, s32 halve)
 Returns the multiplier (256 = 1x) for an element difference input, read from a five-point line (gElement_PowerResistCurve); with halve the effect of the difference is half.
s32 BattleRandom (void)
 The battle's random number generator, the same linear congruential one as Random16 with its own seed.
u32 BattleRandomPercent (void)
 Returns a battle random number from 0 to 99.
s32 Battle_CalcAttackDamage (s32 attack, s32 defense, s32 addedPower, s32 elementDifference)
 Scales max(attack - defense, 0) + twice the action's added power by the elemental multiplier, then halves it.
s32 Battle_CalcPsynergyPower (s32 power, s32 elementDifference, s32 powerMultiplier)
 Returns the power of Psynergy: power times the multiplier for the element difference (power minus resistance, 0..512 with 256 = 1x) and the supplied powerMultiplier (also 256 = 1x).
s32 Battle_CalcRecovery (s32 power, s32 elementPower, s32 powerMultiplier)
 Returns the amount healed: power and powerMultiplier (256 is 1x) times the multiplier for twice the healer's element power above 100.
s32 Item_GetEquippedElement (s32 owner)
 Returns the element the unit attacks with (ELEMENT_NONE for none): an enemy's comes from its kind, a character's from its equipped weapon.
s32 Equipment_GetUnleashRateBonus (struct BattleUnit *unit)
 Returns the unleash chance, in percent, that a unit's equipment adds (ITEM_EFFECT_ADD_UNLEASH_CHANCE).
s32 RollWeaponUnleash (struct BattleUnit *owner)
 Rolls whether a character's weapon unleashes: its chance is the weapon's unleashChance times 5 percent plus what the equipment adds.
s32 BattleFx_GetBaseSuccessRate (s32 effectId)
 Returns the base chance, in percent, of effect effectId.
s32 BattleTarget_IsWeakToEffect (const struct BattleUnit *target, s32 effectId)
 Returns 1 when the unit is weak to effect effectId: one of three listed for its enemy kind (EnemyDefinition.unk48) or class (ClassDefinition.unk50).
s32 Battle_IsReviveEffect (s32 effectId)
 Returns 1 for the revive effects (Revive, Quartz, Dew), which only work on a downed unit.
s32 BattleFx_RollSuccess (s32 caster, s32 target, s32 resistanceCategory, s32 effectId, s32 successScale)
 Rolls whether effect effectId takes hold on target: it fails at once when there is nothing for it to do.
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 gives the first.
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, puts it on standby and sets its found flag.
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_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, not recovering and not held by a summon.
u32 Djinn_IsActive (s32 owner, s32 element, s32 djinnIndex)
 Returns 1 when the Djinni is set on the unit.
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 Djinn_Deactivate (s32 owner, s32 element, s32 djinnIndex)
 Takes a set Djinni off the unit and works out its class again.
s32 DjinnRecovery_Remove (s32 owner, s32 element, s32 djinnIndex)
 Takes the Djinni off its side's standby and recovery list, closing the gap.
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 was already listed.
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.
s32 Djinn_GetAbilityId (u32 group, u32 index)
 Returns the ability ID used when the Djinni is unleashed.
s32 Party_SumDjinnCounts (s32 element)
 Returns how many Djinn of element the party holds, or of all elements for -1.
void Inventory_AddAndEquip (s32 owner, s32 itemId)
 Gives a unit itemId and equips every exactly matching inventory entry.
void InventorySnapshot_Save (void)
 Saves the first four characters' inventories, shortcuts and party order, then keeps only the Psynergy-granting items, gives Isaac the Short Sword, sets FLAG_INVENTORY_SNAPSHOT and restores everyone's HP and PP.
void InventorySnapshot_Restore (void)
 Gives back the inventories, shortcuts and party order InventorySnapshot_Save put aside, then clears the snapshot and FLAG_INVENTORY_SNAPSHOT.

Function Documentation

◆ Game_Restart()

void Game_Restart ( void )

Starts a new game: clears the game state and restarts at the opening.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 32 of file units.c.

Referenced by Game_Restart().

◆ Djinn_GetRecoveryTable()

void * Djinn_GetRecoveryTable ( s32 enemySide)

Returns the party's Djinn recovery bank (the standby Djinn and their turns to recover), or for the enemy side battle unit 0x83's record, read as a bank.

The bank also holds the summon flags Summon_ListLearned reads. Called by the battle code that sets, recovers and links Djinn (DjinnRecovery_Tick, BattleSummon_UpdateAvailability, the link battle).

Definition at line 42 of file units.c.

Referenced by Djinn_GetRecoveryTable(), Djinn_IsReady(), DjinnRecovery_AddStandby(), DjinnRecovery_CountStandby(), DjinnRecovery_Remove(), LinkLobby_ReceivePartyRecords(), LinkLobby_SendPartyRecords(), and Summon_ListLearned().

◆ Party_GetAverageLevel()

u32 Party_GetAverageLevel ( void )

Returns the average level of the party members, rounded down (0 with no members).

Called by Encounter_SelectEnemyGroup to pick a random battle's enemies, and by the Lucky Dice game in Tolbi to set its prizes.

Definition at line 52 of file units.c.

Referenced by Party_GetAverageLevel(), and TolbiSpring_OfferLuckyDice().

◆ UnitGet()

struct BattleUnit * UnitGet ( u32 owner)

Returns the unit record of owner: 0 to 7 are the playable characters in the game state, 0x80 to 0x85 the enemies of the current battle.

Anything else, or an enemy outside a battle, is NULL. Nearly every bank calls it, through GAME.S as UnitGetFar.

Definition at line 73 of file units.c.

Referenced by BabiPalace_RestorePartyAndInventory(), BattleFx_RollSuccess(), BattleUnitSet(), Clear_PackPasswordData(), Colosso_ControlCharacterAlone(), DebugMenu_DamageAndAfflictParty(), Djinn_Activate(), Djinn_AddToLeastLoadedOwner(), Djinn_AddToOwner(), Djinn_Deactivate(), Djinn_GetRecoveryTable(), Djinn_IsActive(), Djinn_IsReady(), Djinn_Transfer(), GameFlag_RefreshLureCap(), GomaCaveEntrance_GiveShamansRod(), Inventory_AddAndEquip(), Inventory_AddItem(), Inventory_Break(), Inventory_CheckDiscard(), Inventory_Count(), Inventory_CountItem(), Inventory_Discard(), Inventory_Equip(), Inventory_Find(), Inventory_FindEquipped(), Inventory_GetQuantity(), Inventory_Remove(), Inventory_Repair(), InventorySnapshot_Restore(), InventorySnapshot_Save(), Item_CanOwnerEquipDirect(), Item_GetEquippedElement(), ItemLevel_AdjustOwnerLevel(), ItemLevel_RunLevelEditor(), KolimaForestTree_ReplaceInventoryItem(), LinkLobby_ReceivePartyRecords(), LinkLobby_SendPartyRecords(), MercuryLighthouse_ReplaceInventoryItem(), Owner_LevelUp(), Party_EndChildhood(), Party_GetAverageLevel(), Party_InitCharacters(), Party_RestoreHpPp(), Party_RestorePpOfLitElements(), Party_SumDjinnCounts(), Scene_GiveAndEquipItem(), SolSanctumElementalStarRoom_UnmaskFelix(), Unit_AddHp(), Unit_AddPp(), Unit_CalcBaseElements(), Unit_GetElementLevel(), Unit_GetExperienceForLevel(), Unit_KnowsAction(), Unit_LearnPsynergy(), Unit_LevelUpTo(), Unit_RefreshPsynergy(), Unit_TryLevelUp(), Unit_UpdateClass(), UnitCalc(), UnitGet(), UnitRatio(), Vault_GetIvanVenusDjinnCount(), Vault_ReturnIsaacsDjinni(), and VaultInteriors_GetIvanVenusDjinnCount().

◆ Enemy_GetDefinition()

const u8 * Enemy_GetDefinition ( s32 selector)

Returns the definition of enemy selector - 8; an id past the first 250 gives the first.

Called by the battle code that builds and scores enemies (the formations, the enemy AI, the spoils) and by the element and weakness reads in this object. XXX: why enemy ids are offset by 8 is unknown; the encounter tables' enemy column would show whether 0 to 7 were meant for the characters.

Definition at line 103 of file units.c.

Referenced by BattleTarget_IsWeakToEffect(), Enemy_GetAttackElement(), Enemy_GetDefinition(), Unit_CalcBaseElements(), and Unit_GetElementLevels().

◆ Runtime_CopyBytesDirectional()

void Runtime_CopyBytesDirectional ( u8 * first,
u8 * second,
s32 count,
s32 direction )

Copies count bytes from first to second when direction is set, and from second to first otherwise.

Definition at line 121 of file units.c.

Referenced by Runtime_CopyBytesDirectional().

◆ UnitCalc()

void UnitCalc ( s32 owner)

Recomputes a unit's stats from its base stats, equipment, set Djinn, class and battle stat levels, clamps each to its range and writes them to the unit.

A change of maximum HP or PP keeps the unit's current HP and PP at the same fraction of it. Also sets the unit's curse restraint bits and equipment bonuses. Called after anything that changes those inputs: equipping, setting Djinn, levelling up, a class change, battle stat changes.

Definition at line 149 of file units.c.

Referenced by BattleUnitSet(), DebugMenu_RecalculateParty(), Inventory_Equip(), Inventory_Remove(), InventorySnapshot_Restore(), InventorySnapshot_Save(), ItemLevel_AdjustOwnerLevel(), ItemLevel_RunLevelEditor(), MercuryLighthouse_MiaJoinsAfterRescue(), Owner_LevelUp(), Party_BeginChildhood(), Party_EndChildhood(), Party_InitCharacters(), Unit_LevelUpTo(), UnitCalc(), and Vault_ReturnIsaacsDjinni().

◆ GameFlag_RefreshLureCap()

void GameFlag_RefreshLureCap ( void )

Sets FLAG_LURE_CAP when any party member has the Lure Cap (the one item with ITEM_EFFECT_LURE) equipped, and clears it otherwise.

Called on entering a scene (Scene_ResetFlagsOnEnter, Field_RunScene) and at the end of a field event, so the encounter rate follows the cap.

Definition at line 446 of file units.c.

Referenced by GameFlag_RefreshLureCap().

◆ Runtime_GetBuildStampTime()

u32 Runtime_GetBuildStampTime ( void )

Encodes the build-stamp time as ((hours * 16 + minutes) * 64 + seconds) with bit 12 set.

Debug mode also sets bits 15..31 before the halfword cast. GameState_InitDefaults stores it as a new game's start stamp, and the save menu (SaveMenu_SelectSlot, SaveState_BuildSummaryHeader) and the file select screen compare saves with it.

Definition at line 482 of file units.c.

Referenced by GameState_InitDefaults(), Runtime_GetBuildStampTime(), and SaveMenu_Run().

◆ GameState_InitDefaults()

void GameState_InitDefaults ( void )

Clears the game-state header, scene state, flags and save stamp; sets a new game's defaults: Isaac alone in the party, the standard button layout, the message speed, the play time clock and the slot machine prize odds.

Called by the file select screen's new game, by Game_Restart and Game_ResetForNewGame, and by the debug battle menu.

Definition at line 537 of file units.c.

Referenced by Game_Restart(), GameState_InitDefaults(), and SaveMenu_Run().

◆ Party_BeginChildhood()

void Party_BeginChildhood ( void )

Sets FLAG_CHILDHOOD and recomputes Isaac, Garet and Jenna, whose classes then take their childhood forms.

Called by the file select screen when a new game starts the prologue.

Definition at line 603 of file units.c.

Referenced by Party_BeginChildhood(), and SaveMenu_Run().

◆ Party_EndChildhood()

void Party_EndChildhood ( void )

The party set-up after the prologue: flags, Jenna recomputed, Isaac and Garet healed with the Machete in their inventories replaced by the Short Sword and equipped, Move and Retreat taught to Isaac, Move to Garet, Mind Read to Ivan, and 300 coins.

Called by Title_Run when the title shown after the prologue hands over to Vale, three years later. XXX: flag 0x901 is set here with no name; its readers would name it.

Definition at line 619 of file units.c.

Referenced by Party_EndChildhood(), and Title_Run().

◆ Party_RestoreHpPp()

void Party_RestoreHpPp ( s32 cureConditions)

Restores every party member's HP and PP; with cureConditions 1 it also cures poison and haunting.

Called by the scenes that heal the party (leaving Vale, meeting Flint, the Colosso rounds, Faran in Lalivero), by the Battle Arena after a round, and by InventorySnapshot_Save.

Definition at line 662 of file units.c.

Referenced by ColossoLog_PlayPostBattleReunion(), ColossoRiver_RestoreMatchResult(), ColossoWall_StageBattleResult(), Event_DepartForQuest(), Event_MeetFlint(), InventorySnapshot_Save(), LinkLobby_RunRoundResult(), Party_RestoreHpPp(), and ReportToFaran().

◆ Party_RestorePpOfLitElements()

void Party_RestorePpOfLitElements ( void )

Restores the PP of each party member whose element group has a lit lighthouse: Venus or Mars for group 0, Mercury or Jupiter for the others.

Called by the scenes at the top of the Mercury and Venus Lighthouses.

Definition at line 685 of file units.c.

Referenced by MercuryLighthouseAerie_PartyArrives(), Party_RestorePpOfLitElements(), and VenusLighthouseAerie_CombineSaturosAndMenardi().

◆ Owner_RatioNoOp()

void Owner_RatioNoOp ( void )

Unused reserved entry; keeps its place in the far-call table.

Definition at line 721 of file units.c.

Referenced by Owner_RatioNoOp().

◆ UnitRatio()

void UnitRatio ( s32 owner)

Recomputes the HP and PP gauges of owner from its current HP and PP, so that UnitCalc keeps the same fractions.

Called after anything that writes HP or PP directly: Unit_AddHp, the inn, the sanctum, item use, battle.

Definition at line 726 of file units.c.

Referenced by Unit_AddHp(), Unit_AddPp(), and UnitRatio().

◆ Unit_SetHp()

void Unit_SetHp ( struct BattleUnit * unit,
s32 hp )

Sets the unit's HP, clamped to 0..maxHp, and recomputes its HP and PP gauges.

Called by BattleActor_DestroyTemporaryObject.

Definition at line 749 of file units.c.

Referenced by Unit_SetHp().

◆ Unit_SetPp()

void Unit_SetPp ( struct BattleUnit * unit,
s32 pp )

Sets the unit's PP, clamped to 0..maxPp, and recomputes its HP and PP gauges.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 759 of file units.c.

Referenced by Unit_SetPp().

◆ Unit_AddHp()

s32 Unit_AddHp ( s32 owner,
s32 delta )

Adds delta to the HP of unit owner, clamped to 0..maxHp, recomputes its gauges and returns the new HP.

Called by battle's round end, poison and regeneration, and by the field's damage floors and status damage.

Definition at line 770 of file units.c.

Referenced by FieldUnit_AddHp(), and Unit_AddHp().

◆ Unit_AddPp()

s16 Unit_AddPp ( s32 owner,
s32 delta )

Adds delta to the PP of unit owner, clamped to 0..maxPp, recomputes its gauges and returns the new PP.

Called when Psynergy is used in the field, in battle and from the menu, by PP recovery at the end of a battle round, and by the debug menu.

Definition at line 787 of file units.c.

Referenced by DebugMenu_DamageAndAfflictParty(), and Unit_AddPp().

◆ Party_AdjustShopCredit()

s32 Party_AdjustShopCredit ( s32 amount)

Definition at line 240 of file party.c.

Referenced by Party_AdjustShopCredit().

◆ Party_AdjustShopGifts()

s32 Party_AdjustShopGifts ( s32 amount)

Definition at line 241 of file party.c.

Referenced by Party_AdjustShopGifts().

◆ Item_GetDirect()

struct ItemDefinition * Item_GetDirect ( s32 item)

Returns item item's definition; an inventory entry may be passed, its equipped and quantity bits are ignored.

Every bank that shows or uses an item calls it, through GAME.S as Item_GetDirectFar.

Definition at line 10 of file inventory.c.

Referenced by Equipment_GetUnleashRateBonus(), GameFlag_RefreshLureCap(), Inventory_AddItem(), Inventory_CheckDiscard(), Inventory_CountItem(), Inventory_Equip(), Inventory_FindEquipped(), Inventory_GetEquippedDefinition(), Inventory_GetEquippedItem(), InventorySnapshot_Save(), Item_CanOwnerEquipDirect(), Item_GetDirect(), Item_GetEquipmentGroup(), Item_GetTargetMode(), Unit_RefreshPsynergy(), and UnitCalc().

◆ Item_CanOwnerEquipDirect()

s32 Item_CanOwnerEquipDirect ( s32 owner,
s32 item )

Returns whether the character can equip item: bit classId of the item's equipMask.

Units past the eight characters cannot. Inventory_Equip checks it first.

Definition at line 17 of file inventory.c.

Referenced by Inventory_Equip(), Item_CanOwnerEquipDirect(), and Item_IsCompatibleWithOwner().

◆ Item_IsCompatibleWithOwner()

s32 Item_IsCompatibleWithOwner ( s32 unit,
s32 item )

Returns 1 for an item that is not a weapon or armor, and for those whether the character can equip it.

The shop's buy screen calls it to grey out the members who could not use an item.

Definition at line 31 of file inventory.c.

Referenced by Item_IsCompatibleWithOwner().

◆ Item_GetEquipmentGroup()

s32 Item_GetEquipmentGroup ( s32 itemId)

Returns what kind of thing an item is: 1 a weapon, 2 armor (armor, shields, helms, boots and shirts), 0 anything else, rings included.

Called by the shops to choose the comparison they show.

Definition at line 41 of file inventory.c.

Referenced by Item_GetEquipmentGroup(), and Item_IsCompatibleWithOwner().

◆ Inventory_GetQuantity()

s32 Inventory_GetQuantity ( s32 owner,
s32 slot )

Returns how many of the item in slot the unit carries (0 for an empty slot).

The entry stores one less than the count. Reached through GAME.S as Shop_GetSelectionState; nothing in this image calls it by name.

Definition at line 65 of file inventory.c.

Referenced by Inventory_GetQuantity().

◆ Inventory_Count()

s32 Inventory_Count ( s32 owner)

Counts filled inventory slots up to the first empty slot; the inventory is kept closed up, so this is how many items the unit carries.

Called by the shops before they add an item and to lay out their item grids.

Definition at line 82 of file inventory.c.

Referenced by Inventory_Count(), PartyInventory_CountFreeSlots(), PartyInventory_HasSpace(), and SolSanctumElementalStarRoom_GiveMythrilBags().

◆ PartyInventory_HasSpace()

s32 PartyInventory_HasSpace ( void )

Returns 1 when the selected character or any party member has a free inventory slot.

Called by the scenes that give an item (the Vault's Water of Life and the bones) and the debug item menus.

Definition at line 99 of file inventory.c.

Referenced by DebugMenu_SelectItem(), Event_MayorGivesWaterOfLife(), Event_OfferBones(), Event_OfferBones(), ItemLevel_SelectItem(), PartyInventory_HasSpace(), and Vault_FindBone().

◆ PartyInventory_CountFreeSlots()

s32 PartyInventory_CountFreeSlots ( void )

Returns the free inventory slots of the whole party.

Called by the Tolbi spring game and the lucky wheels to cap what the player can win.

Definition at line 122 of file inventory.c.

Referenced by PartyInventory_CountFreeSlots(), TolbiSpring_OfferLuckyWheels(), and TolbiSpring_RunSpringGame().

◆ Inventory_AddItem()

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.

A full matching stack fails immediately, even if another slot is free. Writes the inventory slot; returns it, or -1 when there was no room. Called by the shops, the new game set-up, the debug presets and PartyInventory_Add.

Definition at line 144 of file inventory.c.

Referenced by DebugMenu_GiveConsumableTestStock(), DebugMenu_GiveEquipmentTestStock(), DebugMenu_GiveTreasureTestStock(), GomaCaveEntrance_GiveShamansRod(), Inventory_AddAndEquip(), Inventory_AddItem(), LemurianShip_SetupScene(), Party_InitCharacters(), PartyInventory_Add(), Scene_GiveAndEquipItem(), SolSanctumElementalStarRoom_PresentStar(), and VenusLighthouseAerie_Initialize().

◆ PartyInventory_Add()

s32 PartyInventory_Add ( s32 itemId)

Gives the item to the first party member with room.

Returns who took it, or -1. Called for a battle's spoils, a chest or search in the field, and the scenes that give items.

Definition at line 189 of file inventory.c.

Referenced by DebugMenu_SelectItem(), ItemLevel_SelectItem(), PartyInventory_Add(), and SolSanctumElementalStarRoom_GiveMythrilBags().

◆ Inventory_Find()

s32 Inventory_Find ( s32 owner,
s32 itemId )

Returns the first slot holding itemId (any quantity, equipped or not), or -1.

Called by the shops and the scenes that check for an item.

Definition at line 212 of file inventory.c.

Referenced by Inventory_Find(), KalayTolbiDocks_TalkToGatekeeper(), KolimaForestTree_ReplaceInventoryItem(), MercuryLighthouse_ReplaceInventoryItem(), PartyInventory_Discard(), PartyInventory_FindOwner(), PartyInventory_Remove(), and SolSanctumElementalStarRoom_PresentStar().

◆ PartyInventory_FindOwner()

◆ Inventory_Equip()

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.

Psynergy items may coexist. Recomputes the unit's Psynergy and stats. Returns 0, -1 when the unit cannot equip it, or -2 when the item it would replace is cursed on. Called by the item menu, the shop's equip prompt, the new game set-up and the debug presets.

Definition at line 257 of file inventory.c.

Referenced by GomaCaveEntrance_GiveShamansRod(), Inventory_AddAndEquip(), Inventory_Equip(), Party_EndChildhood(), Party_InitCharacters(), and Scene_GiveAndEquipItem().

◆ Inventory_FindEquipped()

s32 Inventory_FindEquipped ( s32 owner,
s32 type )

Returns the slot of the equipped item of type, or -1.

Called by the shops to compare what is worn and to repair it, and by the battle sprites to draw the member's weapon.

Definition at line 296 of file inventory.c.

Referenced by Inventory_FindEquipped().

◆ Inventory_GetEquippedDefinition()

struct ItemDefinition * Inventory_GetEquippedDefinition ( struct BattleUnit * unit,
s32 type )

Returns the definition of the unit's equipped item of type, or NULL.

Nothing calls it by name.

Definition at line 315 of file inventory.c.

Referenced by Inventory_GetEquippedDefinition(), Item_GetEquippedElement(), and RollWeaponUnleash().

◆ Inventory_GetEquippedItem()

s32 Inventory_GetEquippedItem ( struct BattleUnit * unit,
s32 type )

Returns the id of the unit's equipped item of type, or 0.

Called by BattleObjMake to draw a member's weapon, and by the battle plan.

Definition at line 333 of file inventory.c.

Referenced by Inventory_GetEquippedItem().

◆ Inventory_Remove()

s32 Inventory_Remove ( s32 owner,
s32 slot )

Takes one item out of slot: a stack shrinks by one (returns 1), a last item empties the slot and the inventory closes up (returns 2).

Returns -1 for an empty slot. The unit's stats are recomputed either way. Called by using an item in the field or in battle, by the shops and by Inventory_Discard.

Definition at line 353 of file inventory.c.

Referenced by Inventory_Discard(), Inventory_Remove(), and PartyInventory_Remove().

◆ Inventory_Discard()

s32 Inventory_Discard ( s32 owner,
s32 slot )

Removes one item as Inventory_Remove does, and puts a rare item back into circulation (its counter goes up by one) for the shops to sell.

Called by selling an item and by the scenes that take an item away.

Definition at line 375 of file inventory.c.

Referenced by GomaCaveEntrance_GiveShamansRod(), Inventory_Discard(), KalayTolbiDocks_TalkToGatekeeper(), PartyInventory_Discard(), SolSanctumElementalStarRoom_GiveMythrilBags(), and SolSanctumElementalStarRoom_PresentStar().

◆ Inventory_CheckDiscard()

s32 Inventory_CheckDiscard ( s32 owner,
s32 slot )

Returns whether the item in slot may be dropped: 0 yes, -1 the slot is empty, -4 the item is indispensable, -3 it is equipped and cursed on.

Called by the shop's item picker before it lets an item go.

Definition at line 389 of file inventory.c.

Referenced by Inventory_CheckDiscard().

◆ PartyInventory_Remove()

s32 PartyInventory_Remove ( s32 itemId)

Removes one itemId from whoever carries it first; always returns 0.

Called by the scenes that use up a key item, the slot machine's Game Tickets and the field shortcut that uses an item.

Definition at line 410 of file inventory.c.

Referenced by CrossboneIslePlatformRooms_UseBlueKey(), Event_ConfrontSaturosAndMenardi(), Event_UseRedKey(), PartyInventory_Remove(), and TolbiSpring_RunSpringGame().

◆ PartyInventory_Discard()

s32 PartyInventory_Discard ( s32 itemId)

Discards one itemId from whoever carries it first, as Inventory_Discard does; always returns 0.

Called by the scenes that take an item back, such as the Vault dog's bone and the Black Orb.

Definition at line 422 of file inventory.c.

Referenced by Event_GiveBoneToDog(), Event_GiveBoneToDog(), Event_UseBlackOrb(), Fuchin_LightDragonWithEye(), PartyInventory_Discard(), SolSanctumElementalStarRoom_AlexTakesStars(), TolbiShipInteriors_ReturnLuckyAnchor(), and WorldMap_Initialize().

◆ Inventory_Break()

s32 Inventory_Break ( s32 owner,
s32 slot )

Marks the item in slot broken; returns -1 for an empty slot.

Called when a used item breaks, in battle or from the item menu.

Definition at line 433 of file inventory.c.

Referenced by Inventory_Break().

◆ Inventory_Repair()

s32 Inventory_Repair ( s32 owner,
s32 slot )

Clears the broken mark of the item in slot; returns -1 for an empty slot.

Called by the shop's repair.

Definition at line 444 of file inventory.c.

Referenced by Inventory_Repair().

◆ Item_GetTargetMode()

u8 Item_GetTargetMode ( s32 itemId)

Returns how the action an item performs when used picks its targets.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 455 of file inventory.c.

Referenced by Item_GetTargetMode().

◆ ItemCounter_Adjust()

s32 ItemCounter_Adjust ( s32 index,
s32 delta )

Adds delta to rare item counter index, kept between 0 and 99, and returns the new count (0 for an index past 127).

Definition at line 461 of file inventory.c.

Referenced by Item_AdjustCounter(), and ItemCounter_Adjust().

◆ Item_AdjustCounter()

s32 Item_AdjustCounter ( s32 itemId,
s32 delta )

Adds delta to the counter of a rare item; ordinary items have none.

Returns the new count, or 0. The counters are how many of each rare item the shops may sell: buying one takes one, discarding or selling puts one back.

Definition at line 488 of file inventory.c.

Referenced by CommandTable_ConfigureCommandList(), Inventory_Discard(), and Item_AdjustCounter().

◆ Inventory_CountItem()

s32 Inventory_CountItem ( s32 owner,
s32 itemId )

Counts matching nonstackable items, or the quantity in the first matching stack.

Called by PartyInventory_CountItem and by the events that give an item, to keep stacks under their limit.

Definition at line 503 of file inventory.c.

Referenced by Inventory_CountItem(), and PartyInventory_CountItem().

◆ PartyInventory_CountItem()

s32 PartyInventory_CountItem ( s32 itemId)

Counts itemId across the party.

Called by the slot machine (Game Tickets) and the Tolbi spring game.

Definition at line 526 of file inventory.c.

Referenced by PartyInventory_CountItem(), TolbiSpring_OfferLuckyWheels(), and TolbiSpring_RunSpringGame().

◆ BattleAction_GetDirect()

struct BattleAct * BattleAction_GetDirect ( s32 actionId)

Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.

Reached through GAME.S as BattleActGet, which every bank uses to read an ability.

Definition at line 10 of file levels.c.

Referenced by BattleAction_GetDirect(), and Item_GetTargetMode().

◆ Unit_KnowsAction()

s32 Unit_KnowsAction ( s32 owner,
s32 actionId )

Returns 1 when actionId is in the unit's action list.

Called by the events that check whether a member knows a Psynergy (Event_ValidatePackedId).

Definition at line 29 of file levels.c.

Referenced by Unit_KnowsAction().

◆ Unit_RefreshPsynergy()

s32 Unit_RefreshPsynergy ( s32 owner)

Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list, adds every class action learned by its level and the action of each equipped item that grants one, and closes it up again.

Writes only the unit's actionSlots; enemies (class 0) are left alone. Called whenever the class, level or equipment changes: Inventory_Equip, Unit_UpdateClass, Owner_LevelUp, Unit_LearnPsynergy and the item menu.

Definition at line 68 of file levels.c.

Referenced by Inventory_Equip(), Owner_LevelUp(), Unit_LearnPsynergy(), Unit_RefreshPsynergy(), and Unit_UpdateClass().

◆ Unit_LearnPsynergy()

s32 Unit_LearnPsynergy ( s32 stateIndex,
s32 value )

Teaches a character action value for good (or makes a class action permanent by clearing its marks), then rebuilds its list.

Returns the action's place in the list, or -1 when the list is full. Called by the events that teach Psynergy, the prologue's end, the debug presets and the debug shortcut menu.

Definition at line 188 of file levels.c.

Referenced by Party_EndChildhood(), and Unit_LearnPsynergy().

◆ Unit_CheckLevelUp()

struct LevelUpResult * Unit_CheckLevelUp ( s32 owner,
struct LevelUpResult * gains )

Levels the character up once if it has the experience.

Returns gains filled with the gains, or NULL. Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 235 of file levels.c.

Referenced by Unit_CheckLevelUp().

◆ Character_GetDefinition()

struct CharacterDefinition * Character_GetDefinition ( s32 index)

Returns character index's definition: growth curves, starting level and equipment.

Definition at line 242 of file levels.c.

Referenced by Character_GetDefinition(), Owner_LevelUp(), Party_InitCharacters(), and Unit_GetElementLevels().

◆ Party_InitCharacters()

void Party_InitCharacters ( void )

Sets up all eight characters for a new game: names from the message table, starting equipment equipped, class and elements worked out, and levels raised to their starting level.

Called by GameState_InitDefaults.

Definition at line 252 of file levels.c.

Referenced by GameState_InitDefaults(), and Party_InitCharacters().

◆ Owner_LevelNoOp()

void Owner_LevelNoOp ( void )

Unused reserved entry; keeps its place in the far-call table.

Definition at line 309 of file levels.c.

Referenced by Owner_LevelNoOp().

◆ Unit_GetExperienceForLevel()

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 level above 99.

Called by the levelling code and by the two status screens to show the experience to the next level.

Definition at line 314 of file levels.c.

Referenced by Owner_LevelUp(), Unit_GetExperienceForLevel(), and Unit_TryLevelUp().

◆ Owner_LevelUp()

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 of its growth curve around the new level (one point every 20 levels), a twentieth of it per level with a random part.

Writes the unit's level, base stats and, if short, its experience, then rebuilds its Psynergy and stats. The gains go to gains, which is returned.

Definition at line 334 of file levels.c.

Referenced by Owner_LevelUp(), Unit_LevelUpTo(), and Unit_TryLevelUp().

◆ Unit_TryLevelUp()

struct LevelUpResult * Unit_TryLevelUp ( s32 owner,
struct LevelUpResult * gains )

Levels the character up once if its experience reaches the next level.

Returns gains filled with the gains, or NULL. Called after a battle by Battle_AwardSpoils, once for each level a member reaches.

Definition at line 414 of file levels.c.

Referenced by Unit_CheckLevelUp(), and Unit_TryLevelUp().

◆ Unit_LevelUpTo()

void Unit_LevelUpTo ( s32 owner,
s32 targetLevel )

Levels character owner up one level at a time until targetLevel, then recomputes its stats.

Called by Party_InitCharacters for the starting levels, and by the debug menus and presets.

Definition at line 429 of file levels.c.

Referenced by CommandTable_ConfigureCommandList(), DebugMenu_RaisePartyLevels(), ItemLevel_AdjustOwnerLevel(), Party_InitCharacters(), and Unit_LevelUpTo().

◆ GameFlag_Test()

s32 GameFlag_Test ( s32 flag)

Returns 1 when flag is set.

Every bank tests flags through it, as GameFlag_TestFar, and the scenes through the event layer.

Definition at line 13 of file flags.c.

Referenced by Class_Determine(), Djinn_AddToLeastLoadedOwner(), GameFlag_Test(), Party_CountActiveOwners(), Party_RestorePpOfLitElements(), and UnitCalc().

◆ GameFlag_SetBit()

s32 GameFlag_SetBit ( s32 flag)

Sets flag and returns its byte number.

Called from every bank, as GameFlag_SetBitFar, and by the scenes through the event layer.

Definition at line 27 of file flags.c.

Referenced by Djinn_AddToLeastLoadedOwner(), GameFlag_RefreshLureCap(), GameFlag_SetBit(), InventorySnapshot_Save(), Party_AddActiveOwner(), Party_BeginChildhood(), and Party_EndChildhood().

◆ GameFlag_ClearBit()

void GameFlag_ClearBit ( s32 flag)

Clears flag.

Called from every bank, as GameFlag_ClearBitFar, and by the scenes through the event layer.

Definition at line 40 of file flags.c.

Referenced by GameFlag_ClearBit(), GameFlag_RefreshLureCap(), InventorySnapshot_Restore(), Party_EndChildhood(), Party_RemoveActiveOwner(), and SaveMenu_Run().

◆ GameFlag_Toggle()

u32 GameFlag_Toggle ( s32 flag)

Flips flag and returns its new value.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 52 of file flags.c.

Referenced by GameFlag_Toggle().

◆ GameFlag_GetByte()

s32 GameFlag_GetByte ( s32 flag)

Returns the whole byte flag is in, a counter kept among the flags.

Called by the battle encounter code and, through FieldGameFlag_GetByte, by the Colosso scenes and the Battle Arena.

Definition at line 68 of file flags.c.

Referenced by FieldGameFlag_GetByte(), and GameFlag_GetByte().

◆ GameFlag_SetByte()

void GameFlag_SetByte ( s32 flag,
s32 value )

Sets the whole byte flag is in.

Reached through FieldGameFlag_SetByte by the Colosso scenes, the world map and the Battle Arena's win counts.

Definition at line 78 of file flags.c.

Referenced by FieldGameFlag_SetByte(), and GameFlag_SetByte().

◆ GameFlag_IncrementByte()

u8 GameFlag_IncrementByte ( s32 flag)

Adds 1 to the byte flag is in, stopping at 255, and returns it.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 86 of file flags.c.

Referenced by GameFlag_IncrementByte().

◆ GameFlag_DecrementByte()

u8 GameFlag_DecrementByte ( s32 flag)

Takes 1 from the byte flag is in, stopping at 0, and returns it.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 99 of file flags.c.

Referenced by GameFlag_DecrementByte().

◆ GameFlag_GetNibble()

s32 GameFlag_GetNibble ( u32 flag)

Returns the four bits flag is in (bit 2 of the number picks the half).

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 112 of file flags.c.

Referenced by GameFlag_GetNibble().

◆ GameFlag_SetNibble()

void GameFlag_SetNibble ( s32 flag,
s32 value )

Sets the four bits flag is in.

Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 128 of file flags.c.

Referenced by GameFlag_SetNibble().

◆ BattleUnitSet()

s32 BattleUnitSet ( s32 unitId,
s32 enemyId,
s32 suffix )

Fills battle unit unitId (0x80 to 0x86) with enemy enemyId: stats, name with its suffix letter, the items it carries, rewards and elements.

Enemies 158 to 171 fight on the party's side. Returns 0 for an id out of range. Called by the battle set-up (Battle_RunEncounter, BattleFormation_BuildEnemyList) and by BattleTargetExec when an enemy calls for help. XXX: which enemies 158 to 171 are, and when they join the party's side, is unknown; the encounter tables that place them would say.

Definition at line 25 of file party.c.

Referenced by BattleUnitSet().

◆ Party_CountActiveOwners()

◆ Party_AddActiveOwner()

s32 Party_AddActiveOwner ( s32 owner)

Adds character owner to the end of the party: sets its game flag and appends it to gGameState.activeOwners unless it is already listed.

Returns the party size. Called by the scenes where a character joins, by the member chooser and the file select screen, and by the debug presets.

Definition at line 135 of file party.c.

Referenced by BabiPalace_RestorePartyAndInventory(), ColosseumEntrance_ApplyArrivalState(), ColosseumEntrance_EscortToEastExit(), ColosseumEntrance_EscortToWestExit(), Colosso_ControlCharacterAlone(), Colosso_OfferCheeringSpot(), CommandTable_ConfigureCommandList(), GameState_InitDefaults(), Party_AddActiveOwner(), and SaveMenu_Run().

◆ Party_RemoveActiveOwner()

s32 Party_RemoveActiveOwner ( s32 owner)

Takes character owner out of the party: clears its game flag and closes the gap it leaves in gGameState.activeOwners.

Returns the party size. Called by the scenes where a character leaves, by the member chooser and the file select screen, and by the debug presets.

Definition at line 154 of file party.c.

Referenced by ColosseumEntrance_EscortToEastExit(), ColosseumEntrance_EscortToWestExit(), Colosso_ControlCharacterAlone(), Colosso_OfferCheeringSpot(), CommandTable_ConfigureCommandList(), Party_RemoveActiveOwner(), and SaveMenu_Run().

◆ Party_ListActiveOwners()

s32 Party_ListActiveOwners ( s16 * owners)

Writes the party members to owners, ending with 0xff, and returns how many there are.

Every screen that lists the party starts here: the menus, the shops, the inn and the party inventory searches.

Definition at line 173 of file party.c.

Referenced by FieldParty_ListActiveOwners(), Party_ListActiveOwners(), Party_SumDjinnCounts(), PartyInventory_Add(), PartyInventory_CountFreeSlots(), PartyInventory_CountItem(), PartyInventory_FindOwner(), and PartyInventory_HasSpace().

◆ Party_AdjustCoins()

s32 Party_AdjustCoins ( s32 amount)

Adds amount to the party's coins, kept between 0 and 999999, and returns the new total.

Called by the shops, the inn and the sanctum to charge, by the battle spoils to pay, and by the Lucky Dice game.

Definition at line 195 of file party.c.

Referenced by KalayTolbiDocks_TalkToTicketSeller(), Party_AdjustCoins(), and TolbiSpring_RunSpringGame().

◆ Summon_ListLearned()

s32 Summon_ListLearned ( u8 * output)

Writes the summons whose bit is set in the first word of the party's Djinn table to output, in menu order, ending with 32.

Returns how many. Called by SummonMenu_SelectSummon to list the battle's Summon command.

Definition at line 246 of file party.c.

Referenced by Summon_ListLearned().

◆ SummonDefinition_GetNear()

const struct SummonDefinition * SummonDefinition_GetNear ( u32 summonId)

Returns summon summonId's definition, or NULL past the sixteenth.

Reached only through GAME.S, as SummonDefinition_Get.

Definition at line 265 of file party.c.

Referenced by SummonDefinition_GetNear().

◆ Class_GetSeries()

s32 Class_GetSeries ( s32 primaryElement,
s32 secondaryElement )

Returns the class series of a character whose strongest element is primaryElement and second secondaryElement, from the 4 by 4 table.

Called by Class_Determine.

Definition at line 18 of file classes.c.

Referenced by Class_Determine(), and Class_GetSeries().

◆ Unit_GetElementLevels()

s32 Unit_GetElementLevels ( s32 record,
const u8 * source,
s32 output[4] )

Writes ten times each element level to output: an enemy's from its element preset, a character's from the Djinn set on it (source is its Djinn bits) plus its own element bonus.

Called by Class_Determine, Unit_GetElementLevel and Unit_CalcBaseElements.

Definition at line 26 of file classes.c.

Referenced by Class_Determine(), Unit_CalcBaseElements(), Unit_GetElementLevel(), and Unit_GetElementLevels().

◆ Unit_GetElementLevel()

s32 Unit_GetElementLevel ( s32 owner,
s32 element )

Returns a unit's level in element (0 to 3).

Called by the two status screens to show the element levels, and by Battle_IsReviveEffect.

Definition at line 67 of file classes.c.

Referenced by BattleFx_RollSuccess(), and Unit_GetElementLevel().

◆ Enemy_GetAttackElement()

s32 Enemy_GetAttackElement ( struct BattleUnit * unit)

Returns the element an enemy attacks with, from its element preset.

Called by Item_GetEquippedElement for an enemy, which has no weapon.

Definition at line 82 of file classes.c.

Referenced by Enemy_GetAttackElement(), and Item_GetEquippedElement().

◆ Unit_CalcBaseElements()

u32 Unit_CalcBaseElements ( s32 owner,
s16 destination[4][2] )

Definition at line 101 of file classes.c.

Referenced by BattleUnitSet(), Unit_CalcBaseElements(), and Unit_UpdateClass().

◆ Class_Determine()

s32 Class_Determine ( s32 character,
const u8 * djinn )

Returns the class a character has with djinn set: the series is chosen by its two strongest elements, and the class is the last of the series whose element requirements it meets.

Isaac and Garet as children and Jenna have fixed classes. Called by Unit_UpdateClass.

Definition at line 161 of file classes.c.

Referenced by Class_Determine(), and Unit_UpdateClass().

◆ Class_GetDefinition()

struct ClassDefinition * Class_GetDefinition ( s32 classId)

Returns class classId's definition: its series, element requirements, stat multipliers and the Psynergy it teaches by level.

Definition at line 223 of file classes.c.

Referenced by BattleTarget_IsWeakToEffect(), Class_GetDefinition(), Unit_RefreshPsynergy(), and UnitCalc().

◆ Unit_UpdateClass()

void Unit_UpdateClass ( s32 ownerId)

Works out a character's class again after its Djinn change, then its Psynergy list and its base elements.

Writes the unit's classIndex, actionSlots and baseElement. Called when a Djinni is set or put on standby, at the prologue's start and end, at a new game and around the Colosso's inventory snapshot.

Definition at line 232 of file classes.c.

Referenced by Djinn_Activate(), Djinn_Deactivate(), InventorySnapshot_Restore(), InventorySnapshot_Save(), Party_BeginChildhood(), Party_EndChildhood(), Party_InitCharacters(), and Unit_UpdateClass().

◆ Battle_GetElementMultiplier()

s32 Battle_GetElementMultiplier ( s32 input,
s32 halve )

Returns the multiplier (256 = 1x) for an element difference input, read from a five-point line (gElement_PowerResistCurve); with halve the effect of the difference is half.

Called by the damage and recovery formulas below.

Definition at line 11 of file battle_calc.c.

Referenced by Battle_CalcAttackDamage(), Battle_CalcPsynergyPower(), Battle_CalcRecovery(), and Battle_GetElementMultiplier().

◆ BattleRandom()

s32 BattleRandom ( void )

The battle's random number generator, the same linear congruential one as Random16 with its own seed.

Returns bits 8 to 23 of the new seed and writes gBattleRandomSeed. Rolls that use it advance independently of Random16; link battles exchange this seed before resolving the round.

Definition at line 56 of file battle_calc.c.

Referenced by BattleRandom(), BattleRandomPercent(), and RollWeaponUnleash().

◆ BattleRandomPercent()

u32 BattleRandomPercent ( void )

Returns a battle random number from 0 to 99.

Definition at line 65 of file battle_calc.c.

Referenced by BattleFx_RollSuccess(), and BattleRandomPercent().

◆ Battle_CalcAttackDamage()

s32 Battle_CalcAttackDamage ( s32 attack,
s32 defense,
s32 addedPower,
s32 elementDifference )

Scales max(attack - defense, 0) + twice the action's added power by the elemental multiplier, then halves it.

elementDifference is power minus resistance; its effect here is half Psynergy's (128..384 with 256 = 1x). Reached through GAME.S as BattleAtkCalc, which BattleTargetExec calls for attacks and physical abilities.

Definition at line 72 of file battle_calc.c.

Referenced by Battle_CalcAttackDamage().

◆ Battle_CalcPsynergyPower()

s32 Battle_CalcPsynergyPower ( s32 power,
s32 elementDifference,
s32 powerMultiplier )

Returns the power of Psynergy: power times the multiplier for the element difference (power minus resistance, 0..512 with 256 = 1x) and the supplied powerMultiplier (also 256 = 1x).

Reached through GAME.S as BattlePowerCalc, which BattleTargetExec calls for Psynergy damage.

Definition at line 95 of file battle_calc.c.

Referenced by Battle_CalcPsynergyPower().

◆ Battle_CalcRecovery()

s32 Battle_CalcRecovery ( s32 power,
s32 elementPower,
s32 powerMultiplier )

Returns the amount healed: power and powerMultiplier (256 is 1x) times the multiplier for twice the healer's element power above 100.

elementPower : the healer's power in the element (100 is 1x) Reached through GAME.S as BattleRecoveryCalc, which the battle and the menu's healing use.

Definition at line 111 of file battle_calc.c.

Referenced by Battle_CalcRecovery().

◆ Item_GetEquippedElement()

s32 Item_GetEquippedElement ( s32 owner)

Returns the element the unit attacks with (ELEMENT_NONE for none): an enemy's comes from its kind, a character's from its equipped weapon.

Called by the battle plan for an attack's element.

Definition at line 127 of file battle_calc.c.

Referenced by Item_GetEquippedElement().

◆ Equipment_GetUnleashRateBonus()

s32 Equipment_GetUnleashRateBonus ( struct BattleUnit * unit)

Returns the unleash chance, in percent, that a unit's equipment adds (ITEM_EFFECT_ADD_UNLEASH_CHANCE).

Called by RollWeaponUnleash and the battle plan.

Definition at line 143 of file battle_calc.c.

Referenced by Equipment_GetUnleashRateBonus(), and RollWeaponUnleash().

◆ RollWeaponUnleash()

s32 RollWeaponUnleash ( struct BattleUnit * owner)

Rolls whether a character's weapon unleashes: its chance is the weapon's unleashChance times 5 percent plus what the equipment adds.

Returns the unleash action, or 1 for a plain attack. Called by the battle plan for each Attack command.

Definition at line 168 of file battle_calc.c.

Referenced by RollWeaponUnleash().

◆ BattleFx_GetBaseSuccessRate()

s32 BattleFx_GetBaseSuccessRate ( s32 effectId)

Returns the base chance, in percent, of effect effectId.

A negative value is a fixed chance that elements and luck do not change; effects not listed always work (-100). Called by BattleFx_RollSuccess.

Definition at line 194 of file battle_calc.c.

Referenced by BattleFx_GetBaseSuccessRate(), and BattleFx_RollSuccess().

◆ BattleTarget_IsWeakToEffect()

s32 BattleTarget_IsWeakToEffect ( const struct BattleUnit * target,
s32 effectId )

Returns 1 when the unit is weak to effect effectId: one of three listed for its enemy kind (EnemyDefinition.unk48) or class (ClassDefinition.unk50).

Called by BattleFx_RollSuccess.

Definition at line 250 of file battle_calc.c.

Referenced by BattleFx_RollSuccess(), and BattleTarget_IsWeakToEffect().

◆ Battle_IsReviveEffect()

s32 Battle_IsReviveEffect ( s32 effectId)

Returns 1 for the revive effects (Revive, Quartz, Dew), which only work on a downed unit.

Called by the battle's targeting, which lets them aim at downed members, and by BattleFx_RollSuccess.

Definition at line 274 of file battle_calc.c.

Referenced by Battle_IsReviveEffect(), and BattleFx_RollSuccess().

◆ BattleFx_RollSuccess()

s32 BattleFx_RollSuccess ( s32 caster,
s32 target,
s32 resistanceCategory,
s32 effectId,
s32 successScale )

Rolls whether effect effectId takes hold on target: it fails at once when there is nothing for it to do.

The chance is the base rate, plus three times the caster's lead over the target in the element, less half the target's luck, plus 25 against a weakness, times successScale percent. Luff gets three tries. Reached through GAME.S as BattleHitCheck, which BattleTargetExec and the battle plan call for each target of an ability with an effect.

Definition at line 290 of file battle_calc.c.

Referenced by BattleFx_RollSuccess().

◆ Djinn_GetDefinition()

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 gives the first.

Called by UnitCalc for a set Djinni's stat bonuses and by Djinn_GetAbilityId.

Definition at line 10 of file djinn.c.

Referenced by Djinn_GetAbilityId(), Djinn_GetDefinition(), and UnitCalc().

◆ Djinn_AddToLeastLoadedOwner()

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, puts it on standby and sets its found flag.

Returns who got it, -1 if it was found before or -2 when nobody has room. Called by Djinn_JoinParty when a Djinni joins in the field.

Definition at line 24 of file djinn.c.

Referenced by Djinn_AddToLeastLoadedOwner().

◆ Djinn_AddToOwner()

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.

Returns -1 when the unit holds ten of the element or has it already. Called by Djinn_AddToLeastLoadedOwner and Djinn_Transfer, by the scenes where a member joins with Djinn, and by the debug menus.

Definition at line 65 of file djinn.c.

Referenced by DebugMenu_GivePartyDjinn(), Djinn_AddToLeastLoadedOwner(), Djinn_AddToOwner(), Djinn_Transfer(), Event_MeetFlint(), and MercuryLighthouse_MiaJoinsAfterRescue().

◆ Djinn_IsReady()

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, not recovering and not held by a summon.

A count of set Djinn above 9 is clamped to 10 on the way. Called by the Djinn menu to list what can be set, and by battle to tell which Djinn can be unleashed.

Definition at line 81 of file djinn.c.

Referenced by Djinn_Activate(), and Djinn_IsReady().

◆ Djinn_IsActive()

u32 Djinn_IsActive ( s32 owner,
s32 element,
s32 djinnIndex )

Returns 1 when the Djinni is set on the unit.

Definition at line 116 of file djinn.c.

Referenced by Djinn_Deactivate(), Djinn_IsActive(), and Djinn_Transfer().

◆ Djinn_Activate()

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.

Returns 1 when it was set. Called by the Djinn menu, by battle when a Djinni recovers, and by Djinn_Transfer.

Definition at line 125 of file djinn.c.

Referenced by DebugMenu_GivePartyDjinn(), Djinn_Activate(), Djinn_Transfer(), and MercuryLighthouse_MiaJoinsAfterRescue().

◆ Djinn_Deactivate()

u32 Djinn_Deactivate ( s32 owner,
s32 element,
s32 djinnIndex )

Takes a set Djinni off the unit and works out its class again.

Returns 1 when it was set. Called by the Djinn menu, by battle when a Djinni is unleashed, and by Djinn_Transfer.

Definition at line 144 of file djinn.c.

Referenced by Djinn_Deactivate(), and Djinn_Transfer().

◆ DjinnRecovery_Remove()

s32 DjinnRecovery_Remove ( s32 owner,
s32 element,
s32 djinnIndex )

Takes the Djinni off its side's standby and recovery list, closing the gap.

Returns 1 when it was there. Called when a Djinni is set again, by the Djinn menu and by battle's recovery.

Definition at line 159 of file djinn.c.

Referenced by Djinn_Transfer(), DjinnRecovery_AddStandby(), and DjinnRecovery_Remove().

◆ DjinnRecovery_AddStandby()

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 was already listed.

Returns the list's count. Called when a Djinni joins, by the Djinn menu's standby command, by battle and by the scene where Flint joins.

Definition at line 185 of file djinn.c.

Referenced by Djinn_AddToLeastLoadedOwner(), Djinn_Transfer(), DjinnRecovery_AddStandby(), and Event_MeetFlint().

◆ Djinn_Transfer()

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.

Returns -1 when the source lacks it or the target has no room. Called by the Djinn menu's Give and Trade.

Definition at line 204 of file djinn.c.

Referenced by Djinn_Transfer(), and Vault_ReturnIsaacsDjinni().

◆ DjinnRecovery_CountStandby()

s32 DjinnRecovery_CountStandby ( u8 * counts)

Counts the party's Djinn on standby, by element into counts when it is given.

Returns the total. Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 230 of file djinn.c.

Referenced by DjinnRecovery_CountStandby().

◆ Djinn_GetAbilityId()

s32 Djinn_GetAbilityId ( u32 group,
u32 index )

Returns the ability ID used when the Djinni is unleashed.

Called by the battle plan, the battle queue's ordering and the battle menu.

Definition at line 264 of file djinn.c.

Referenced by Djinn_GetAbilityId().

◆ Party_SumDjinnCounts()

s32 Party_SumDjinnCounts ( s32 element)

Returns how many Djinn of element the party holds, or of all elements for -1.

Called by the save summary, the field Status screen, the battle status screen and the battle command menu.

Definition at line 271 of file djinn.c.

Referenced by Party_SumDjinnCounts().

◆ Inventory_AddAndEquip()

void Inventory_AddAndEquip ( s32 owner,
s32 itemId )

Gives a unit itemId and equips every exactly matching inventory entry.

Called by InventorySnapshot_Save to arm Isaac for the Colosso.

Definition at line 9 of file snapshot.c.

Referenced by Inventory_AddAndEquip(), and InventorySnapshot_Save().

◆ InventorySnapshot_Save()

void InventorySnapshot_Save ( void )

Saves the first four characters' inventories, shortcuts and party order, then keeps only the Psynergy-granting items, gives Isaac the Short Sword, sets FLAG_INVENTORY_SNAPSHOT and restores everyone's HP and PP.

Nothing happens when a snapshot is already saved, apart from the restore. Called by the Colosseum entrance scene as Isaac enters the Colosso.

Definition at line 33 of file snapshot.c.

Referenced by InventorySnapshot_Save().

◆ InventorySnapshot_Restore()

void InventorySnapshot_Restore ( void )

Gives back the inventories, shortcuts and party order InventorySnapshot_Save put aside, then clears the snapshot and FLAG_INVENTORY_SNAPSHOT.

Called by the Babi palace scene after the Colosso, and by the file select screen.

Definition at line 82 of file snapshot.c.

Referenced by InventorySnapshot_Restore(), and SaveMenu_Run().