The party's units and their stats, a new game, the prologue, HP and PP. More...
Go to the source code of this file.
Data Structures | |
| struct | StatWork |
| The running totals UnitCalc builds a unit's stats in, in a block of the alternate pool that it frees at the end. More... | |
| struct | SceneStateTail |
| The end of the scene state that a new game sets up. More... | |
Macros | |
| #define | UNIT_STAT_DIFF(a, b) |
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. | |
| UNUSED 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. | |
| static s32 | Unit_ClampGaugeValue (s32 value, s32 maximum) |
| Clamps a new HP or PP value to 0 and the maximum. | |
| 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. | |
The party's units and their stats, a new game, the prologue, HP and PP.
Part of game.c, the game object, compiled only through it.
Definition in file units.c.
| #define UNIT_STAT_DIFF | ( | a, | |
| b ) |
Definition at line 28 of file units.c.
Referenced by UnitCalc().
| 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().
| 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().
| 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().
| 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().
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().
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().
| 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().
| 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().
| 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().
| 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().
| 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().
| 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().
| 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().
| 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().
| UNUSED 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().
| 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().
Clamps a new HP or PP value to 0 and the maximum.
Definition at line 734 of file units.c.
Referenced by Unit_AddHp(), Unit_AddPp(), Unit_ClampGaugeValue(), Unit_SetHp(), and Unit_SetPp().
| 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().
| 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().
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().
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().