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 )
56 #define IE_ITEM_NO_DISPEL 0x01000000 //disables destruction by dispelling
57 #define IE_ITEM_TOGGLE_CRITS 0x02000000 //toggles critical hit avertion
59 //Extended header recharge flags
60 #define IE_ITEM_USESTRENGTH 1 //weapon
61 #define IE_ITEM_BREAKABLE 2 //weapon
62 #define IE_ITEM_HOSTILE 0x400 //equipment
63 #define IE_ITEM_RECHARGE 0x800 //equipment
64 #define IE_ITEM_IGNORESHIELD 0x10000 //weapon
65 #define IE_ITEM_KEEN 0x20000 //weapon
68 #define IE_ITEM_BACKSTAB 0x01000000 //can used for backstab (ranged weapon)
70 //item use locations (weapons are not listed in equipment list)
71 #define ITEM_LOC_WEAPON 1 //this is a weapon slot (uses thac0 etc)
72 #define ITEM_LOC_EQUIPMENT 3 //this slot appears on equipment list
73 //other item locations appear useless
76 #define ITEM_AT_MELEE 1
77 #define ITEM_AT_PROJECTILE 2
78 #define ITEM_AT_MAGIC 3
82 #define TARGET_INVALID 0 //all the rest (default)
83 #define TARGET_CREA 1 //single living creature
84 #define TARGET_INV 2 //inventory item (not used?)
85 #define TARGET_DEAD 3 //creature, item or point
86 #define TARGET_AREA 4 //point target
87 #define TARGET_SELF 5 //self
88 #define TARGET_UNKNOWN 6 //unknown (use default)
89 #define TARGET_NONE 7 //self
91 //projectile qualifiers
96 //charge depletion flags
103 * @class ITMExtHeader
104 * Header for special effects and uses of an Item.
107 class GEM_EXPORT ITMExtHeader
{
119 //this is partially redundant, but the original engine uses this value to
120 //determine projectile type (ProjectileQualifier is almost always set too)
121 //We use this field only when really needed, and resolve the redundancy
122 //in the exporter. The reason: using bitfields is more flexible.
123 //ieWord ProjectileType;
128 ieWordSigned DamageBonus
; //this must be signed!!!
131 ieWord FeatureOffset
;
133 ieWord ChargeDepletion
;
134 ieDword RechargeFlags
; //this is a bitfield with many bits
135 ieWord ProjectileAnimation
;
136 ieWord MeleeAnimation
[3];
137 //this value is set in projectiles and launchers too
138 int ProjectileQualifier
; //this is a derived value determined on load time
144 * Class for all things your PCs can pick, carry and wear and many they can't.
147 class GEM_EXPORT Item
{
152 ITMExtHeader
*ext_headers
;
153 Effect
*equipping_features
;
154 ieResRef Name
; //the resref of the item itself!
157 ieStrRef ItemNameIdentified
;
158 ieResRef ReplacementItem
;
161 ieDword UsabilityBitmask
;
162 char AnimationType
[2];
167 ieByte MinStrengthBonus
;
169 ieByte MinIntelligence
;
175 ieByte MinConstitution
;
179 ieDword KitUsability
;
187 ieStrRef ItemDescIdentified
;
188 ieResRef DescriptionIcon
;
190 ieDword ExtHeaderOffset
;
191 ieWord ExtHeaderCount
;
192 ieDword FeatureBlockOffset
;
193 ieWord EquippingFeatureOffset
;
194 ieWord EquippingFeatureCount
;
203 // flag items to mutually exclusive to equip
206 ieStrRef
GetItemName(bool identified
) const
209 if((int) ItemNameIdentified
>=0) return ItemNameIdentified
;
212 if((int) ItemName
>=0) {
215 return ItemNameIdentified
;
217 ieStrRef
GetItemDesc(bool identified
) const
220 if((int) ItemDescIdentified
>=0) return ItemDescIdentified
;
223 if((int) ItemDesc
>=0) {
226 return ItemDescIdentified
;
229 //returns if the item is usable, expend will also expend a charge
230 int UseCharge(ieWord
*Charges
, int header
, bool expend
) const;
232 //returns the requested extended header
233 //-1 will return melee weapon header, -2 the ranged one
234 ITMExtHeader
*GetExtHeader(int which
) const
237 return GetWeaponHeader(which
== -2) ;
238 if(ExtHeaderCount
<=which
) {
241 return ext_headers
+which
;
243 ieDword
GetWieldedGradient() const
248 //-1 will return the equipping feature block
249 EffectQueue
*GetEffectBlock(Scriptable
*self
, const Point
&pos
, int header
, ieDwordSigned invslot
, ieDword pro
) const;
250 //returns a projectile created from an extended header
251 //if miss is non-zero, then no effects will be loaded
252 Projectile
*GetProjectile(Scriptable
*self
, int header
, const Point
&target
, ieDwordSigned invslot
, int miss
) const;
253 //Builds an equipping glow effect from gradient colour
254 //this stuff is not item specific, could be moved elsewhere
255 Effect
*BuildGlowEffect(int gradient
) const;
256 //returns the average damage of the weapon (doesn't check for special effects)
257 int GetDamagePotential(bool ranged
, ITMExtHeader
*&header
) const;
258 //returns the weapon header
259 ITMExtHeader
*GetWeaponHeader(bool ranged
) const;
260 int GetWeaponHeaderNumber(bool ranged
) const;
261 int GetEquipmentHeaderNumber(int cnt
) const;
262 unsigned int GetCastingDistance(int header
) const;