1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares Item, class for all things your PCs can pick, carry and wear
24 * and many they can't.
25 * @author The GemRB Project
34 #include "EffectQueue.h"
39 // !!! Keep these synchronized with GUIDefines.h !!!
40 #define IE_ITEM_CRITICAL 0x00000001
41 #define IE_ITEM_TWO_HANDED 0x00000002
42 #define IE_ITEM_MOVABLE 0x00000004
43 #define IE_ITEM_DISPLAYABLE 0x00000008
44 #define IE_ITEM_CURSED 0x00000010
45 #define IE_ITEM_NOT_COPYABLE 0x00000020
46 #define IE_ITEM_MAGICAL 0x00000040
47 #define IE_ITEM_BOW 0x00000080
48 #define IE_ITEM_SILVER 0x00000100
49 #define IE_ITEM_COLD_IRON 0x00000200
50 #define IE_ITEM_STOLEN 0x00000400
51 #define IE_ITEM_CONVERSABLE 0x00000800
52 #define IE_ITEM_PULSATING 0x00001000
53 #define IE_ITEM_UNSELLABLE ( IE_ITEM_CRITICAL | IE_ITEM_STOLEN )
55 //Extended header recharge flags
56 #define IE_ITEM_USESTRENGTH 1 //weapon
57 #define IE_ITEM_BREAKABLE 2 //weapon
58 #define IE_ITEM_HOSTILE 0x400 //equipment
59 #define IE_ITEM_RECHARGE 0x800 //equipment
60 #define IE_ITEM_IGNORESHIELD 0x10000 //weapon
61 #define IE_ITEM_KEEN 0x20000 //weapon
63 //item use locations (weapons are not listed in equipment list)
64 #define ITEM_LOC_WEAPON 1 //this is a weapon slot (uses thac0 etc)
65 #define ITEM_LOC_EQUIPMENT 3 //this slot appears on equipment list
66 //other item locations appear useless
69 #define ITEM_AT_MELEE 1
70 #define ITEM_AT_PROJECTILE 2
71 #define ITEM_AT_MAGIC 3
75 #define TARGET_INVALID 0 //all the rest (default)
76 #define TARGET_CREA 1 //single living creature
77 #define TARGET_INV 2 //inventory item (not used?)
78 #define TARGET_DEAD 3 //creature, item or point
79 #define TARGET_AREA 4 //point target
80 #define TARGET_SELF 5 //self
81 #define TARGET_UNKNOWN 6 //unknown (use default)
82 #define TARGET_NONE 7 //self
84 //projectile qualifiers
89 //charge depletion flags
97 * Header for special effects and uses of an Item.
100 class GEM_EXPORT ITMExtHeader
{
112 //this is partially redundant, but the original engine uses this value to
113 //determine projectile type (ProjectileQualifier is almost always set too)
114 //We use this field only when really needed, and resolve the redundancy
115 //in the exporter. The reason: using bitfields is more flexible.
116 //ieWord ProjectileType;
121 ieWordSigned DamageBonus
; //this must be signed!!!
124 ieWord FeatureOffset
;
126 ieWord ChargeDepletion
;
127 ieDword RechargeFlags
; //this is a bitfield with many bits
128 ieWord ProjectileAnimation
;
129 ieWord MeleeAnimation
[3];
130 //this value is set in projectiles and launchers too
131 int ProjectileQualifier
; //this is a derived value determined on load time
137 * Class for all things your PCs can pick, carry and wear and many they can't.
140 class GEM_EXPORT Item
{
145 ITMExtHeader
*ext_headers
;
146 Effect
*equipping_features
;
147 ieResRef Name
; //the resref of the item itself!
150 ieStrRef ItemNameIdentified
;
151 ieResRef ReplacementItem
;
154 ieDword UsabilityBitmask
;
155 char AnimationType
[2];
160 ieByte MinStrengthBonus
;
162 ieByte MinIntelligence
;
168 ieByte MinConstitution
;
172 ieDword KitUsability
;
180 ieStrRef ItemDescIdentified
;
181 ieResRef DescriptionIcon
;
183 ieDword ExtHeaderOffset
;
184 ieWord ExtHeaderCount
;
185 ieDword FeatureBlockOffset
;
186 ieWord EquippingFeatureOffset
;
187 ieWord EquippingFeatureCount
;
196 // flag items to mutually exclusive to equip
199 ieStrRef
GetItemName(bool identified
) const
202 if((int) ItemNameIdentified
>=0) return ItemNameIdentified
;
205 if((int) ItemName
>=0) {
208 return ItemNameIdentified
;
210 ieStrRef
GetItemDesc(bool identified
) const
213 if((int) ItemDescIdentified
>=0) return ItemDescIdentified
;
216 if((int) ItemDesc
>=0) {
219 return ItemDescIdentified
;
222 //returns if the item is usable, expend will also expend a charge
223 int UseCharge(ieWord
*Charges
, int header
, bool expend
) const;
225 //returns the requested extended header
226 //-1 will return melee weapon header, -2 the ranged one
227 ITMExtHeader
*GetExtHeader(int which
) const
230 return GetWeaponHeader(which
== -2) ;
231 if(ExtHeaderCount
<=which
) {
234 return ext_headers
+which
;
236 ieDword
GetWieldedGradient() const
241 //-1 will return the equipping feature block
242 EffectQueue
*GetEffectBlock(int header
, ieDwordSigned invslot
, ieDword pro
) const;
243 //returns a projectile created from an extended header
244 //if miss is non-zero, then no effects will be loaded
245 Projectile
*GetProjectile(ieDwordSigned invslot
, int header
, int miss
) const;
246 //Builds an equipping glow effect from gradient colour
247 //this stuff is not item specific, could be moved elsewhere
248 Effect
*BuildGlowEffect(int gradient
) const;
249 //returns the average damage of the weapon (doesn't check for special effects)
250 int GetDamagePotential(bool ranged
, ITMExtHeader
*&header
) const;
251 //returns the weapon header
252 ITMExtHeader
*GetWeaponHeader(bool ranged
) const;
253 int GetWeaponHeaderNumber(bool ranged
) const;
254 int GetEquipmentHeaderNumber(int cnt
) const;
255 unsigned int GetCastingDistance(int header
) const;