Items and inventories: equipping, adding, removing, breaking and counting. More...
Go to the source code of this file.
Functions | |
| 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. | |
Items and inventories: equipping, adding, removing, breaking and counting.
Part of game.c, the game object, compiled only through it.
Definition in file inventory.c.
| 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().
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().
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().
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().
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().
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().
| 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().
| 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().
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().
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().
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().
Returns who carries itemId, asking the selected character first, or -1.
Called by the scenes that need a key item, such as the Mercury Lighthouse's Hermes' Water and Kolima's Tret.
Definition at line 229 of file inventory.c.
Referenced by CrossboneIslePlatformRooms_UseBlueKey(), Event_ConfrontSaturosAndMenardi(), Event_TalkToDog(), Event_TalkToDogAfterCapture(), Event_UseRedKey(), Fuchin_SearchDragonStatue(), KalayTolbiDocks_TalkToGatekeeper(), KolimaForestTree_ReplaceInventoryItem(), KolimaForestTree_TalkToTret(), MercuryLighthouse_FillHermesWaterBottle(), MercuryLighthouse_InspectHealingFountain(), MercuryLighthouse_ReplaceInventoryItem(), PartyInventory_Discard(), PartyInventory_FindOwner(), PartyInventory_Remove(), SolSanctumElementalStarRoom_PresentStar(), and TretTreeInteriors_PlayPostBattleConversation().
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().
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().
| 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().
| 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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().