Planeshift
Public Member Functions | Static Public Member Functions | Protected Attributes

psItem Class Reference

This class embodies item instances in the game. More...

#include <psitem.h>

List of all members.

Public Member Functions

float AddDecay (float severityFactor)
 Adjust the item quality by an amount of decay.
void AddLootModifier (uint32_t id, int pos=-1)
 Allows to add a modification to the item.
bool AddModifier (psItemStats *modifier)
 Adds a modifier to this item instance if there is space available.
void AddOpenableLock (uint32 v)
double CalcFunction (MathEnvironment *env, const char *functionName, const double *params)
void CancelEquipScript ()
bool CanOpenLock (uint32 id, bool includeSkel) const
bool CheckRequirements (psCharacter *character, csString &resp)
 Check to see if the character meets the requirements for this item.
bool CheckStackableWith (const psItem *otheritem, bool precise, bool checkStackCount=true, bool checkWorld=true) const
 Check if otheritem is stackable with this item.
void ClearOpenableLocks ()
void CombineStack (psItem *&stackme)
 Combines 'stackme' with this item.
bool CompareOpenableLocks (const psItem *key) const
virtual psItemCopy (unsigned short newstackcount)
 Duplicates an item instance.
virtual void Copy (psItem *target)
 Copies values of its attributes to item 'target'.
void CopyOpenableLock (psItem *origKey)
virtual psItemCreateNew ()
 Creates a new blank instance of it's class (i.e.
bool DeleteFromDatabase ()
virtual void DeleteObjectCallback (iDeleteNotificationObject *object)
 Handles deleted gem objects.
bool Destroy ()
 Called when an item is completely destroyed from the persistant world.
bool FitsInSlot (INVENTORY_SLOT_NUMBER slot)
bool FitsInSlots (PSITEMSTATS_SLOTLIST slotmask)
void ForceSaveIfNew ()
 Saves this item now if it hasn't been saved before, to force the generation of a UID.
PSITEMSTATS_AMMOTYPE GetAmmoType ()
PSITEMSTATS_ARMORTYPE GetArmorType ()
float GetArmorVSWeaponResistance (psItemStats *armor)
 Gets the reduction of this weapon against the armor given.
int GetAttackAnimID (psCharacter *pschar)
 TODO: Comment me with something more than "Gets the attack animation ID".
psItemStatsGetBaseStats () const
 Returns the base stats for this item instance.
csString GetBookText ()
 Gets the book text, should only be used if this is a book.
bool GetBuyPersonalise ()
bool GetCanTransform ()
psItemCategoryGetCategory ()
int GetCharges () const
uint32 GetContainerID () const
 Returns the item that contains this item, or NULL if it's not contained by another item.
unsigned short GetContainerMaxSize ()
int GetContainerMaxSlots ()
 Gets the slots available in this item (only containers) which means also the maximum amount of items which can be stored in this container.
float GetCounterBlockValue ()
PID GetCrafterID () const
 Returns the UID for the crafter of this item. Be sure to check GetIsCrafterIDValid()!
PSITEMSTATS_CREATIVETYPE GetCreative ()
const csString & GetCreativeBackgroundImg ()
 return the background image used in this creative.
PID GetCreator (PSITEMSTATS_CREATORSTATUS &creatorStatus)
 Gets the creator of this creative and the creator setting status.
psItemStatsGetCurrentStats () const
 Gets a pointer to the current stats.
float GetDamage (PSITEMSTATS_DAMAGETYPE dmgtype)
float GetDamageProtection (PSITEMSTATS_DAMAGETYPE dmgtype)
float GetDecay ()
 Returns the decay value of the item. See the decay member for a description of what this is.
float GetDecayResistance ()
const char * GetDescription () const
 Fetch the psitem description if it's not null, otherwise the current_stats description.
PSITEM_FLAGS GetFlags ()
gemItemGetGemObject ()
PID GetGuardingCharacterID () const
 Item guardians: items dropped in the world or placed in a public container are not owned, but "guarded" by a character.
unsigned int GetGuildID () const
 Returns the UID for the guild who has certified this item. Be sure to check GetIsGuildIDValid()!
float GetHardness ()
int GetIdentifyMinSkill ()
 Returns minimum skill level to identify certain examined items.
int GetIdentifySkill ()
 Returns skill id of skill needed to identify examined items.
const char * GetImageName ()
 Get the Image Name for the item.
bool GetIsAmmo ()
bool GetIsArmor ()
bool GetIsAutoTransformContainer ()
bool GetIsBothHandsWeapon ()
bool GetIsCD () const
bool GetIsConstructible ()
bool GetIsContainer ()
bool GetIsCrafterIDValid ()
 Returns true if the crafter character ID is valid.
bool GetIsEquipStackable () const
bool GetIsGuildIDValid ()
 Returns true if the certifying guild ID is valid.
bool GetIsIdentifiable ()
 Get the identifiable status of the item.
bool GetIsKey () const
bool GetIsLockable ()
bool GetIsLocked ()
bool GetIsMasterKey () const
bool GetIsMeleeWeapon ()
bool GetIsNoPickup ()
 Gets if the item has a no pickup flag set.
bool GetIsNoPickupStrong ()
 Checks if the item has a strong no pickup flag set.
bool GetIsNoPickupWeak ()
 Checks if the item has a weak no pickup flag set.
bool GetIsNpcOwned () const
bool GetIsRangeWeapon ()
bool GetIsReadable ()
 Checks the readable flag in the item_stats and tell if this is the case.
bool GetIsSecurityLocked ()
bool GetIsSettingItem () const
bool GetIsShield ()
bool GetIsSkeleton ()
bool GetIsStackable () const
bool GetIsTrap ()
bool GetIsUnique () const
 Returns true if this item is based off of unique statistics.
bool GetIsUnpickable ()
bool GetIsWriteable ()
 Checks the writeable flag in the item_stats and tell if this is the case.
csString GetItemCommand ()
 returns the special command assigned to this item
float GetItemDecayRate ()
 Get the item decay factor.
float GetItemQuality () const
 Gets the quality of the item.
float GetItemSize ()
virtual const char * GetItemType ()
 Return a string identifying this object as an Item.
float GetLatency ()
const csString & GetLiteratureText (void)
 return creative contents of books.
void GetLocationInWorld (InstanceID &instance, psSectorInfo **sectorinfo, float &loc_x, float &loc_y, float &loc_z, float &loc_yrot) const
INVENTORY_SLOT_NUMBER GetLocInParent (bool adjustSlot=false)
 Returns the location of this item in its parent item or in the player's equipment, bulk or bank as appropriate.
PSSKILL GetLockpickSkill ()
unsigned int GetLockStrength ()
int GetMaxCharges () const
float GetMaxItemQuality () const
 Gets the maximum possible quality of the item by reading the item_stat.
const char * GetMeshName ()
 Get the Mesh Name for the item.
psItemStatsGetModifier (int index)
 Returns the modifier at a specific index 0 through PSITEM_MAX_MODIFIERS-1.
const char * GetModifiersDescription ()
 If an overlay is set return it's script description, otherwise return the.
const csString & GetMusicalSheet (void)
 return creative contents of musical sheets.
const char * GetName () const
csString GetOpenableLockNames ()
psCharacterGetOwningCharacter ()
 Returns a pointer to the character who is holding this item directly or indirectly (including containers and bank slots) or NULL if none.
PID GetOwningCharacterID () const
 Get the ID of the owning character.
const char * GetPartMeshName ()
 Get the Part Mesh Name for the item.
const char * GetPartName ()
 Get the Part Name for the item.
float GetPenetration ()
psMoney GetPrice ()
double GetProperty (MathEnvironment *env, const char *ptr)
 This is used by the math scripting engine to get various values.
virtual int GetPurifyStatus () const
const char * GetQualityString ()
 Returns a description of the quality level of item.
csString GetQuantityName ()
float GetRange () const
float GetRarity ()
 return Rarity as 0-100% range
csString GetRarityName ()
 return Rarity description. example: "rare (0.7%)"
int GetRequiredRepairTool ()
 Returns item_stats id of repair tool required to fix this item, or 0.
bool GetRequiredRepairToolConsumed ()
 Returns the is_consumed flag of repair tool required to fix this item.
void GetRotationInWorld (float &loc_xrot, float &loc_yrot, float &loc_zrot)
 Get the x,y and z axis rotations for the item.
psScheduledItemGetScheduledItem ()
psSectorInfoGetSector () const
psMoney GetSellPrice ()
 Merchants want a percentage.
const csString & GetSketch (void)
 return creative contents of sketches.
csString GetSlotRemovedMesh (int slot, csString meshName="")
 Proxies the same function in psitemstats which gets the list of mesh to remove when this item is equipped in the specified slot.
const char * GetSound ()
unsigned short GetStackCount () const
 Returns the stack count. Be sure to call GetIsStackable() first!
const char * GetStandardDescription ()
const char * GetStandardName ()
float GetTargetedBlockValue ()
const char * GetTextureName ()
 Get the Texture Name for the item.
float GetTotalStackSize ()
 Gets the total size of the items in the stack.
psWorkGameEventGetTransformationEvent ()
uint32 GetUID ()
 Returns the UID of this item instance.
float GetUntargetedBlockValue ()
bool GetUsesAmmo ()
PSITEMSTATS_SLOTLIST GetValidSlots ()
float GetVisibleDistance ()
float GetWeaponAttributeBonus (PSITEMSTATS_STAT stat)
float GetWeaponAttributeBonusMax (int index)
PSITEMSTATS_STAT GetWeaponAttributeBonusType (int index)
PSSKILL GetWeaponSkill (PSITEMSTATS_WEAPONSKILL_INDEX index)
psWeaponTypeGetWeaponType ()
float GetWeight ()
void GetXZRotationInWorld (float &loc_xrot, float &loc_zrot)
 Get the x and z axis rotations for the item (y obtained in GetLocationInWorld)
bool HasCharges () const
bool HasModifier (psItemStats *modifier)
 Returns true if this item has this modifier in its modifier list.
bool IsActive () const
bool IsEquipped () const
bool IsInUse ()
bool IsRechargeable () const
bool IsThisTheCreator (PID pid)
 Checks if the creator of the book is the one passed as argument.
bool IsTransient ()
virtual bool Load (iResultRow &row)
 Loads data from a database row into the current psItem.
void MakeSkeleton (bool b)
void operator delete (void *)
 The delete operator is overriden to call PoolAllocator template functions.
void * operator new (size_t)
 The new operator is overriden to call PoolAllocator template functions.
PSITEM_FLAGS ParseItemFlags (csString flagstr)
 Parses an item flags list and returns the flags.
void PrepareCreativeItemInstance ()
 psItem ()
 Constructs a psItem.
void RecalcCurrentStats ()
 In some cases some modifiers or effects may be difficult to reverse (for example percent bonuses applied and removed in different orders).
void RemoveOpenableLock (uint32 v)
void ResetItemStackable ()
void RunEquipScript (gemActor *actor)
void Save (bool children)
 Queues this item to be saved to the database.
void ScheduleRemoval ()
 This function handles creating an event manager event at the right time to get transient objects removed from the world automatically.
void ScheduleRespawn ()
bool SendActionContents (Client *client, psActionLocation *action)
bool SendContainerContents (Client *client, int containerID=CONTAINER_INVENTORY_BULK)
bool SendItemDescription (Client *client)
void SetActive (bool state)
void SetBaseStats (psItemStats *statptr)
 Alters the base stats of this item instance.
bool SetBookText (const csString &newText)
 Sets the book text, should only be used if this is a book.
void SetCharges (int charges)
void SetContainerID (uint32 parentId)
void SetCrafterID (PID v)
 Sets the UID for the cracter of this item. Generally used immediately after completing the crafting work.
bool SetCreation (PSITEMSTATS_CREATIVETYPE, const csString &, csString)
 Write creative stuff such as lit text (eg book) or map data.
void SetCreator (PID, PSITEMSTATS_CREATORSTATUS)
 sets the creator (i.e. author, artist, etc) of creative things
void SetCurrentStats (psItemStats *statptr)
 Sets the current item stats.
void SetDecay (float v)
 Sets the decay value of the item. See the decay member for a description of what this is.
void SetDecayResistance (float v)
 Set the decay resistance percentage for the item.
void SetDescription (const char *newDescription)
void SetFlags (int f)
void SetGemObject (gemItem *object)
void SetGuardingCharacterID (PID guardian)
void SetGuildID (unsigned int v)
 Sets the UID for the guild certifying this item.
void SetInUse (bool flag)
void SetIsCD (bool v)
void SetIsCrafterIDValid (bool v)
 Set wether the crafter ID is valid. SetCrafterID() sets this to true for you.
void SetIsGuildIDValid (bool v)
 Set wether the guild ID is valid. SetGuildID() sets this to true for you.
void SetIsIdentifiable (bool v)
 Set the Identifiable flag of the item.
void SetIsItemStackable (bool v)
void SetIsKey (bool v)
void SetIsLockable (bool v)
void SetIsLocked (bool v)
void SetIsMasterKey (bool v)
void SetIsNpcOwned (bool v)
void SetIsPickupable (bool v)
 Sets the pickupable flag in order to not allow/allow the item to be picked up.
void SetIsPickupableWeak (bool v)
 Sets the weak pickupable flag in order to not allow/allow the item to be picked up.
void SetIsSecurityLocked (bool v)
void SetIsSettingItem (bool v)
void SetIsTransient (bool v)
void SetIsUnpickable (bool v)
void SetItemDecayRate (float v)
 Set the item decay factor.
void SetItemQuality (float v)
 Sets the quality of the item.
void SetLoaded ()
 Flags that this item has been fully loaded, and is allowed to be saved on changes.
void SetLocationInWorld (InstanceID instance, psSectorInfo *sectorinfo, float loc_x, float loc_y, float loc_z, float loc_yrot)
void SetLocInParent (INVENTORY_SLOT_NUMBER location)
 Please consider using UpdateInventoryStatus() instead.
void SetLockpickSkill (PSSKILL v)
void SetLockStrength (unsigned int v)
void SetMaxItemQuality (float v)
 Sets the maximum allowed quality of the item by changing the item_stat.
bool SetMusicalSheet (const csString &newMusicalSheet)
 Sets the musical sheet.
void SetName (const char *newName)
virtual void SetOwningCharacter (psCharacter *owner)
 Alters the owning character of this item. Also see UpdateInventoryStatus.
void SetRotationInWorld (float loc_xrot, float loc_yrot, float loc_zrot)
 Set the x, y and z axis rotations for the item.
void SetScheduledItem (psScheduledItem *item)
bool SetSketch (const csString &newSketchData)
 Sets sketch data.
void SetStackCount (unsigned short v)
 Sets the stack count.
void SetTransformationEvent (psWorkGameEvent *t)
void SetUID (uint32 v)
 Sets the Unique ID of this item.
void SetUniqueStats (psItemStats *statptr)
 Used to set the UNIQUE flag in addition to setting base stats pointer TODO: This is pretty much untested at this point.
void SetXZRotationInWorld (float loc_xrot, float loc_zrot)
 Set the x and z axis rotations for the item (y set in SetLocationInWorld)
psItemSplitStack (unsigned short newstackcount)
 Splits an item instance representing a stack into two smaller stacks.
const char * ToString ()
void UpdateInventoryStatus (psCharacter *owner, uint32 parent_id, INVENTORY_SLOT_NUMBER slot)
void UpdateModifiers ()
 Recalculates the modifications for this item.
void UpdateView (Client *fromClient, EID eid, bool clear)
 inform clients on view updates
bool UsesAmmoType (uint32_t id) const
void ViewItem (Client *client, int containerID, INVENTORY_SLOT_NUMBER slotID)
 Send an item to the client.
virtual ~psItem ()
 Destructs the psItem, and, if this is a container, all contained items.

Static Public Member Functions

static csString GetQuantityName (const char *namePtr, int stack_count, PSITEMSTATS_CREATIVETYPE creativeType, bool giveDetail=false)

Protected Attributes

PSITEM_FLAGS flags
 Flags for this item instance.
bool loaded

Detailed Description

This class embodies item instances in the game.

Every item that can be picked up, dropped, traded, equipped, bought or sold is a psitem.

This class has some specific design philosophy.

First, each item instance has a unique 32 bit identifier. The database ensures that there can be only one entry per item identifier. This means if an item is truly duped it will not persist between world resets since the next load from the database will find only one entry for that item. In order to make this mean anything, certain situations must be carefully coded to avoid bypassing this protection. In any case where 1 item becomes multiple items (such as splitting a stack) the logic should be well defined and located in just one place (preferably within the psItem class). If a bug does arise, it should require a fix to a single location. Any instance where an item is legitimately duped will need to do more work to actually copy the item. The code will be required to basically reconstruct the item from the ground up. The new item will be a truly new item. Do not take this lightly.

----The only time an item instance should be duplicated is for Game Master level functions.----

Items are built from statistic entries (item stats). Most items will have a base item stat entry and 0 or more item stat entries that act as modifiers. Modifiers are permanent additions to an item instance. For example, you may be able to buy a normal 'short sword' from a merchant. This would be the base stat of the item. If you use a trade skill to sharpen the short sword, that may add the 'sharpened' modifier to the sword. The resulting item instance will still (and always) have the base stat of 'short sword'. In addition it will have the modifier of 'sharpened'. It may gain or lose modifiers through other actions. Temporary effects such as spells, poisons, etc are NOT modifiers. They should be handled differently. At this time there is no code to handle effects on items, but it should not be difficult to add once the parameters of effects are defined. The other type of item instance is a unique item. Unique items are truely unique. The unique item has its own entry for its stats in the database. Only one item instance will ever refer to this entry. If the item instance is destroyed, so is the entry. In some situations the item stats may be altered - either through an extremely difficult quest, or GM intervention. These alterations to the stats will alter the entries of the unique item stats. In addition, normal modifiers may also be applied.

----Unique items should be very difficult to obtain as they are a larger drain on server resources----

An item instance has four persistant-state related operations: Load() - Translates data from a database item instance entry into a usable psItem Save() - Saves a psItem. This creates a new Unique Identifier (UID) for the item instance if needed (if the UID is 0). DeleteItem() - (Called from psCharacterLoader) Destroys the item instance entry from the database. The psItem entry in memory should also be destroyed promptly.

Weight Rules: TODO: Containers will have a maximum carrying weight. Weight of stacks is a the count of the stack multiplied by the weight of the base item stat.

Size Rules: Size is single number (float) that relates to the length of the longest dimension measured in centimeters. Stacks do not affect size. Containers have a maximum content size. 65535 = infinite size. Items with 65535 cannot be put into any containers. Containers with 65535 max content size can contain any item except items with 65535 size.

TODO: Add effect data - such as spell effects or poision or whatever. TODO: Merge various mutually exclusive stats into unions to save space.

Definition at line 238 of file psitem.h.


Constructor & Destructor Documentation

psItem::psItem ( )

Constructs a psItem.

Does not assign a UID. After construction the caller should set the location in the world or place the item into a container with the parent's AddItemToContainer() member function. It should then call Save() to save the instance to the database.

virtual psItem::~psItem ( ) [virtual]

Destructs the psItem, and, if this is a container, all contained items.

Does NOT remove any items from the database.


Member Function Documentation

float psItem::AddDecay ( float  severityFactor)

Adjust the item quality by an amount of decay.

void psItem::AddLootModifier ( uint32_t  id,
int  pos = -1 
)

Allows to add a modification to the item.

Todo:
For now the system, even if adapted to allow an unspecified amount of modifications now, in the LOAD and Save it supports only 3: a prefix, a suffix and an adjective. Should make the schema allow to receive an unspecified amount of modifiers too. so the pos variable should be removed when that will be implemented.
Parameters:
idThe id of the modification to apply to this item.
posThe position in the array where to put this modifications (note it overwrites what's there)
bool psItem::AddModifier ( psItemStats modifier)

Adds a modifier to this item instance if there is space available.

Current stats are automaticaly updated.

TODO: A DeleteModifier() function may be warranted in the future.

void psItem::AddOpenableLock ( uint32  v)
double psItem::CalcFunction ( MathEnvironment env,
const char *  functionName,
const double *  params 
) [virtual]

Implements iScriptableVar.

void psItem::CancelEquipScript ( )
bool psItem::CanOpenLock ( uint32  id,
bool  includeSkel 
) const
bool psItem::CheckRequirements ( psCharacter character,
csString &  resp 
)

Check to see if the character meets the requirements for this item.

bool psItem::CheckStackableWith ( const psItem otheritem,
bool  precise,
bool  checkStackCount = true,
bool  checkWorld = true 
) const

Check if otheritem is stackable with this item.

Parameters:
otheritemThe item to check if this item is stackable with.
preciseIs the quality, max quality and crafter the same.
checkStackCountSheck the stack count.
checkWorldChecks if stackability is possible in the world (eg: instances comparing)
void psItem::ClearOpenableLocks ( )
void psItem::CombineStack ( psItem *&  stackme)

Combines 'stackme' with this item.

You must call CheckStackableWith first; this ASSERTS if the two are not stackable.

bool psItem::CompareOpenableLocks ( const psItem key) const
virtual psItem* psItem::Copy ( unsigned short  newstackcount) [virtual]

Duplicates an item instance.

The parameter is the stack count of the new item. The return value must be checked for NULL. The returned item will not have a valid location nor a valid UID. The location in the world or on an owning player must be set first, and then Save() called to generate a UID and save to the database.

virtual void psItem::Copy ( psItem target) [virtual]

Copies values of its attributes to item 'target'.

void psItem::CopyOpenableLock ( psItem origKey)
virtual psItem* psItem::CreateNew ( ) [inline, virtual]

Creates a new blank instance of it's class (i.e.

psItem or its subclass)

Reimplemented in psGlyph.

Definition at line 614 of file psitem.h.

bool psItem::DeleteFromDatabase ( )
virtual void psItem::DeleteObjectCallback ( iDeleteNotificationObject object) [virtual]

Handles deleted gem objects.

Implements iDeleteObjectCallback.

bool psItem::Destroy ( )

Called when an item is completely destroyed from the persistant world.

Persistant refers to the item existing through a reset of the server. This definition can affect when an item should be "destroyed" (removed from the database). For example, if items dropped on the ground will be forever lost if the server goes down, then when an item is dropped on the group, DestroyItem() should be used instead of UpdateItem(). When the item is picked up again, CreateItem() should be called.

bool psItem::FitsInSlot ( INVENTORY_SLOT_NUMBER  slot)
bool psItem::FitsInSlots ( PSITEMSTATS_SLOTLIST  slotmask)
void psItem::ForceSaveIfNew ( )

Saves this item now if it hasn't been saved before, to force the generation of a UID.

PSITEMSTATS_AMMOTYPE psItem::GetAmmoType ( )
PSITEMSTATS_ARMORTYPE psItem::GetArmorType ( )
float psItem::GetArmorVSWeaponResistance ( psItemStats armor)

Gets the reduction of this weapon against the armor given.

int psItem::GetAttackAnimID ( psCharacter pschar)

TODO: Comment me with something more than "Gets the attack animation ID".

psItemStats* psItem::GetBaseStats ( ) const [inline]

Returns the base stats for this item instance.

You may want to use this only to see this item instance is a specific type of item Do not use for retrieval of values for calculations (such as damage).

Definition at line 732 of file psitem.h.

csString psItem::GetBookText ( ) [inline]

Gets the book text, should only be used if this is a book.

Definition at line 1150 of file psitem.h.

bool psItem::GetBuyPersonalise ( )
bool psItem::GetCanTransform ( )
psItemCategory* psItem::GetCategory ( )
int psItem::GetCharges ( ) const
uint32 psItem::GetContainerID ( ) const [inline]

Returns the item that contains this item, or NULL if it's not contained by another item.

Definition at line 699 of file psitem.h.

unsigned short psItem::GetContainerMaxSize ( )
int psItem::GetContainerMaxSlots ( )

Gets the slots available in this item (only containers) which means also the maximum amount of items which can be stored in this container.

Note:
this function uses the base item stats of this item.
Returns:
The number of slots available in this container.
float psItem::GetCounterBlockValue ( )
PID psItem::GetCrafterID ( ) const [inline]

Returns the UID for the crafter of this item. Be sure to check GetIsCrafterIDValid()!

Definition at line 525 of file psitem.h.

PSITEMSTATS_CREATIVETYPE psItem::GetCreative ( )
const csString& psItem::GetCreativeBackgroundImg ( ) [inline]

return the background image used in this creative.

Definition at line 1230 of file psitem.h.

PID psItem::GetCreator ( PSITEMSTATS_CREATORSTATUS creatorStatus)

Gets the creator of this creative and the creator setting status.

Parameters:
creatorStatusThe status of the creator setting in this creative
Returns:
PID The PID of the player who created this creative or 0 if not set or invalid.
psItemStats* psItem::GetCurrentStats ( ) const [inline]

Gets a pointer to the current stats.

You probably dont want to use this. Use the functions below which may apply additional logic to determine what value to return.

Definition at line 746 of file psitem.h.

float psItem::GetDamage ( PSITEMSTATS_DAMAGETYPE  dmgtype)
float psItem::GetDamageProtection ( PSITEMSTATS_DAMAGETYPE  dmgtype)
float psItem::GetDecay ( )

Returns the decay value of the item. See the decay member for a description of what this is.

float psItem::GetDecayResistance ( )
const char* psItem::GetDescription ( ) const

Fetch the psitem description if it's not null, otherwise the current_stats description.

Returns:
the psitem description if it's not null, otherwise the current_stats description.
PSITEM_FLAGS psItem::GetFlags ( ) [inline]

Definition at line 756 of file psitem.h.

gemItem* psItem::GetGemObject ( void  ) [inline]

Definition at line 260 of file psitem.h.

PID psItem::GetGuardingCharacterID ( ) const [inline]

Item guardians: items dropped in the world or placed in a public container are not owned, but "guarded" by a character.

Definition at line 689 of file psitem.h.

unsigned int psItem::GetGuildID ( ) const [inline]

Returns the UID for the guild who has certified this item. Be sure to check GetIsGuildIDValid()!

Definition at line 533 of file psitem.h.

float psItem::GetHardness ( )
int psItem::GetIdentifyMinSkill ( )

Returns minimum skill level to identify certain examined items.

int psItem::GetIdentifySkill ( )

Returns skill id of skill needed to identify examined items.

const char* psItem::GetImageName ( )

Get the Image Name for the item.

Used in inventory and other location where item has to be presented by a 2D image.

bool psItem::GetIsAmmo ( )
bool psItem::GetIsArmor ( )
bool psItem::GetIsAutoTransformContainer ( )
bool psItem::GetIsBothHandsWeapon ( )
bool psItem::GetIsCD ( ) const [inline]

Definition at line 1065 of file psitem.h.

bool psItem::GetIsConstructible ( )
bool psItem::GetIsContainer ( )
bool psItem::GetIsCrafterIDValid ( )

Returns true if the crafter character ID is valid.

bool psItem::GetIsEquipStackable ( ) const
bool psItem::GetIsGuildIDValid ( )

Returns true if the certifying guild ID is valid.

bool psItem::GetIsIdentifiable ( ) [inline]

Get the identifiable status of the item.

Definition at line 1244 of file psitem.h.

bool psItem::GetIsKey ( ) const [inline]

Definition at line 1077 of file psitem.h.

bool psItem::GetIsLockable ( ) [inline]

Definition at line 1023 of file psitem.h.

bool psItem::GetIsLocked ( ) [inline]

Definition at line 1017 of file psitem.h.

bool psItem::GetIsMasterKey ( ) const [inline]

Definition at line 1083 of file psitem.h.

bool psItem::GetIsMeleeWeapon ( )
bool psItem::GetIsNoPickup ( ) [inline]

Gets if the item has a no pickup flag set.

Returns:
TRUE if the item has a no pickup flag set.

Definition at line 1044 of file psitem.h.

bool psItem::GetIsNoPickupStrong ( ) [inline]

Checks if the item has a strong no pickup flag set.

Returns:
TRUE has a strong no pickup flag set.

Definition at line 1052 of file psitem.h.

bool psItem::GetIsNoPickupWeak ( ) [inline]

Checks if the item has a weak no pickup flag set.

Returns:
TRUE has a weak no pickup flag set.

Definition at line 1060 of file psitem.h.

bool psItem::GetIsNpcOwned ( ) const [inline]

Definition at line 1071 of file psitem.h.

bool psItem::GetIsRangeWeapon ( )
bool psItem::GetIsReadable ( )

Checks the readable flag in the item_stats and tell if this is the case.

Returns:
TRUE if the item is readable.
bool psItem::GetIsSecurityLocked ( ) [inline]

Definition at line 1029 of file psitem.h.

bool psItem::GetIsSettingItem ( ) const [inline]

Definition at line 1108 of file psitem.h.

bool psItem::GetIsShield ( )
bool psItem::GetIsSkeleton ( )
bool psItem::GetIsStackable ( ) const
bool psItem::GetIsTrap ( )
bool psItem::GetIsUnique ( ) const

Returns true if this item is based off of unique statistics.

Items with unique statistics will be especially rare. Some special operations are possible on unique items

bool psItem::GetIsUnpickable ( ) [inline]

Definition at line 1035 of file psitem.h.

bool psItem::GetIsWriteable ( )

Checks the writeable flag in the item_stats and tell if this is the case.

Returns:
TRUE if the item is writeable.
csString psItem::GetItemCommand ( ) [inline]

returns the special command assigned to this item

Definition at line 1168 of file psitem.h.

float psItem::GetItemDecayRate ( ) [inline]

Get the item decay factor.

Definition at line 570 of file psitem.h.

float psItem::GetItemQuality ( ) const

Gets the quality of the item.

float psItem::GetItemSize ( )
virtual const char* psItem::GetItemType ( ) [inline, virtual]

Return a string identifying this object as an Item.

Reimplemented in psGlyph.

Definition at line 255 of file psitem.h.

float psItem::GetLatency ( )
const csString& psItem::GetLiteratureText ( void  ) [inline]

return creative contents of books.

Definition at line 1225 of file psitem.h.

void psItem::GetLocationInWorld ( InstanceID instance,
psSectorInfo **  sectorinfo,
float loc_x,
float loc_y,
float loc_z,
float loc_yrot 
) const
INVENTORY_SLOT_NUMBER psItem::GetLocInParent ( bool  adjustSlot = false)

Returns the location of this item in its parent item or in the player's equipment, bulk or bank as appropriate.

PSSKILL psItem::GetLockpickSkill ( ) [inline]

Definition at line 1114 of file psitem.h.

unsigned int psItem::GetLockStrength ( ) [inline]

Definition at line 1120 of file psitem.h.

int psItem::GetMaxCharges ( ) const
float psItem::GetMaxItemQuality ( ) const

Gets the maximum possible quality of the item by reading the item_stat.

const char* psItem::GetMeshName ( )

Get the Mesh Name for the item.

Used for standalone or weilded mesh.

psItemStats* psItem::GetModifier ( int  index)

Returns the modifier at a specific index 0 through PSITEM_MAX_MODIFIERS-1.

const char* psItem::GetModifiersDescription ( )

If an overlay is set return it's script description, otherwise return the.

Returns:
the description of the overlay's script (only if present) or the desc. of the base_stats's (base item) script
const csString& psItem::GetMusicalSheet ( void  ) [inline]

return creative contents of musical sheets.

Definition at line 1220 of file psitem.h.

const char* psItem::GetName ( ) const
csString psItem::GetOpenableLockNames ( )
psCharacter* psItem::GetOwningCharacter ( ) [inline]

Returns a pointer to the character who is holding this item directly or indirectly (including containers and bank slots) or NULL if none.

Returns NULL if on the ground or in a container on the ground.

This should always be valid since items should be destroyed when the character logs off

Definition at line 672 of file psitem.h.

PID psItem::GetOwningCharacterID ( ) const [inline]

Get the ID of the owning character.

This is required in cases where the owning character may not be online and the above pointer is undefined.

Definition at line 679 of file psitem.h.

const char* psItem::GetPartMeshName ( )

Get the Part Mesh Name for the item.

This is the new mesh to be attached to the location given by the pattern Part Name.

const char* psItem::GetPartName ( )

Get the Part Name for the item.

This is the name of the part that the texture should be attached to if no change of mesh.

float psItem::GetPenetration ( )
psMoney psItem::GetPrice ( )
double psItem::GetProperty ( MathEnvironment env,
const char *  ptr 
) [virtual]

This is used by the math scripting engine to get various values.

Implements iScriptableVar.

virtual int psItem::GetPurifyStatus ( ) const [inline, virtual]

Reimplemented in psGlyph.

Definition at line 766 of file psitem.h.

const char* psItem::GetQualityString ( )

Returns a description of the quality level of item.

csString psItem::GetQuantityName ( )
static csString psItem::GetQuantityName ( const char *  namePtr,
int  stack_count,
PSITEMSTATS_CREATIVETYPE  creativeType,
bool  giveDetail = false 
) [static]
float psItem::GetRange ( ) const [inline]

Definition at line 835 of file psitem.h.

float psItem::GetRarity ( )

return Rarity as 0-100% range

csString psItem::GetRarityName ( )

return Rarity description. example: "rare (0.7%)"

int psItem::GetRequiredRepairTool ( )

Returns item_stats id of repair tool required to fix this item, or 0.

bool psItem::GetRequiredRepairToolConsumed ( )

Returns the is_consumed flag of repair tool required to fix this item.

void psItem::GetRotationInWorld ( float loc_xrot,
float loc_yrot,
float loc_zrot 
)

Get the x,y and z axis rotations for the item.

Parameters:
loc_xrotthe variable in which the x rotation will be stored
loc_yrotthe variable in which the y rotation will be stored
loc_zrotthe variable in which the z rotation will be stored
psScheduledItem* psItem::GetScheduledItem ( ) [inline]

Definition at line 1136 of file psitem.h.

psSectorInfo* psItem::GetSector ( ) const [inline]

Definition at line 929 of file psitem.h.

psMoney psItem::GetSellPrice ( )

Merchants want a percentage.

const csString& psItem::GetSketch ( void  ) [inline]

return creative contents of sketches.

Definition at line 1215 of file psitem.h.

csString psItem::GetSlotRemovedMesh ( int  slot,
csString  meshName = "" 
) [inline]

Proxies the same function in psitemstats which gets the list of mesh to remove when this item is equipped in the specified slot.

Parameters:
slotThe slot this item is being equipped into.
meshNameThe meshName we are sarching for the slot to remove for it.
Returns:
The list of meshes to remove when equipping this item.

Definition at line 888 of file psitem.h.

const char* psItem::GetSound ( )
unsigned short psItem::GetStackCount ( ) const [inline]

Returns the stack count. Be sure to call GetIsStackable() first!

Definition at line 656 of file psitem.h.

const char* psItem::GetStandardDescription ( )
const char* psItem::GetStandardName ( )
float psItem::GetTargetedBlockValue ( )
const char* psItem::GetTextureName ( )

Get the Texture Name for the item.

Used when worn and attached to the mesh given by part name.

float psItem::GetTotalStackSize ( ) [inline]

Gets the total size of the items in the stack.

Definition at line 864 of file psitem.h.

psWorkGameEvent* psItem::GetTransformationEvent ( ) [inline]

Definition at line 266 of file psitem.h.

uint32 psItem::GetUID ( ) [inline]

Returns the UID of this item instance.

0 is reserved for no UID assigned yet. Items are initially created with a UID of 0. Save() generates a unique item id.

Definition at line 504 of file psitem.h.

float psItem::GetUntargetedBlockValue ( )
bool psItem::GetUsesAmmo ( )
PSITEMSTATS_SLOTLIST psItem::GetValidSlots ( )
float psItem::GetVisibleDistance ( )
float psItem::GetWeaponAttributeBonus ( PSITEMSTATS_STAT  stat)
float psItem::GetWeaponAttributeBonusMax ( int  index)
PSITEMSTATS_STAT psItem::GetWeaponAttributeBonusType ( int  index)
PSSKILL psItem::GetWeaponSkill ( PSITEMSTATS_WEAPONSKILL_INDEX  index)
psWeaponType* psItem::GetWeaponType ( )
float psItem::GetWeight ( )
void psItem::GetXZRotationInWorld ( float loc_xrot,
float loc_zrot 
)

Get the x and z axis rotations for the item (y obtained in GetLocationInWorld)

Parameters:
loc_xrotthe variable in which the x rotation will be stored
loc_zrotthe variable in which the z rotation will be stored
bool psItem::HasCharges ( ) const
bool psItem::HasModifier ( psItemStats modifier)

Returns true if this item has this modifier in its modifier list.

This can be used to make sure an item doesn't get the same modifier multiple times or if an item needs to have a specific modifier to be used for something.

TODO: In the future we may expand this to functions that check for "similar" modifiers to a given modifier.

bool psItem::IsActive ( ) const
bool psItem::IsEquipped ( ) const
bool psItem::IsInUse ( ) [inline]

Definition at line 577 of file psitem.h.

bool psItem::IsRechargeable ( ) const
bool psItem::IsThisTheCreator ( PID  pid)

Checks if the creator of the book is the one passed as argument.

Parameters:
pidthe PID of the character we are checking creator status.
bool psItem::IsTransient ( ) [inline]

Definition at line 1089 of file psitem.h.

virtual bool psItem::Load ( iResultRow &  row) [virtual]

Loads data from a database row into the current psItem.

This is used only by the character loader. On return parentid is set to the UID of the parent item. UID 0 is reserved for no parent.

Reimplemented in psGlyph.

void psItem::MakeSkeleton ( bool  b)
void psItem::operator delete ( void *  )

The delete operator is overriden to call PoolAllocator template functions.

Reimplemented in psGlyph.

void* psItem::operator new ( size_t  )

The new operator is overriden to call PoolAllocator template functions.

Reimplemented in psGlyph.

PSITEM_FLAGS psItem::ParseItemFlags ( csString  flagstr)

Parses an item flags list and returns the flags.

void psItem::PrepareCreativeItemInstance ( )
void psItem::RecalcCurrentStats ( )

In some cases some modifiers or effects may be difficult to reverse (for example percent bonuses applied and removed in different orders).

In these cases it should be safe to call RecalcCurrentStats() which takes a bit longer, but builds the current stats back up from the base.

void psItem::RemoveOpenableLock ( uint32  v)
void psItem::ResetItemStackable ( )
void psItem::RunEquipScript ( gemActor actor)
void psItem::Save ( bool  children)

Queues this item to be saved to the database.

(DB action will be executed after 500ms) Call this after EVERY change of a persistant property, and the system will ensure that any sequence of changes will result in only one DB hit.

void psItem::ScheduleRemoval ( )

This function handles creating an event manager event at the right time to get transient objects removed from the world automatically.

void psItem::ScheduleRespawn ( )
bool psItem::SendActionContents ( Client client,
psActionLocation action 
)
bool psItem::SendContainerContents ( Client client,
int  containerID = CONTAINER_INVENTORY_BULK 
)
bool psItem::SendItemDescription ( Client client)
void psItem::SetActive ( bool  state)
void psItem::SetBaseStats ( psItemStats statptr)

Alters the base stats of this item instance.

If called on a unique item it revokes the unique item status of this item! If called on a unique item the unique item stats should be destroyed elsewhere.

bool psItem::SetBookText ( const csString &  newText)

Sets the book text, should only be used if this is a book.

void psItem::SetCharges ( int  charges)
void psItem::SetContainerID ( uint32  parentId) [inline]

Definition at line 703 of file psitem.h.

void psItem::SetCrafterID ( PID  v)

Sets the UID for the cracter of this item. Generally used immediately after completing the crafting work.

bool psItem::SetCreation ( PSITEMSTATS_CREATIVETYPE  ,
const csString &  ,
csString   
)

Write creative stuff such as lit text (eg book) or map data.

void psItem::SetCreator ( PID  ,
PSITEMSTATS_CREATORSTATUS   
)

sets the creator (i.e. author, artist, etc) of creative things

void psItem::SetCurrentStats ( psItemStats statptr)

Sets the current item stats.

DO NOT USE! This is used mostly internally. The current stats either point to the same entry as the base stats or a stats entry that is the sum of the base stats plus modifiers and effects.

void psItem::SetDecay ( float  v)

Sets the decay value of the item. See the decay member for a description of what this is.

void psItem::SetDecayResistance ( float  v)

Set the decay resistance percentage for the item.

void psItem::SetDescription ( const char *  newDescription)
void psItem::SetFlags ( int  f) [inline]

Definition at line 761 of file psitem.h.

void psItem::SetGemObject ( gemItem object)
void psItem::SetGuardingCharacterID ( PID  guardian) [inline]

Definition at line 693 of file psitem.h.

void psItem::SetGuildID ( unsigned int  v)

Sets the UID for the guild certifying this item.

void psItem::SetInUse ( bool  flag) [inline]

Definition at line 581 of file psitem.h.

void psItem::SetIsCD ( bool  v)
void psItem::SetIsCrafterIDValid ( bool  v)

Set wether the crafter ID is valid. SetCrafterID() sets this to true for you.

void psItem::SetIsGuildIDValid ( bool  v)

Set wether the guild ID is valid. SetGuildID() sets this to true for you.

void psItem::SetIsIdentifiable ( bool  v)

Set the Identifiable flag of the item.

void psItem::SetIsItemStackable ( bool  v)
void psItem::SetIsKey ( bool  v)
void psItem::SetIsLockable ( bool  v)
void psItem::SetIsLocked ( bool  v)
void psItem::SetIsMasterKey ( bool  v)
void psItem::SetIsNpcOwned ( bool  v)
void psItem::SetIsPickupable ( bool  v)

Sets the pickupable flag in order to not allow/allow the item to be picked up.

Parameters:
vFALSE if the no pickup flag should be set.
void psItem::SetIsPickupableWeak ( bool  v)

Sets the weak pickupable flag in order to not allow/allow the item to be picked up.

Parameters:
vFALSE if the weak no pickup flag should be set.
void psItem::SetIsSecurityLocked ( bool  v)
void psItem::SetIsSettingItem ( bool  v)
void psItem::SetIsTransient ( bool  v)
void psItem::SetIsUnpickable ( bool  v)
void psItem::SetItemDecayRate ( float  v)

Set the item decay factor.

void psItem::SetItemQuality ( float  v)

Sets the quality of the item.

void psItem::SetLoaded ( ) [inline]

Flags that this item has been fully loaded, and is allowed to be saved on changes.

This MUST be called after this item is constructed AND it's initial properties are set. (includes normal loading, InstantiateBasicItem(), etc.)

Definition at line 491 of file psitem.h.

void psItem::SetLocationInWorld ( InstanceID  instance,
psSectorInfo sectorinfo,
float  loc_x,
float  loc_y,
float  loc_z,
float  loc_yrot 
)
void psItem::SetLocInParent ( INVENTORY_SLOT_NUMBER  location)

Please consider using UpdateInventoryStatus() instead.

void psItem::SetLockpickSkill ( PSSKILL  v)
void psItem::SetLockStrength ( unsigned int  v)
void psItem::SetMaxItemQuality ( float  v)

Sets the maximum allowed quality of the item by changing the item_stat.

bool psItem::SetMusicalSheet ( const csString &  newMusicalSheet)

Sets the musical sheet.

void psItem::SetName ( const char *  newName)
virtual void psItem::SetOwningCharacter ( psCharacter owner) [virtual]

Alters the owning character of this item. Also see UpdateInventoryStatus.

Reimplemented in psGlyph.

void psItem::SetRotationInWorld ( float  loc_xrot,
float  loc_yrot,
float  loc_zrot 
)

Set the x, y and z axis rotations for the item.

Parameters:
loc_xrotthe variable used to set the x rotation of the item
loc_yrotthe variable used to set the x rotation of the item
loc_zrotthe variable used to set the z rotation of the item
void psItem::SetScheduledItem ( psScheduledItem item) [inline]

Definition at line 1140 of file psitem.h.

bool psItem::SetSketch ( const csString &  newSketchData)

Sets sketch data.

void psItem::SetStackCount ( unsigned short  v)

Sets the stack count.

Be sure to call GetIsStackable() first! Don't call this to try and combine or split stacks! That logic is done in CombineStack() and SplitStack().

void psItem::SetTransformationEvent ( psWorkGameEvent t) [inline]

Definition at line 270 of file psitem.h.

void psItem::SetUID ( uint32  v)

Sets the Unique ID of this item.

DO NOT CALL THIS. This should ONLY be called internally or from psCharacterLoader.

void psItem::SetUniqueStats ( psItemStats statptr)

Used to set the UNIQUE flag in addition to setting base stats pointer TODO: This is pretty much untested at this point.

void psItem::SetXZRotationInWorld ( float  loc_xrot,
float  loc_zrot 
)

Set the x and z axis rotations for the item (y set in SetLocationInWorld)

Parameters:
loc_xrotthe variable used to set the x rotation of the item
loc_zrotthe variable used to set the z rotation of the item
psItem* psItem::SplitStack ( unsigned short  newstackcount)

Splits an item instance representing a stack into two smaller stacks.

The parameter is the size of the new stack. The return value must be checked for NULL. The returned item will not have a valid location nor a valid UID. The location in the world or on an owning player must be set first, and then Save() called to generate a UID and save to the database.

const char* psItem::ToString ( ) [inline, virtual]

Implements iScriptableVar.

Definition at line 1012 of file psitem.h.

void psItem::UpdateInventoryStatus ( psCharacter owner,
uint32  parent_id,
INVENTORY_SLOT_NUMBER  slot 
)
void psItem::UpdateModifiers ( )

Recalculates the modifications for this item.

void psItem::UpdateView ( Client fromClient,
EID  eid,
bool  clear 
)

inform clients on view updates

bool psItem::UsesAmmoType ( uint32_t  id) const [inline]

Definition at line 839 of file psitem.h.

void psItem::ViewItem ( Client client,
int  containerID,
INVENTORY_SLOT_NUMBER  slotID 
)

Send an item to the client.

Parameters:
clientThe client the message is for.
containerIDthe ID of the owning container
slotIDthe slot this item is in TODO check if we can't get the data our self

Member Data Documentation

Flags for this item instance.

Flags are described at the top of this file. Note that psItemStats also has flags that are stored separately. If you're looking for a flag that you think should be here, check psItemStats to be sure it's not a stat flag instead of an instance flag. Flags are indicated in the database as text, e.g. "NOPICKUP" in the flags column

Definition at line 362 of file psitem.h.

bool psItem::loaded [protected]

Definition at line 1267 of file psitem.h.

Definition at line 328 of file psitem.h.

Definition at line 329 of file psitem.h.

Definition at line 330 of file psitem.h.

Definition at line 329 of file psitem.h.

Definition at line 330 of file psitem.h.

Definition at line 329 of file psitem.h.

Definition at line 330 of file psitem.h.

Definition at line 331 of file psitem.h.


The documentation for this class was generated from the following file: