src/game/game_inventory.c
Items and inventories: equipping, adding, removing, breaking and counting. More…
Included by game.c.
Functions
| Name | Description | |
|---|---|---|
const ITEM_DEFINITION * | gmItemGetDefinition (Sint32 item) | Returns an item's definition; an inventory entry's other bits are ignored. |
Sint32 | gmItemCanUnitEquip (Sint32 unitId, Sint32 itemId) | Returns whether the character can equip the item. |
Sint32 | gmItemIsCompatibleWithUnit (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. |
Sint32 | gmItemGetEquipmentGroup (Sint32 itemId) | Returns what kind of thing an item is, an EQUIPMENT_GROUP. |
Sint32 | gmInventoryGetQuantity (Sint32 unitId, Sint32 slot) | Returns how many of the item in slot the unit carries (0 for an empty slot). |
Sint32 | gmInventoryCount (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. |
Bool | gmPartyInventoryHasSpace (void) | Returns TRUE when the leader or any party member has a free inventory slot. |
Sint32 | gmPartyInventoryCountFreeSlots (void) | Returns the free inventory slots of the whole party. |
Sint32 | gmInventoryAddItem (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. |
Sint32 | gmPartyInventoryAdd (Sint32 itemId) | Gives the item to the first party member with room. |
Sint32 | gmInventoryFind (Sint32 unitId, Sint32 itemId) | Returns the first slot holding itemId (any quantity, equipped or not), or -1. |
Sint32 | gmPartyInventoryFindMember (Sint32 itemId) | Returns who carries itemId, asking the leader first, or -1. |
Sint32 | gmInventoryEquip (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. |
Sint32 | gmInventoryFindEquipped (Sint32 unitId, Sint32 type) | Returns the slot of the equipped item of type, or -1. |
const ITEM_DEFINITION * | gmInventoryGetEquippedDefinition (UNIT *unit, Sint32 type) | Returns the definition of the unit's equipped item of type, or NULL. |
Sint32 | gmInventoryGetEquippedItem (UNIT *unit, Sint32 type) | Returns the id of the unit's equipped item of type, or 0. |
Sint32 | gmInventoryRemove (Sint32 unitId, Sint32 slot) | Takes one item out of slot, closing up the inventory when it was the last. |
Sint32 | gmInventoryDiscard (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. |
Sint32 | gmInventoryCheckDiscard (Sint32 unitId, Sint32 slot) | Returns whether the item in slot may be dropped or sold, an enum INVENTORY_DISCARD_CHECK. |
Sint32 | gmPartyInventoryRemove (Sint32 itemId) | Removes one itemId from whoever carries it first; always returns 0. |
Sint32 | gmPartyInventoryDiscard (Sint32 itemId) | Discards one itemId from whoever carries it first, as gmInventoryDiscard does; always returns 0. |
Sint32 | gmInventoryBreak (Sint32 unitId, Sint32 slot) | Marks the item in slot broken; returns -1 for an empty slot. |
Sint32 | gmInventoryRepair (Sint32 unitId, Sint32 slot) | Clears the broken mark of the item in slot; returns -1 for an empty slot. |
Uint8 | gmItemGetTargetMode (Sint32 itemId) | Unused: returns how the ability an item uses picks its targets. |
Sint32 | gmRareItemStockAdjust (Sint32 index, Sint32 delta) | Adds delta to the shops' stock of rare item index, kept between 0 and RARE_ITEM_STOCK_MAX, and returns the new count (0 for an index from RARE_ITEM_STOCK_COUNT on). |
Sint32 | gmItemAdjustRareItemStock (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. |
Sint32 | gmInventoryCountItem (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. |
Sint32 | gmPartyInventoryCountItem (Sint32 itemId) | Counts itemId across the party. |
Description
Items and inventories: equipping, adding, removing, breaking and counting.
Part of game.c.
Functions in detail
gmItemGetDefinition
const ITEM_DEFINITION *gmItemGetDefinition(Sint32 item)
Returns an item's definition; an inventory entry's other bits are ignored.
References ItemDefinitionTable and Sint32.
Referenced by dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), gmEquipmentGetUnleashRateBonus(), gmFlagRefreshLureCap(), gmInventoryAddItem(), gmInventoryCheckDiscard(), gmInventoryCountItem(), gmInventoryEquip(), gmInventoryFindEquipped(), gmInventoryGetEquippedDefinition(), gmInventoryGetEquippedItem(), gmInventorySnapshotSave(), gmItemCanUnitEquip(), gmItemGetEquipmentGroup(), gmItemGetTargetMode(), gmUnitCalculate(), gmUnitRefreshPsynergy(), scFileScreenPackPasswordData() and scGomaCaveEntranceGiveShamansRod().
Definition at line 5 of file game_inventory.c.
gmItemCanUnitEquip
Sint32 gmItemCanUnitEquip(Sint32 unitId, Sint32 itemId)
Returns whether the character can equip the item.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by gmInventoryEquip() and gmItemIsCompatibleWithUnit().
Definition at line 11 of file game_inventory.c.
gmItemIsCompatibleWithUnit
Sint32 gmItemIsCompatibleWithUnit(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.
References gmItemCanUnitEquip(), gmItemGetEquipmentGroup() and Sint32.
Definition at line 24 of file game_inventory.c.
gmItemGetEquipmentGroup
Sint32 gmItemGetEquipmentGroup(Sint32 itemId)
Returns what kind of thing an item is, an EQUIPMENT_GROUP.
References gmItemGetDefinition() and Sint32.
Referenced by gmItemIsCompatibleWithUnit().
Definition at line 32 of file game_inventory.c.
gmInventoryGetQuantity
Sint32 gmInventoryGetQuantity(Sint32 unitId, Sint32 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.
References gmUnitGet() and Sint32.
Definition at line 54 of file game_inventory.c.
gmInventoryCount
Sint32 gmInventoryCount(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.
References gmUnitGet() and Sint32.
Referenced by gmPartyInventoryCountFreeSlots(), gmPartyInventoryHasSpace() and scSolSanctumElementalStarRoomGiveMythrilBags().
Definition at line 65 of file game_inventory.c.
gmPartyInventoryHasSpace
Bool gmPartyInventoryHasSpace(void)
Returns TRUE when the leader or any party member has a free inventory slot.
References gmInventoryCount(), gmPartyListMembers(), MainRoutineStateWork and Sint32.
Referenced by dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), scLogRoomsAMayorGivesWaterOfLife(), scLogRoomsAOfferBones(), scLogRoomsBOfferBones() and scVaultFindBone().
Definition at line 79 of file game_inventory.c.
gmPartyInventoryCountFreeSlots
Sint32 gmPartyInventoryCountFreeSlots(void)
Returns the free inventory slots of the whole party.
References gmInventoryCount(), gmPartyListMembers() and Sint32.
Referenced by scStuccoRoomsCOfferLuckyWheels() and scTolbiSpringRunSpringGame().
Definition at line 99 of file game_inventory.c.
gmInventoryAddItem
Sint32 gmInventoryAddItem(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. A full matching stack fails at once, even if another slot is free.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by dbMenuTestGiveConsumableTestStock(), dbMenuTestGiveEquipmentTestStock(), dbMenuTestGiveTreasureTestStock(), gmInventoryAddAndEquip(), gmPartyInitCharacters(), gmPartyInventoryAdd(), scGiveAndEquipItem(), scGomaCaveEntranceGiveShamansRod(), scInit() and scSolSanctumElementalStarRoomPresentStarFX().
Definition at line 115 of file game_inventory.c.
gmPartyInventoryAdd
Sint32 gmPartyInventoryAdd(Sint32 itemId)
Gives the item to the first party member with room. Returns who took it, or -1.
References gmInventoryAddItem(), gmPartyListMembers() and Sint32.
Referenced by dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem() and scSolSanctumElementalStarRoomGiveMythrilBags().
Definition at line 160 of file game_inventory.c.
gmInventoryFind
Sint32 gmInventoryFind(Sint32 unitId, Sint32 itemId)
Returns the first slot holding itemId (any quantity, equipped or not), or
-1.
References gmUnitGet() and Sint32.
Referenced by gmPartyInventoryDiscard(), gmPartyInventoryFindMember(), gmPartyInventoryRemove(), scInventoryReplaceItem(), scKalayTolbiDocksTalkToManCheckingTickets() and scSolSanctumElementalStarRoomPresentStarFX().
Definition at line 179 of file game_inventory.c.
gmPartyInventoryFindMember
Sint32 gmPartyInventoryFindMember(Sint32 itemId)
Returns who carries itemId, asking the leader first, or -1.
References gmInventoryFind(), gmPartyListMembers(), MainRoutineStateWork and Sint32.
Referenced by gmPartyInventoryDiscard(), gmPartyInventoryRemove(), scCrossboneIsleKeysUseBlueKey(), scCrossboneIsleKeysUseRedKey(), scFuchinFallsCaveSearchDragonStatue(), scInventoryReplaceItem(), scKalayTolbiDocksTalkToManCheckingTickets(), scKolimaForestTreeTalkToTret(), scLunpaFortressSearchLockedDoor(), scLunpaFortressTalkToJailedDodonpa(), scLunpaFortressUnlockCaveDoor(), scLunpaFortressUnlockGroundFloorDoor(), scLunpaFortressUnlockToadonpaDoor(), scLunpaFortressUnlockUpperFloorDoor(), scMercuryLighthouseFillHermesWaterBottle(), scMercuryLighthouseInspectHealingFountain(), scSolSanctumElementalStarRoomPresentStarFX(), scTreeRoomsPlayPostBattleConversation(), scVaultRevisitTalkToDog(), scVaultTalkToDogAfterCapture() and scVenusLighthouseAerieConfrontSaturosAndMenardi().
Definition at line 193 of file game_inventory.c.
gmInventoryEquip
Sint32 gmInventoryEquip(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. Recomputes
the unit's Psynergy and stats. Returns an INVENTORY_EQUIP_RESULT.
References gmItemCanUnitEquip(), gmItemGetDefinition(), gmUnitCalculate(), gmUnitGet(), gmUnitRefreshPsynergy() and Sint32.
Referenced by gmInventoryAddAndEquip(), gmPartyEndChildhood(), gmPartyInitCharacters(), scGiveAndEquipItem() and scGomaCaveEntranceGiveShamansRod().
Definition at line 217 of file game_inventory.c.
gmInventoryFindEquipped
Sint32 gmInventoryFindEquipped(Sint32 unitId, Sint32 type)
Returns the slot of the equipped item of type, or -1.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Definition at line 259 of file game_inventory.c.
gmInventoryGetEquippedDefinition
const ITEM_DEFINITION *gmInventoryGetEquippedDefinition(UNIT *unit, Sint32 type)
Returns the definition of the unit's equipped item of type, or NULL.
References gmItemGetDefinition() and Sint32.
Referenced by gmEquipmentRollUnleash() and gmUnitGetAttackElement().
Definition at line 280 of file game_inventory.c.
gmInventoryGetEquippedItem
Sint32 gmInventoryGetEquippedItem(UNIT *unit, Sint32 type)
Returns the id of the unit's equipped item of type, or 0.
References gmItemGetDefinition() and Sint32.
Definition at line 300 of file game_inventory.c.
gmInventoryRemove
Sint32 gmInventoryRemove(Sint32 unitId, Sint32 slot)
Takes one item out of slot, closing up the inventory when it was the last. The Psynergy list is not rebuilt, so a removed item's Psynergy stays listed until something rebuilds it.
References gmInventoryCompactSlots(), gmUnitCalculate(), gmUnitGet() and Sint32.
Referenced by gmInventoryDiscard() and gmPartyInventoryRemove().
Definition at line 323 of file game_inventory.c.
gmInventoryDiscard
Sint32 gmInventoryDiscard(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.
References fdPartyClearUnusableShortcutsStub(), gmInventoryRemove(), gmItemAdjustRareItemStock(), gmUnitGet() and Sint32.
Referenced by gmPartyInventoryDiscard(), scGomaCaveEntranceGiveShamansRod(), scKalayTolbiDocksTalkToManCheckingTickets(), scSolSanctumElementalStarRoomGiveMythrilBags() and scSolSanctumElementalStarRoomPresentStarFX().
Definition at line 349 of file game_inventory.c.
gmInventoryCheckDiscard
Sint32 gmInventoryCheckDiscard(Sint32 unitId, Sint32 slot)
Returns whether the item in slot may be dropped or sold, an enum
INVENTORY_DISCARD_CHECK.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Definition at line 364 of file game_inventory.c.
gmPartyInventoryRemove
Sint32 gmPartyInventoryRemove(Sint32 itemId)
Removes one itemId from whoever carries it first; always returns 0.
References gmInventoryFind(), gmInventoryRemove(), gmPartyInventoryFindMember() and Sint32.
Referenced by scCrossboneIsleKeysUseBlueKey(), scCrossboneIsleKeysUseRedKey(), scTolbiSpringRunSpringGame() and scVenusLighthouseAerieConfrontSaturosAndMenardi().
Definition at line 387 of file game_inventory.c.
gmPartyInventoryDiscard
Sint32 gmPartyInventoryDiscard(Sint32 itemId)
Discards one itemId from whoever carries it first, as gmInventoryDiscard
does; always returns 0.
References gmInventoryDiscard(), gmInventoryFind(), gmPartyInventoryFindMember() and Sint32.
Referenced by scAltmillerCaveRestoreBabiAndInviteParty(), scFuchinFallsCaveLightDragonWithEye(), scInit(), scShipRoomsReturnLuckyAnchor(), scSolSanctumElementalStarRoomAlexTakesStars(), scVaultGiveBoneToDog(), scVaultRevisitGiveBoneToDog() and scWorldMapUseBlackOrb().
Definition at line 399 of file game_inventory.c.
gmInventoryBreak
Sint32 gmInventoryBreak(Sint32 unitId, Sint32 slot)
Marks the item in slot broken; returns -1 for an empty slot.
References gmUnitGet() and Sint32.
Definition at line 410 of file game_inventory.c.
gmInventoryRepair
Sint32 gmInventoryRepair(Sint32 unitId, Sint32 slot)
Clears the broken mark of the item in slot; returns -1 for an empty slot.
References gmUnitGet() and Sint32.
Definition at line 421 of file game_inventory.c.
gmItemGetTargetMode
Uint8 gmItemGetTargetMode(Sint32 itemId)
Unused: returns how the ability an item uses picks its targets. Only its
unnamed slot in the game module's stub table (src/game/stubs.s) reaches it,
and nothing calls through that slot.
References gmAbilityGetDefinition(), gmItemGetDefinition() and Sint32.
Definition at line 434 of file game_inventory.c.
gmRareItemStockAdjust
Sint32 gmRareItemStockAdjust(Sint32 index, Sint32 delta)
Adds delta to the shops' stock of rare item index, kept between 0 and
RARE_ITEM_STOCK_MAX, and returns the new count (0 for an index from
RARE_ITEM_STOCK_COUNT on).
References RareItemStock and Sint32.
Referenced by gmItemAdjustRareItemStock().
Definition at line 443 of file game_inventory.c.
gmItemAdjustRareItemStock
Sint32 gmItemAdjustRareItemStock(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. A delta of 0 reads it.
ItemRareItemStockIndex holds each item's stock number plus one, 0 meaning
none.
References gmRareItemStockAdjust(), ItemRareItemStockIndex and Sint32.
Referenced by gmInventoryDiscard() and scInit().
Definition at line 475 of file game_inventory.c.
gmInventoryCountItem
Sint32 gmInventoryCountItem(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.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by gmPartyInventoryCountItem().
Definition at line 487 of file game_inventory.c.
gmPartyInventoryCountItem
Sint32 gmPartyInventoryCountItem(Sint32 itemId)
Counts itemId across the party.
References gmInventoryCountItem(), gmPartyListMembers() and Sint32.
Referenced by scStuccoRoomsCOfferLuckyWheels() and scTolbiSpringRunSpringGame().
Definition at line 510 of file game_inventory.c.