src/game/game_inventory.c
Items and inventories: equipping, adding, removing, breaking and counting. More…
Included by game.c.
Functions
| Name | Description | |
|---|---|---|
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: the bit of its equipMask for who the unit is, and 0 for anyone past PIERS. |
Sint32 | gmItemIsCompatibleWithUnit (Sint32 unit, Sint32 item) | 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 an item's equipment group from its type: weapons, tridents and the class-changing items count as weapons, armor, shields, helms, boots and shirts as armor, and anything else as neither. |
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 1 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. |
Sint32 | gmPartyInventoryAdd (Sint32 itemId) | Gives the item to the first party member with room. |
Sint32 | gmPartyInventoryFindRoom (Sint32 itemId) | Returns the first party member with room for itemId, found by giving it and taking it back, or -1. |
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. |
Sint32 | gmInventoryFindEquipped (Sint32 unitId, Sint32 type) | Returns the slot of the equipped item of type, or -1. |
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 | gmInventoryClearSlot (Sint32 unitId, Sint32 slot) | Empties an inventory slot outright, closes the inventory up and recalculates the unit; returns INVENTORY_REMOVE_LAST, as gmInventoryRemove does for a last item. |
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 puts a rare item back into circulation (its counter goes up by one) for the shops to sell. |
Sint32 | gmInventoryCheckUnequip (Sint32 unitId, Sint32 slot) | Returns 0 when the item in slot may be taken off, or else why not: it is equipped and cannot be (INVENTORY_REFUSE_CANNOT_UNEQUIP), or the slot is empty. |
Sint32 | gmInventoryCheckDiscard (Sint32 unitId, Sint32 slot) | Returns 0 when the item in slot may be dropped, or else why not, as INVENTORY_REFUSAL bits: the item is indispensable, it is equipped and cannot be taken off, or the slot is empty. |
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) | Returns how the action an item performs when used picks its targets. |
Sint32 | gmRareItemStockAdjust (Sint32 index, Sint32 delta) | Adds delta to rare item counter index, kept between 0 and ITEM_COUNTER_MAX, and returns the new count (0 for an index from ITEM_COUNTER_COUNT on). |
Sint32 | gmItemAdjustRareItemStock (Sint32 itemId, Sint32 delta) | Adds delta to how many of a rare item the shops may sell, and returns the new count; ordinary items have none. |
Sint32 | gmInventoryCountItem (Sint32 unitId, Sint32 itemId) | Counts matching nonstackable items, or the quantity in the first matching 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
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(), dbShopTestDamageAndAfflictParty(), dbShopTestSelectItem(), dbShopTestTalkToSunshinesWife(), gmDataTransferApply(), gmEquipmentGetUnleashRateBonus(), gmFlagRefreshLureCap(), gmInventoryAddItem(), gmInventoryCheckDiscard(), gmInventoryCheckUnequip(), gmInventoryCountItem(), gmInventoryEquip(), gmInventoryFindEquipped(), gmInventoryGetEquippedDefinition(), gmInventoryGetEquippedItem(), gmInventorySnapshotSave(), gmItemCanUnitEquip(), gmItemGetEquipmentGroup(), gmItemGetTargetMode(), gmUnitCalculate(), gmUnitRebuildPsynergyList(), scDailaRoomsGiveItem(), scNaribweRoomsReadFortune(), scShamanVillageCheckTrialEntry() and scYallamRoomsTalkToSunshinesWife().
Definition at line 5 of file game_inventory.c.
gmItemCanUnitEquip
Sint32 gmItemCanUnitEquip(Sint32 unitId, Sint32 itemId)
Returns whether the character can equip the item: the bit of its equipMask
for who the unit is, and 0 for anyone past PIERS.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by gmInventoryEquip() and gmItemIsCompatibleWithUnit().
Definition at line 12 of file game_inventory.c.
gmItemIsCompatibleWithUnit
Sint32 gmItemIsCompatibleWithUnit(Sint32 unit, Sint32 item)
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 25 of file game_inventory.c.
gmItemGetEquipmentGroup
Sint32 gmItemGetEquipmentGroup(Sint32 itemId)
Returns an item's equipment group from its type: weapons, tridents and the class-changing items count as weapons, armor, shields, helms, boots and shirts as armor, and anything else as neither.
References gmItemGetDefinition() and Sint32.
Referenced by gmItemIsCompatibleWithUnit().
Definition at line 35 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.
Referenced by scDailaRoomsGiveItem().
Definition at line 63 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() and gmPartyInventoryHasSpace().
Definition at line 74 of file game_inventory.c.
gmPartyInventoryHasSpace
Bool gmPartyInventoryHasSpace(void)
Returns 1 when the leader or any party member has a free inventory slot.
References gmInventoryCount(), gmPartyListMembers(), MainRoutineStateWork and Sint32.
Referenced by dbIncreaseItemAndLevelSelectItem() and dbShopTestSelectItem().
Definition at line 88 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 scContigoOfferLuckyWheels() and scLemuriaSpringRunSpringGame().
Definition at line 108 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. A full matching stack
fails immediately, even if another slot is free.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by dbPsynergyTestGiveTreasureTestStock(), dbShopTestGiveItemTo(), gmPartyGiveItemIfMissing(), gmPartyInitCharacters(), gmPartyInventoryAdd(), gmPartyInventoryFindRoom() and scMarsLighthouseStarRoomTakeMarsStar().
Definition at line 124 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(), dbShopTestSelectItem(), scClearApplyImportedData(), scDailaRoomsGiveItem(), scDailaRoomsTakeSeaGodsTear(), scJupiterLighthouseBeaconIsLit() and scJupiterLighthouseIsaacAndIvanFall().
Definition at line 169 of file game_inventory.c.
gmPartyInventoryFindRoom
Sint32 gmPartyInventoryFindRoom(Sint32 itemId)
Returns the first party member with room for itemId, found by giving it and
taking it back, or -1.
References gmInventoryAddItem(), gmInventoryRemove(), gmPartyListMembers() and Sint32.
Referenced by dbShopTestTalkToSunshinesWife(), scDailaRoomsTakeSeaGodsTear(), scMadraMeetKarst() and scYallamRoomsTalkToSunshinesWife().
Definition at line 188 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() and gmPartyInventoryRemove().
Definition at line 211 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 gmPartyGiveItemIfMissing(), gmPartyInventoryDiscard(), gmPartyInventoryRemove(), scChampaCliffCavesObabaOffersHelp(), scFieldPartyInventoryFindMember(), scIsletsGiveTurtle(), scIzumoRoomsTalkToUzume(), scMarsLighthouseHallHearDragonStatue(), scShamanVillageCheckTrialEntry() and scYallamRoomsPartyHasForgeMaterial().
Definition at line 225 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. 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.
References gmItemCanUnitEquip(), gmItemGetDefinition(), gmUnitCalculate(), gmUnitGet(), gmUnitRefreshPsynergy() and Sint32.
Referenced by gmPartyInitCharacters(), scJupiterLighthouseBeaconIsLit(), scJupiterLighthouseIsaacAndIvanFall() and scMarsLighthouseStarRoomTakeMarsStar().
Definition at line 250 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 292 of file game_inventory.c.
gmInventoryGetEquippedDefinition
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 313 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.
Referenced by gmUnitUpdateClass().
Definition at line 333 of file game_inventory.c.
gmInventoryClearSlot
Sint32 gmInventoryClearSlot(Sint32 unitId, Sint32 slot)
Empties an inventory slot outright, closes the inventory up and recalculates
the unit; returns INVENTORY_REMOVE_LAST, as gmInventoryRemove does for a last
item.
References gmInventoryCompactSlots(), gmUnitCalculate(), gmUnitGet() and Sint32.
Referenced by scTrialRoadPutItemInChest().
Definition at line 356 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(), result and Sint32.
Referenced by gmDataTransferApply(), gmInventoryDiscard(), gmPartyInventoryFindRoom() and gmPartyInventoryRemove().
Definition at line 369 of file game_inventory.c.
gmInventoryDiscard
Sint32 gmInventoryDiscard(Sint32 unitId, Sint32 slot)
Removes one item as gmInventoryRemove does, and puts a rare item back into
circulation (its counter goes up by one) for the shops to sell.
References fdPartyClearUnusableShortcutsStub(), gmInventoryRemove(), gmItemAdjustRareItemStock(), gmUnitGet() and Sint32.
Referenced by gmPartyInventoryDiscard() and scDailaRoomsGiveItem().
Definition at line 395 of file game_inventory.c.
gmInventoryCheckUnequip
Sint32 gmInventoryCheckUnequip(Sint32 unitId, Sint32 slot)
Returns 0 when the item in slot may be taken off, or else why not: it is
equipped and cannot be (INVENTORY_REFUSE_CANNOT_UNEQUIP), or the slot is
empty.
References gmItemGetDefinition(), gmUnitGet(), result and Sint32.
Definition at line 411 of file game_inventory.c.
gmInventoryCheckDiscard
Sint32 gmInventoryCheckDiscard(Sint32 unitId, Sint32 slot)
Returns 0 when the item in slot may be dropped, or else why not, as
INVENTORY_REFUSAL bits: the item is indispensable, it is equipped and cannot
be taken off, or the slot is empty.
References gmItemGetDefinition(), gmUnitGet(), result and Sint32.
Definition at line 429 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 gmPartyAddIsaacsParty(), scAlhafraGiveBreadToHungryBoy(), scChampaCliffCavesObabaOffersHelp(), scIsletsLonesomeGeorgeThanks(), scIsletsTradeWithBird(), scIsletsTradeWithDog(), scIzumoRoomsGiveUzumeTheDoll(), scJupiterLighthouseCastTheJupiterStar(), scJupiterLighthouseIsaacAndIvanFall(), scJupiterLighthouseUseBlueKey(), scJupiterLighthouseUseRedKey(), scLemurianShipSetBlackCrystal(), scLemuriaSpringRunSpringGame(), scMadraCatacombsUnlockWithRuinKey(), scMadraRoomsGiveHealingFungus(), scMarsLighthouseAerieLightBeacon() and scMarsLighthouseStarRoomTakeMarsStar().
Definition at line 447 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 scTrialRoadBeatMoapa().
Definition at line 459 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.
Referenced by dbShopTestDamageAndAfflictParty().
Definition at line 470 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 481 of file game_inventory.c.
gmItemGetTargetMode
Uint8 gmItemGetTargetMode(Sint32 itemId)
Returns how the action an item performs when used picks its targets. Nothing calls it or its stub.
References gmAbilityGetDefinition(), gmItemGetDefinition() and Sint32.
Definition at line 493 of file game_inventory.c.
gmRareItemStockAdjust
Sint32 gmRareItemStockAdjust(Sint32 index, Sint32 delta)
Adds delta to rare item counter index, kept between 0 and
ITEM_COUNTER_MAX, and returns the new count (0 for an index from
ITEM_COUNTER_COUNT on).
References RareItemStock and Sint32.
Referenced by gmItemAdjustRareItemStock().
Definition at line 502 of file game_inventory.c.
gmItemAdjustRareItemStock
Sint32 gmItemAdjustRareItemStock(Sint32 itemId, Sint32 delta)
Adds delta to how many of a rare item the shops may sell, and returns the
new count; ordinary items have none.
References gmRareItemStockAdjust(), ItemRareItemCounters, result and Sint32.
Referenced by gmInventoryDiscard() and scInit().
Definition at line 534 of file game_inventory.c.
gmInventoryCountItem
Sint32 gmInventoryCountItem(Sint32 unitId, Sint32 itemId)
Counts matching nonstackable items, or the quantity in the first matching stack.
References gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by gmPartyInventoryCountItem() and scDailaRoomsGiveItem().
Definition at line 552 of file game_inventory.c.
gmPartyInventoryCountItem
Sint32 gmPartyInventoryCountItem(Sint32 itemId)
Counts itemId across the party.
References gmInventoryCountItem(), gmPartyListMembers() and Sint32.
Referenced by scContigoOfferLuckyWheels() and scLemuriaSpringRunSpringGame().
Definition at line 575 of file game_inventory.c.