CItem Class¶
Overview¶
Note
The CItem class handles game items and equiptment
The structures used for this class are CItem, CResItem, Item_Header_st, Item_ability_st, Item_effect_st
Quick Reference¶
Quick Ref |
void CItem::CItem() |
void CItem::CItem(CItem& item) |
void CItem::CItem(CCreatureFileItem& item) |
void CItem::CItem(CResRef id, unsigned short useCount1, unsigned short useCount2, unsigned short useCount3, unsigned short wear, unsigned long flags) |
virtual void CItem::~CItem() |
int CItem::Demand() |
void CItem::Equip(CGameSprite* pSprite, long slotNum, int animationOnly) |
Item_ability_st* CItem::GetAbility(long abilityNum) |
int CItem::GetAbilityCount() |
CGameEffect* CItem::GetAbilityEffect(long abilityNum, long effectNum, CGameObject* pObject) |
unsigned short CItem::GetAnimationType() |
unsigned long CItem::GetBaseValue() |
unsigned long CItem::GetDescription() |
unsigned long CItem::GetFlagsFile() |
unsigned long CItem::GetGenericName() |
CResRef CItem::GetGroundIcon() |
int CItem::GetInventorySlotType() |
CCreatureFileItem CItem::GetItemFile() |
CResRef CItem::GetItemIcon() |
const unsigned short CItem::GetItemType() |
unsigned short CItem::GetLoreValue() |
unsigned short CItem::GetMaxStackable() |
unsigned short CItem::GetMaxUsageCount(int nAbility) |
unsigned char CItem::GetMinCHRRequired() |
unsigned char CItem::GetMinCONRequired() |
unsigned char CItem::GetMinDEXRequired() |
unsigned char CItem::GetMinINTRequired() |
unsigned char CItem::GetMinLevelRequired() |
unsigned char CItem::GetMinSTRBonusRequired() |
unsigned char CItem::GetMinSTRRequired() |
unsigned char CItem::GetMinWISRequired() |
unsigned long CItem::GetNotUsableBy() |
unsigned long CItem::GetNotUsableBy2() |
unsigned char CItem::GetProficiencyType() |
CString CItem::GetUsabilityText() |
unsigned short CItem::GetUsageCount(int nAbility) |
CResRef CItem::GetUsedUpItemId() |
unsigned long CItem::GetWeight() |
void CItem::LoadUsability() |
void CItem::LoadWeaponIdentification(CWeaponIdentification& weaponId) |
void CItem::PushToLua(int skipDescriptionText) |
void CItem::ResolveRandomItem(CResRef& id) |
void CItem::SetResRef(CResRef& cNewResRef, int bSetAutoRequest) |
void CItem::SetUsageCount(int nAbility, unsigned short wUseCount) |
void CItem::SetWear(unsigned short newWear) |
unsigned char CItem::TranslateAnimationType(CString& equipCode, CGameSprite* pSprite) |
void CItem::Unequip(CGameSprite* pSprite, long slotNum, int recalculateEffects, int animationOnly) |
bool CItem::operator!=(CItem& item) |
Constructors¶
Name |
Description |
Constructs a |
|
Destroys a |
CItem::CItem¶
Constructs a CItem
object
void CItem::CItem();
Remarks
Constructs a CItem
object
CItem::CItem¶
Constructs a CItem
object
void CItem::CItem(CItem& item);
Parameters
CItem& item -
Remarks
Constructs a CItem
object
CItem::CItem¶
Constructs a CItem
object
void CItem::CItem(CCreatureFileItem& item);
Parameters
CCreatureFileItem& item -
Remarks
Constructs a CItem
object
CItem::CItem¶
Constructs a CItem
object
void CItem::CItem(
CResRef id,
unsigned short useCount1,
unsigned short useCount2,
unsigned short useCount3,
unsigned short wear,
unsigned long flags);
Parameters
CResRef id -
unsigned short
useCount1 -unsigned short
useCount2 -unsigned short
useCount3 -unsigned short
wear -unsigned long
flags -
Remarks
Constructs a CItem
object
CItem::~CItem¶
Destroys the CItem
object
virtual void CItem::~CItem();
Remarks
Destroys the CItem
object
Methods¶
Name |
Description |
Returns animation type for the item |
|
Returns base value of the item |
|
Returns a String Reference (StrRef) for the description of the item |
|
Returns item flags |
|
Returns a String Reference (StrRef) for the name of the item |
|
Returns a resource reference for the icon used for when the item is on the ground |
|
Returns the item inventory slot type |
|
Returns the creature item file |
|
Returns a resource reference for the icon used for the item |
|
Returns the item type |
|
Returns the lore value for the item |
|
Returns the maximum stackable value of items when grouped (stacked) together |
|
Returns the maximum usage count or charges of an item |
|
Returns the minimum charisma score required to be able to use the item |
|
Returns the minimum constitution score required to be able to use the item |
|
Returns the minimum dexterity score required to be able to use the item |
|
Returns the minimum intelligence score required to be able to use the item |
|
Returns the minimum character class level required to be able to use the item |
|
Returns the minimum exceptional strength score required to be able to use the item |
|
Returns the minimum strength score required to be able to use the item |
|
Returns the minimum wisdom score required to be able to use the item |
|
Returns a not usable by a class bit mask |
|
Returns a 2nd not usable by a class bit mask |
|
Returns a weapon proficiency type |
|
Returns a string describing the restrictions of the item’s use |
|
CItem::Demand¶
int CItem::Demand();
Return Value
Returns int
Remarks
CItem::Equip¶
void CItem::Equip(
:ref:`CGameSprite<CGameSprite>`\* pSprite,
long slotNum,
int animationOnly);
Parameters
CGameSprite* pSprite -
long
slotNum -int
animationOnly -
Remarks
CItem::GetAbility¶
Item_ability_st\* CItem::GetAbility(long abilityNum);
Parameters
long
abilityNum -
Return Value
Returns Item_ability_st*
Remarks
CItem::GetAbilityCount¶
int CItem::GetAbilityCount();
Return Value
Returns int
Remarks
CItem::GetAbilityEffect¶
CGameEffect* CItem::GetAbilityEffect(
long abilityNum,
long effectNum,
CGameObject* pObject);
Parameters
long
abilityNum -long
effectNum -CGameObject* pObject -
Return Value
Returns CGameEffect*
Remarks
CItem::GetAnimationType¶
Returns animation type for the item
unsigned short CItem::GetAnimationType();
Return Value
Returns an unsigned short
, the animation type for the item
Remarks
Returns (256 * Item_Header_st.animationType[1]) + Item_Header_st.animationType[2]
or 0
if error
CItem::GetBaseValue¶
Returns base value of the item
unsigned long CItem::GetBaseValue();
Return Value
Returns unsigned long
, the base value of the item
Remarks
Returns the Item_Header_st.baseValue field value
CItem::GetDescription¶
Returns a String Reference (StrRef) for the description of the item
unsigned long CItem::GetDescription();
Return Value
Returns unsigned long
, a StrRef value for the item’s description
Remarks
The String Reference (StrRef) return value is from Item_Header_st.genericDescription or Item_Header_st.identifiedDescription depending on wether the item has been identified or not.
The CItem.m_flags** field is checked for a value of 1
and returns the value in Item_Header_st.identifiedDescription if it is, or Item_Header_st.genericDescription if CItem.m_flags is any other value
CItem.m_flags field can contain bit values from INVITEM.IDS
:
1 IDENTIFIED
2 NONSTEALABLE
4 STOLEN
8 NONDROPABLE
See also CItem::GetGenericName
CItem::GetFlagsFile¶
Returns item flags
unsigned long CItem::GetFlagsFile();
Return Value
Returns unsigned long
Remarks
Returns the value of the Item_Header_st.itemFlags field
CItem::GetGenericName¶
Returns a String Reference (StrRef) for the name of the item
unsigned long CItem::GetGenericName();
Return Value
Returns unsigned long
, a StrRef value for the item’s name
Remarks
The String Reference (StrRef) return value is from Item_Header_st.genericName or Item_Header_st.identifiedName depending on wether the item has been identified or not.
The CItem.m_flags field is checked for a value of 1
and returns the value in Item_Header_st.identifiedName if it is, or Item_Header_st.genericName if CItem.m_flags is any other value
CItem.m_flags field can contain bit values from INVITEM.IDS
:
1 IDENTIFIED
2 NONSTEALABLE
4 STOLEN
8 NONDROPABLE
See also CItem::GetDescription
CItem::GetGroundIcon¶
Returns a resource reference for the icon used for when the item is on the ground
CResRef CItem::GetGroundIcon();
Return Value
Returns a CResRef resource reference
Remarks
Returns the resource reference stored in the Item_Header_st.groundIcon[8] field.
If there is no ground icon for the item, it returns a default/generic sack icon resource reference: “gsack01” - which is for gsack01.bam
See also CItem::GetItemIcon
CItem::GetInventorySlotType¶
Returns the item inventory slot type
int CItem::GetInventorySlotType();
Return Value
Returns an int
value representing the item inventory slot type
Remarks
Fetches the value stored in the Item_Header_st.itemType field
If the value in Item_Header_st.itemType is less than or equal to 26
then it calls CScreenInventory::MapButtonIdToInventoryId. The values 0
to 26
can be found in ITEMCAT.IDS
:
0 MISC
1 AMULET
2 ARMOR
3 BELT
4 BOOT
5 ARROW
6 BRACER
7 HELMET
8 KEY
9 POTION
10 RING
11 SCROLL
12 SHIELD
13 FOOD
14 BULLET
15 BOW
16 DAGGER
17 MACE
18 SLING
19 SMSWORD
20 BGSWORD
21 HAMMER
22 MSTAR
23 FLAIL
24 DART
25 AXE
26 STAFF
If the value in Item_Header_st.itemType is greater than 26
then it calls CRuleTables::GetItemTypeSlot and returns a value from SLOTS.IDS
:
0 SLOT_AMULET
1 SLOT_ARMOR
2 SLOT_BELT
3 SLOT_BOOTS
4 SLOT_CLOAK
5 SLOT_GAUNTLETS
6 SLOT_HELMET
7 SLOT_RING_LEFT
8 SLOT_RING_RIGHT
9 SLOT_SHIELD
10 SLOT_FIST
11 SLOT_AMMO
15 SLOT_MISC
35 SLOT_WEAPON
11 SLOT_AMMO0
12 SLOT_AMMO1
13 SLOT_AMMO2
14 SLOT_AMMO3
15 SLOT_MISC0
16 SLOT_MISC1
17 SLOT_MISC2
18 SLOT_MISC3
19 SLOT_MISC4
20 SLOT_MISC5
21 SLOT_MISC6
22 SLOT_MISC7
23 SLOT_MISC8
24 SLOT_MISC9
25 SLOT_MISC10
26 SLOT_MISC11
27 SLOT_MISC12
28 SLOT_MISC13
29 SLOT_MISC14
30 SLOT_MISC15
31 SLOT_MISC16
32 SLOT_MISC17
33 SLOT_MISC18
34 SLOT_MISC19
35 SLOT_WEAPON0
36 SLOT_WEAPON1
37 SLOT_WEAPON2
38 SLOT_WEAPON3
See also CItem::GetItemType
CItem::GetItemFile¶
Returns the creature item file
CCreatureFileItem CItem::GetItemFile();
Return Value
Returns CCreatureFileItem
Remarks
CItem::GetItemIcon¶
Returns a resource reference for the icon used for the item
CResRef CItem::GetItemIcon();
Return Value
Returns a CResRef resource reference
Remarks
Returns the resource reference stored in the Item_Header_st.itemIcon[8] field.
See also CItem::GetGroundIcon
CItem::GetItemType¶
Returns the item type
const unsigned short CItem::GetItemType();
Return Value
Returns const unsigned short
as the item type
Remarks
Returns the value stored in the Item_Header_st.itemType field. The values for this field are from IITEMCAT.IDS
:
0 MISC
1 AMULET
2 ARMOR
3 BELT
4 BOOT
5 ARROW
6 BRACER
7 HELMET
8 KEY
9 POTION
10 RING
11 SCROLL
12 SHIELD
13 FOOD
14 BULLET
15 BOW
16 DAGGER
17 MACE
18 SLING
19 SMSWORD
20 BGSWORD
21 HAMMER
22 MSTAR
23 FLAIL
24 DART
25 AXE
26 STAFF
27 XBOW
28 FIST
29 SPEAR
30 POLEARM
31 BOLT
32 CLOAK
33 COIN
34 GEM
35 WAND
36 BROKEN1
37 BROKEN2
See also CItem::GetInventorySlotType
CItem::GetLoreValue¶
Returns the lore value for the item
unsigned short CItem::GetLoreValue();
Return Value
Returns unsigned short
Remarks
The lore value of the item is used to determine if a character with a high enough lore skill can identify the item without having to use an identity spell, identify scroll or other means to identify an item
Returns the value stored in the Item_Header_st.loreValue field
CItem::GetMaxStackable¶
Returns the maximum stackable value of items when grouped (stacked) together
unsigned short CItem::GetMaxStackable();
Return Value
Returns an unsigned short
value of the max stackable of similar items
Remarks
For items of the same type: gems, arrows etc. Returns how many can be stacked together.
Returns the value stored in the Item_Header_st.maxStackable field
CItem::GetMaxUsageCount¶
Returns the maximum usage count or charges of an item
unsigned short CItem::GetMaxUsageCount(int nAbility);
Parameters
int
nAbility - ability number
Return Value
Returns an unsigned short
value of the max usage count of item
Remarks
Fetches the value stored in the Item_Header_st.abilityCount field and calls CItem::GetAbility
Returns the value in the Item_ability_st.maxUsageCount field or 0
otherwise
CItem::GetMinCHRRequired¶
Returns the minimum charisma score required to be able to use the item
unsigned char CItem::GetMinCHRRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minCHRRequired field
CItem::GetMinCONRequired¶
Returns the minimum constitution score required to be able to use the item
unsigned char CItem::GetMinCONRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minCONRequired field
CItem::GetMinDEXRequired¶
Returns the minimum dexterity score required to be able to use the item
unsigned char CItem::GetMinDEXRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minDEXRequired field
CItem::GetMinINTRequired¶
Returns the minimum intelligence score required to be able to use the item
unsigned char CItem::GetMinINTRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minINTRequired field
CItem::GetMinLevelRequired¶
Returns the minimum character class level required to be able to use the item
unsigned char CItem::GetMinLevelRequired();
Return Value
Returns unsigned char
of the minimum level
Remarks
Returns the value stored in the Item_Header_st.minLevelRequired field
CItem::GetMinSTRBonusRequired¶
Returns the minimum exceptional strength score (extra percentile strength score) required to be able to use the item
unsigned char CItem::GetMinSTRBonusRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minSTRBonusRequired field
CItem::GetMinSTRRequired¶
Returns the minimum strength score required to be able to use the item
unsigned char CItem::GetMinSTRRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minSTRRequired field
CItem::GetMinWISRequired¶
Returns the minimum wisdom score required to be able to use the item
unsigned char CItem::GetMinWISRequired();
Return Value
Returns unsigned char
of the minimum ability scrore
Remarks
Returns the value stored in the Item_Header_st.minWISRequired field
CItem::GetNotUsableBy¶
Returns a not usable by a class bit mask
unsigned long CItem::GetNotUsableBy();
Return Value
Returns an unsigned long
bit mask
Remarks
Returns the value stored in the Item_Header_st.notUsableBy field. The following bit values indicate not usable by:
Not Usable By |
Bit mask value |
Chaotic |
0x1 |
Evil |
0x2 |
Good |
0x4 |
Neutral |
0x8 |
Lawful |
0x10 |
Neutral |
0x20 |
Bard |
0x40 |
Cleric |
0x80 |
Cleric/Mage |
0x100 |
Cleric/Thief |
0x200 |
Cleric/Ranger |
0x400 |
Fighter |
0x800 |
Fighter/Druid |
0x1000 |
Fighter/Mage |
0x2000 |
Fighter/Cleric |
0x4000 |
Fighter/Mage/Cleric |
0x8000 |
Fighter/Mage/Thief |
0x10000 |
Fighter/Thief |
0x20000 |
Mage |
0x40000 |
Mage/Thief |
0x80000 |
Paladin |
0x100000 |
Ranger |
0x200000 |
Thief |
0x400000 |
Elf |
0x800000 |
Dwarf |
0x1000000 |
Half-Elf |
0x2000000 |
Halfling |
0x4000000 |
Human |
0x8000000 |
Gnome |
0x10000000 |
Monk |
0x20000000 |
Druid |
0x40000000 |
Half-Orc |
0x80000000 |
CItem::GetNotUsableBy2¶
Returns a 2nd not usable by a class bit mask
unsigned long CItem::GetNotUsableBy2();
Return Value
Returns an unsigned long
bit mask
Remarks
Fetches the byte values stored in the following fields: Item_Header_st.notUsableBy2a, Item_Header_st.notUsableBy2b, Item_Header_st.notUsableBy2c, Item_Header_st.notUsableBy2d and combines them together to form the 2nd not usable bit mask. The following bit values indicate not usable by:
Not Usable By |
Bit mask value |
Cleric of Talos |
0x1 |
Cleric of Helm |
0x2 |
Cleric of Lathlander |
0x4 |
Totemic Druid |
0x8 |
Shapeshifter Druid |
0x10 |
Avenger Druid |
0x20 |
Barbarian |
0x40 |
Wildmage |
0x80 |
Stalker Ranger |
0x100 |
Beastmaster Ranger |
0x200 |
Assassin Thief |
0x400 |
Bounty Hunter Thief |
0x800 |
Swashbuckler Thief |
0x1000 |
Blade Bard |
0x2000 |
Jester Bard |
0x4000 |
Skald Bard |
0x8000 |
Diviner |
0x10000 |
Enchanter |
0x20000 |
Illusionist |
0x40000 |
Invoker |
0x80000 |
Necromancer |
0x100000 |
Transmuter |
0x200000 |
All (no kit) |
0x400000 |
Ferlain |
0x800000 |
Beserker Fighter |
0x1000000 |
Wizardslayer Fighter |
0x2000000 |
Kensai Fighter |
0x4000000 |
Cavalier Paladin |
0x8000000 |
Inquisiter Paladin |
0x10000000 |
Undead Hunter Paladin |
0x20000000 |
Abjurer |
0x40000000 |
Conjurer |
0x80000000 |
CItem::GetProficiencyType¶
Returns a weapon proficiency type
unsigned char CItem::GetProficiencyType();
Return Value
Returns unsigned char
as a weapon proficiency type
Remarks
Returns the value stored in the Item_Header_st.proficiencyType field. The values from this field can be found in WPROF.IDS
:
89 PROFICIENCYBASTARDSWORD
90 PROFICIENCYLONGSWORD
91 PROFICIENCYSHORTSWORD
92 PROFICIENCYAXE
93 PROFICIENCYTWOHANDEDSWORD
94 PROFICIENCYKATANA
95 PROFICIENCYSCIMITARWAKISASHININJATO
96 PROFICIENCYDAGGER
97 PROFICIENCYWARHAMMER
98 PROFICIENCYSPEAR
99 PROFICIENCYHALBERD
100 PROFICIENCYFLAILMORNINGSTAR
101 PROFICIENCYMACE
102 PROFICIENCYQUARTERSTAFF
103 PROFICIENCYCROSSBOW
104 PROFICIENCYLONGBOW
105 PROFICIENCYSHORTBOW
106 PROFICIENCYDART
107 PROFICIENCYSLING
108 PROFICIENCYBLACKJACK
111 PROFICIENCY2HANDED
112 PROFICIENCYSWORDANDSHIELD
113 PROFICIENCYSINGLEWEAPON
114 PROFICIENCY2WEAPON
115 PROFICIENCYCLUB
CItem::GetUsabilityText¶
Returns a string describing the restrictions of the item’s use by character class, race, ability scores, level or other factors.
CString CItem::GetUsabilityText();
Return Value
Returns CString
Remarks
Performs the equivalent of CItem::GetNotUsableBy and CItem::GetNotUsableBy2 all the CItem::GetMin* functions, and other functions and builds the string for the item restrictions
CItem::GetUsageCount¶
unsigned short CItem::GetUsageCount(int nAbility);
Parameters
int
nAbility -
Return Value
Returns unsigned short
Remarks
CItem::GetUsedUpItemId¶
CResRef CItem::GetUsedUpItemId();
Return Value
Returns CResRef
Remarks
CItem::GetWeight¶
unsigned long CItem::GetWeight();
Return Value
Returns unsigned long
Remarks
CItem::LoadUsability¶
void CItem::LoadUsability();
Remarks
CItem::LoadWeaponIdentification¶
void CItem::LoadWeaponIdentification(CWeaponIdentification& weaponId);
Parameters
CWeaponIdentification& weaponId -
Return Value
Remarks
CItem::PushToLua¶
void CItem::PushToLua(int skipDescriptionText);
Parameters
int
skipDescriptionText -
Remarks
CItem::ResolveRandomItem¶
void CItem::ResolveRandomItem(CResRef& id);
Parameters
CResRef& id -
Remarks
CItem::SetResRef¶
void CItem::SetResRef(
:ref:`CResRef<CResRef>`\& cNewResRef,
int bSetAutoRequest);
Parameters
CResRef& cNewResRef -
int
bSetAutoRequest -
Remarks
CItem::SetUsageCount¶
void CItem::SetUsageCount(
int nAbility,
unsigned short wUseCount);
Parameters
int
nAbility -unsigned short
wUseCount -
Remarks
CItem::SetWear¶
void CItem::SetWear(unsigned short newWear);
Parameters
unsigned short
newWear -
Remarks
CItem::TranslateAnimationType¶
unsigned char CItem::TranslateAnimationType(
:ref:`CString<CString>`\& equipCode,
:ref:`CGameSprite<CGameSprite>`\* pSprite);
Parameters
CString& equipCode -
CGameSprite* pSprite -
Return Value
Returns unsigned char
Remarks
CItem::Unequip¶
void CItem::Unequip(
CGameSprite* pSprite,
long slotNum,
int recalculateEffects,
int animationOnly);
Parameters
CGameSprite* pSprite -
long
slotNum -int
recalculateEffects -int
animationOnly -
Remarks
Operators¶
Name |
Description |
CItem::operator=¶
CItem& CItem::operator=(CItem& item);
Parameters
CItem& item -
Return Value
Returns CItem&
Remarks
CItem::operator!=¶
bool CItem::operator!=(CItem& item);
Parameters
CItem& item -
Return Value
Returns bool
Remarks