20 #ifndef __PSCHARINV_H__ 21 #define __PSCHARINV_H__ 26 #include <csutil/sysfunc.h> 27 #include <csutil/weakref.h> 35 #include "../icachedobject.h" 59 #define PSCHARACTER_EQUIPMENTFLAG_AUTOATTACK 0x00000001 61 #define PSCHARACTER_EQUIPMENTFLAG_SINGLEATTACK 0x00000002 63 #define PSCHARACTER_EQUIPMENTFLAG_ATTACKIFEMPTY 0x00000004 95 exchangeOfferSlot = -1;
96 exchangeStackCount = 0;
165 bool QuickLoad(PID
id);
173 bool HasEnoughUnusedSpace(
float desiredSpace);
181 int GetCurrentTotalSpace();
188 int GetCurrentMaxSpace();
196 void AddStorageItem(
psItem* &item);
204 bool HasEnoughUnusedWeight(
float requiredWeight);
205 float GetCurrentTotalWeight();
213 size_t HowManyCanFit(
psItem* item);
235 float GetTotalSizeOfItemsInContainer(
psItem* container=NULL);
268 bool Add(
psItem* &item,
bool test =
false,
bool stack =
true,
283 bool AddOrDrop(
psItem* &item,
bool stack =
true);
306 bool hasItemsWithName(csString &itemname,
bool includeEquipment,
bool includeBulk,
int amountMin = 1,
int amountMax = -1,
float qualityMin = 0,
float qualityMax = 0);
321 void RestoreAllInventoryQuality();
341 size_t FindItemStatIndex(
psItemStats* itemstats,
size_t startAt=1);
361 psItem* RemoveItemID(uint32 itemID,
int count = -1,
bool storage =
false);
388 psItem* FindItemID(uint32 itemID,
bool storage =
false);
391 int GetOfferedStackCount(
psItem* item);
401 bool HaveKeyForLock(uint32 lock);
456 bool hasItemCategory(
psItemCategory* category,
bool includeEquipment,
bool includeBulk,
bool includeStorage =
false);
471 bool hasItemCategory(csString &categoryname,
bool includeEquipment,
bool includeBulk,
bool includeStorage =
false,
int amountMin = 1,
int amountMax = -1 ,
float qualityMin = 0,
float qualityMax = 0);
481 csArray<psItem*> GetItemsInCategory(
psItemCategory* category,
bool storage =
false);
491 psItem* StackNumberItems(
const csString &itemname,
int count,
bool container);
494 size_t GetContainedItemCount(
psItem* container);
495 float GetContainedWeight(
psItem* container);
496 float GetContainedSize(
psItem* container);
499 void CalculateLimits();
502 void RunEquipScripts();
508 void SetDoRestrictions(
bool v);
513 return doRestrictions;
519 return &inventoryCacheServer;
523 bool HasPurifiedGlyphs(
const glyphList_t glyphsToCheck);
526 void CreateGlyphList(csArray <glyphSlotInfo> &slots);
539 void Unequip(
psItem* item);
563 return inventory.GetSize();
573 return inventory[which].item;
579 return &inventory[index];
583 void WriteAllInventory(iDocumentNode* npcRoot);
594 psItem* RemoveItemIndex(
size_t index,
int count=-1,
bool storage =
false);
597 bool BeginExchange();
600 void CommitExchange();
603 void RollbackExchange();
606 void UpdateEncumbrance();
632 size_t GetItemIndex(
psItem* item);
643 int FindFirstOpenSlot(
psItem* container);
649 size_t FindCompatibleStackedItem(
psItem* item,
bool checkStackCount =
true);
660 csArray<size_t> FindCompatibleStackedItems(
psItem* item,
bool checkStackCount =
true,
bool precise =
true);
677 if(!committed && myInv)
678 myInv->RollbackExchange();
682 myInv->CommitExchange();
psCharacterInventory * myInv
This class handles the details behind a character's inventory system.
psInventoryCacheServer * GetInventoryCacheServer(void)
Get the inventory cache handler.
bool GetDoRestrictions()
Get the status of the weight/capacity restrictions.
float maxSize
Max capacity in inventory.
uint32 GetInventoryVersion() const
void IncreaseInventoryVersion()
Updates (increases) the current inventory version.
bool BeginExchange()
Copies current inventory to backup inventory.
size_t GetInventoryIndexCount()
Return a count of items in the base inventory array.
csArray< psItem * > storageInventory
Array with all the items stored by the character.
INVENTORY_SLOT_NUMBER
Holds a list of the possible socket identifiers that items can be attached to.
The structure of 1 queue entry (pointer to a message)
csString lastError
Contain error messge for last function failing.
csArray< psItemStats * > glyphList_t
Defines characteristics of a race associated to an NPC, player or pet.
bool loaded
Has this inventory been fully loaded yet?
Any semi-autonomous object, either a player or an NPC.
gemContainers are the public containers in the world for crafting, like forges or ovens...
The psInventoryCacheServer class implements the inventory cache on the server.
used by psCharacter::CreateGlyphList()
psItem * default_if_empty
InventoryTransaction(psCharacterInventory *what)
int exchangeOfferSlot
Slot in exchange offer window on client.
psCharacterInventoryItem(psItem *it)
psCharacter * owner
Current owner of the inventory.
unsigned int EquipmentFlags
uint32 version
Inventory version.
bool inExchangeMode
Exchange mode flag.
psCharacterInventoryItem * GetIndexCharInventoryItem(size_t index)
Returns the exchange info and the item in the index specified.
This huge class stores all the properties of any object a player can have in the game.
psItem * GetInventoryIndexItem(size_t which)
Return the psItem at the inventory index specified.
float maxWeight
Max weight the inventory can hold.
int purifyStatus
possible values are: 0=not purified 1=purifying 2=purified
bool doRestrictions
Do weight/capacity restrictions?
csArray< psCharacterInventoryItem > inventory
Flat array of all items owned in this inventory.
int exchangeStackCount
count of items being offered, subset of stack in *item
This class embodies item instances in the game.