Skip to Content
The Alchemy Project

include/game/game_functions.h

The game module's functions, declared once each in the order of its stub table (src/game/stubs.s). More…

Included by game.h.

Functions

NameDescription
struct DJINN_RECOVERY_TABLE *gmDjinnGetRecoveryTable (Sint32 enemySide)The game module's functions in the order of its stub table (src/game/stubs.s).
struct UNIT *gmUnitGet (Uint32 unitId)Returns the unit of unitId: ISAAC to PIERS the characters, the six from FIRST_ENEMY_UNIT the enemies of the current battle; NULL for anything else.
voidgmUnitCalculate (Sint32 unitId)Works out a unit's stats from its base stats, equipment, set Djinn, class and battle stat levels; its HP and PP keep their share of a new maximum.
const struct ITEM_DEFINITION *gmItemGetDefinition (Sint32 item)Returns an item's definition; an inventory entry's other bits are ignored.
Sint32gmInventoryGetQuantity (Sint32 unitId, Sint32 slot)Returns how many of the item in slot the unit carries (0 for an empty slot).
Sint32gmInventoryAddItem (Sint32 unitId, Sint32 itemId)Gives a unit one item, joining its first matching stack (up to INVENTORY_STACK_MAX) or taking the first free slot, and returns the slot, or -1.
Sint32gmPartyInventoryAdd (Sint32 itemId)Gives the item to the first party member with room.
Sint32gmInventoryFind (Sint32 unitId, Sint32 itemId)Returns the first slot holding itemId (any quantity, equipped or not), or -1.
Sint32gmPartyInventoryFindMember (Sint32 itemId)Returns who carries itemId, asking the leader first, or -1.
Sint32gmPartyInventoryRemove (Sint32 itemId)Removes one itemId from whoever carries it first; always returns 0.
Sint32gmInventoryEquip (Sint32 unitId, Sint32 slot)Equips the item in slot, clearing the equipped bit of the item of the same type it replaces; any number of Psynergy items may be equipped.
Sint32gmInventoryRemove (Sint32 unitId, Sint32 slot)Takes one item out of slot, closing up the inventory when it was the last.
Sint32gmInventoryBreak (Sint32 unitId, Sint32 slot)Marks the item in slot broken; returns -1 for an empty slot.
Sint32gmInventoryRepair (Sint32 unitId, Sint32 slot)Clears the broken mark of the item in slot; returns -1 for an empty slot.
Uint8gmItemGetTargetMode (Sint32 itemId)Unused: returns how the ability an item uses picks its targets.
Sint32gmInventoryGetEquippedItem (struct UNIT *unit, Sint32 type)Returns the id of the unit's equipped item of type, or 0.
struct ABILITY_DEFINITION *gmAbilityGetDefinition (Sint32 abilityId)Returns the definition of ability abilityId (its low 14 bits); an id past the table gives the first.
Sint32gmUnitLearnPsynergy (Sint32 unitId, Sint32 abilityId)Teaches a character abilityId for good (or makes a class action permanent by clearing its marks), then rebuilds its list.
BoolgmUnitKnowsPsynergy (Sint32 unitId, Sint32 abilityId)Returns 1 when abilityId is in the unit's Psynergy list.
voidgmMainRoutineStateInitDefaults (void)Clears the game's state and sets a new game's defaults: Isaac alone in the party, the standard buttons, the message speed and the odds of the Lucky Medals fountain.
struct LEVEL_UP_RESULT *gmUnitCheckLevelUp (Sint32 unitId, struct LEVEL_UP_RESULT *gains)Levels the character up once if it has the experience, and returns gains, or NULL.
voidgmPartyInitCharacters (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.
voidgmUnitLevelNoOperation (void)Unused: reserved entry; keeps its place in the stub table.
struct LEVEL_UP_RESULT *gmUnitTryLevelUp (Sint32 unitId, struct LEVEL_UP_RESULT *gains)Levels the character up once if its experience reaches the next level, and returns gains, or NULL.
BoolgmFlagGet (Sint32 flag)Returns 1 when flags is set.
Sint32gmFlagSet (Sint32 flag)Sets flags and returns its byte number.
voidgmFlagClear (Sint32 flag)Clears flags.
Uint32gmFlagToggle (Sint32 flag)Flips flags and returns its new value.
Sint32gmFlagGetByte (Sint32 flag)Returns the whole byte flags is in, a counter kept among the flags.
voidgmFlagSetByte (Sint32 flag, Sint32 value)Sets the whole byte flags is in.
Uint8gmFlagIncrementByte (Sint32 flag)Adds 1 to the byte flags is in, stopping at GAME_FLAG_BYTE_MAX, and returns it.
Uint8gmFlagDecrementByte (Sint32 flag)Takes 1 from the byte flags is in, stopping at 0, and returns it.
Sint32gmFlagGetNibble (Uint32 flag)Returns the four bits a flag is in, 0 to 15.
voidgmFlagSetNibble (Sint32 flag, Sint32 value)Sets the four bits flags is in.
voidgmRestartQuest (void)Starts a new game: clears the main routine's state and restarts at the opening.
Sint32gmUnitAddHp (Sint32 unitId, Sint32 delta)Adds delta to unit unitId's HP, kept from 0 to its maximum, and returns the new HP.
Sint16gmUnitAddPp (Sint32 unitId, Sint32 delta)Adds delta to unit unitId's PP, kept from 0 to its maximum, and returns the new PP.
voidgmUnitRecalculateGauges (Sint32 unitId)Recomputes the HP and PP gauges of unitId from its current HP and PP, so that gmUnitCalculate keeps the same fractions.
voidgmUnitSetHp (struct UNIT *unit, Sint32 value)
voidgmUnitSetPp (struct UNIT *unit, Sint32 value)
BoolgmBattleUnitSet (Sint32 unitId, Sint32 enemyId, Sint32 suffix)Fills a battle unit with an enemy: its stats, its name with its letter, its items, rewards and elements.
Sint32gmPartyCountMembers (void)Returns the number of party members, counted from its FLAG_IN_PARTY flags.
Sint32gmPartyAddMember (Sint32 unitId)Adds a character to the end of the party unless it is there already, and returns the party size.
Sint32gmPartyListMembers (Sint16 *unitIds)Writes the party members to unitIds and returns how many there are.
Sint32gmEquipmentRollUnleash (struct UNIT *unit)Rolls whether a character's weapon unleashes, 5 percent a point of its chance.
Sint32gmPartyRemoveMember (Sint32 unitId)Takes character unitId out of the party: clears its game flag and closes the gap it leaves in MainRoutineStateWork.party.
Sint32gmUnitGetAttackElement (Sint32 unitId)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.
Sint32gmBattleRollEffectSuccess (Sint32 caster, Sint32 target, Sint32 element, Sint32 effectId, Sint32 successScale)Rolls whether an effect takes hold on target: the base rate, plus three points for each level the caster's element is above the target's and less three for every two points of the target's luck, plus WEAKNESS_BONUS against a weakness, all times successScale percent.
Sint32gmBattleCalculateAttackDamage (Sint32 attack, Sint32 defense, Sint32 addedPower, Sint32 elementDifference)Scales max(attack - defense, 0) plus twice the added power by half the element multiplier, then halves it.
Sint32gmBattleCalculatePsynergyPower (Sint32 power, Sint32 elementDifference, Sint32 powerMultiplier)Returns Psynergy's power times the element multiplier and powerMultiplier.
Sint32gmBattleCalculateRecovery (Sint32 power, Sint32 elementPower, Sint32 powerMultiplier)Returns the amount healed: power times powerMultiplier and the multiplier for the healer's element power above HEALING_BASE_POWER.
const struct ENEMY_DEFINITION *gmEnemyGetDefinition (Sint32 enemyId)Returns the definition of enemy enemyId; enemy ids start past the eight characters', so that one id names any unit.
Sint32gmBattleRandom (void)The battle's random number generator, the same as syRandom with its own seed, which link battles exchange.
Sint32gmDjinnGive (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Gives a Djinni to a unit.
Sint32gmDjinnSet (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Sets a ready Djinni on the unit, counts it and works out the unit's class again.
Uint32gmDjinnPutOnStandby (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Takes a set Djinni off the unit and works out its class again.
Sint32gmDjinnRecoveryRemove (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Takes the Djinni off its side's standby and recovery list, closing the gap.
Uint32 *gmDjinnRecoveryAddStandby (Uint32 unitId, Uint32 element, Uint32 djinnIndex)Puts a unit's Djinni at the end of its side's list on standby.
Sint32gmDjinnTransfer (Sint32 src, Sint32 element, Sint32 djinnIndex, Sint32 target)Moves a Djinni from one unit to another, set or on standby as it was.
Sint32gmSummonListLearned (Uint8 *output)Writes the summons the party can call to output, in menu order, ending with SUMMON_END, and returns how many.
const struct SUMMON_DEFINITION *gmSummonDefinitionGetNear (Uint32 summonId)Returns summon summonId's definition, or NULL past the last.
Sint32gmDjinnGetAbilityId (Uint32 element, Uint32 djinni)Returns the ability the Djinni unleashes.
voidgmUnitLevelUpTo (Sint32 unitId, Sint32 targetLevel)Levels character unitId up one level at a time until targetLevel, then recomputes its stats.
Sint32gmUnitGetElementLevel (Sint32 unitId, Sint32 element)Returns how strongly a unit is attuned to element, its whole element level (a tenth of what gmUnitGetElementLevels counts), and 0 for ELEMENT_NONE.
Sint32gmDjinnRecoveryCountStandby (Uint8 *counts)Counts the party's Djinn on standby, by element into counts when it is given.
Uint32gmDjinnIsSet (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Returns 1 when the Djinni is set on the unit.
BoolgmDjinnCanSet (Sint32 unitId, Sint32 element, Sint32 djinnIndex)Returns 1 when the unit holds the Djinni and it can be set: not set, not recovering and not held by a summon.
Sint32gmItemCanUnitEquip (Sint32 unitId, Sint32 itemId)Returns whether the character can equip the item.
Sint32gmItemIsCompatibleWithUnit (Sint32 unitId, Sint32 itemId)Returns 1 for an item that is not a weapon or armor, and for those whether the character can equip it.
Sint32gmInventoryFindEquipped (Sint32 unitId, Sint32 type)Returns the slot of the equipped item of type, or -1.
Sint32gmPartyAdjustCoins (Sint32 amount)Adds amount to the party's coins, kept between 0 and COIN_MAX, and returns the new total.
Sint32gmItemGetEquipmentGroup (Sint32 itemId)Returns what kind of thing an item is, an EQUIPMENT_GROUP.
Sint32gmItemAdjustRareItemStock (Sint32 itemId, Sint32 delta)Adds delta to how many of an item the shops' Artifacts offer, and returns the new count; 0 for an item they keep no stock of.
Sint32gmInventoryCount (Sint32 unitId)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.
BoolgmPartyInventoryHasSpace (void)Returns TRUE when the leader or any party member has a free inventory slot.
Uint32gmUnitGetExperienceForLevel (Sint32 unitId, Sint32 level)Returns the experience a character needs for level (0 for level 0 and below); -1 for an enemy or a level above 99.
voidgmPartyRestoreHpPp (Sint32 cureConditions)Restores every party member's HP and PP; with cureConditions 1 it also cures poison and haunting.
voidgmPartyRestorePpInLighthouse (void)Refills the PP of each party member whose lighthouse group (CharacterLighthouseGroupTable) holds the lighthouse the party is inside.
voidgmPartyStartChildhood (void)Sets FLAG_CHILDHOOD and recomputes Isaac, Garet and Jenna, whose classes then take their childhood forms.
voidgmPartyEndChildhood (void)The party after the prologue: Isaac and Garet healed and given the Short Sword, Move and Retreat for Isaac, Move for Garet, Mind Read for Ivan, and PROLOGUE_COINS.
voidgmUnitGaugeNoOperation (void)Unused: reserved entry; keeps its place in the stub table.
Sint32gmDjinnGiveToParty (Sint32 element, Sint32 djinn)Gives a newly found Djinni to the party member holding the fewest Djinn who has room, on standby.
Sint32gmPartySumDjinnCounts (Sint32 element)Returns how many Djinn of element the party holds, or of every element for DJINN_ALL_ELEMENTS: the save files' Djinn counts, and whether the menus show the Djinn at all.
Sint32gmPartyAdjustShopCredit (Sint32 amount)
Sint32gmPartyAdjustShopGifts (Sint32 amount)
Sint32gmInventoryCheckDiscard (Sint32 unitId, Sint32 slot)Returns whether the item in slot may be dropped or sold, an enum INVENTORY_DISCARD_CHECK.
Sint32gmInventoryDiscard (Sint32 unitId, Sint32 slot)Removes one item as gmInventoryRemove does, and gives the shops' Artifacts one more of it to sell, if they keep a stock of it.
BoolgmBattleIsReviveEffect (Sint32 effectId)Returns 1 for the revive effects (Revive, Quartz, Dew), which only work on a downed unit.
Sint32gmUnitRefreshPsynergy (Sint32 unitId)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.
Uint32gmPartyGetAverageLevel (void)Returns the average level of the party members, rounded down (0 with no party members).
voidgmUnitUpdateClass (Sint32 unitId)Works out a character's class again after its Djinn change, then its Psynergy list and its base elements.
Sint32gmInventoryCountItem (Sint32 unitId, Sint32 itemId)Returns how many of an item the unit carries: the number of slots holding it, or for a stackable item the quantity in its first stack.
Sint32gmPartyInventoryCountItem (Sint32 itemId)Counts itemId across the party.
Sint32gmPartyInventoryDiscard (Sint32 itemId)Discards one itemId from whoever carries it first, as gmInventoryDiscard does; always returns 0.
voidgmFlagRefreshLureCap (void)Sets FLAG_LURE_CAP when any party member has the Lure Cap (the one item with EQUIP_EFFECT_LURE) equipped, and clears it otherwise.
Sint32gmEquipmentGetUnleashRateBonus (struct UNIT *unit)Returns the unleash chance, in percent, that a unit's equipment adds (EQUIP_EFFECT_ADD_UNLEASH_CHANCE).
Uint32gmBuildStampGetTime (void)Encodes the build stamp's time, which a new game takes as its start stamp and the file list compares saves with.
Sint32gmPartyInventoryCountFreeSlots (void)Returns the free inventory slots of the whole party.
voidgmInventorySnapshotSave (void)Saves Isaac's to Mia's inventories, the shortcuts and the party order, then keeps only the Psynergy-granting items, gives Isaac the Short Sword, sets FLAG_COLOSSO_HOLDS_EQUIPMENT and restores everyone's HP and PP.
voidgmInventorySnapshotRestore (void)Gives back the inventories, shortcuts and party order gmInventorySnapshotSave put aside, then clears the snapshot and FLAG_COLOSSO_HOLDS_EQUIPMENT.

Description

The game module's functions, declared once each in the order of its stub table (src/game/stubs.s). game.h includes it for everyone else.

Functions in detail

gmUnitAddHp

Sint32 gmUnitAddHp(Sint32 unitId, Sint32 delta)

Adds delta to unit unitId's HP, kept from 0 to its maximum, and returns the new HP.

Referenced by scFieldUnitAddHp().

Definition at line 59 of file game_functions.h.

gmUnitAddPp

Sint16 gmUnitAddPp(Sint32 unitId, Sint32 delta)

Adds delta to unit unitId's PP, kept from 0 to its maximum, and returns the new PP.

Referenced by dbMenuTestDamageAndAfflictParty().

Definition at line 63 of file game_functions.h.

gmUnitSetHp

void gmUnitSetHp(struct UNIT *unit, Sint32 value)

Definition at line 65 of file game_functions.h.

gmUnitSetPp

void gmUnitSetPp(struct UNIT *unit, Sint32 value)

Definition at line 66 of file game_functions.h.

gmPartyAdjustShopCredit

Sint32 gmPartyAdjustShopCredit(Sint32 amount)

Definition at line 123 of file game_functions.h.

gmPartyAdjustShopGifts

Sint32 gmPartyAdjustShopGifts(Sint32 amount)

Definition at line 124 of file game_functions.h.