Move EventMgr to GUI.
[gemrb.git] / gemrb / core / Item.h
blob9e679d0418b07ebb591136e272f46614707fa5fe
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.
21 /**
22 * @file Item.h
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
28 #ifndef ITEM_H
29 #define ITEM_H
31 #include "exports.h"
32 #include "ie_types.h"
34 #include "EffectQueue.h"
36 class Projectile;
38 // Item Flags bits
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
68 //attack types
69 #define ITEM_AT_MELEE 1
70 #define ITEM_AT_PROJECTILE 2
71 #define ITEM_AT_MAGIC 3
72 #define ITEM_AT_BOW 4
74 //target types
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
85 #define PROJ_ARROW 1
86 #define PROJ_BOLT 2
87 #define PROJ_BULLET 4
89 //charge depletion flags
90 #define CHG_NONE 0
91 #define CHG_BREAK 1
92 #define CHG_NOSOUND 2
93 #define CHG_DAY 3
95 /**
96 * @class ITMExtHeader
97 * Header for special effects and uses of an Item.
100 class GEM_EXPORT ITMExtHeader {
101 public:
102 ITMExtHeader();
103 ~ITMExtHeader();
104 ieByte AttackType;
105 ieByte IDReq;
106 ieByte Location;
107 ieByte unknown1;
108 ieResRef UseIcon;
109 ieByte Target;
110 ieByte TargetNumber;
111 ieWord Range;
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;
117 ieWord Speed;
118 ieWord THAC0Bonus;
119 ieWord DiceSides;
120 ieWord DiceThrown;
121 ieWordSigned DamageBonus; //this must be signed!!!
122 ieWord DamageType;
123 ieWord FeatureCount;
124 ieWord FeatureOffset;
125 ieWord Charges;
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
132 Effect *features;
136 * @class Item
137 * Class for all things your PCs can pick, carry and wear and many they can't.
140 class GEM_EXPORT Item {
141 public:
142 Item();
143 ~Item();
145 ITMExtHeader *ext_headers;
146 Effect *equipping_features;
147 ieResRef Name; //the resref of the item itself!
149 ieStrRef ItemName;
150 ieStrRef ItemNameIdentified;
151 ieResRef ReplacementItem;
152 ieDword Flags;
153 ieWord ItemType;
154 ieDword UsabilityBitmask;
155 char AnimationType[2];
156 ieByte MinLevel;
157 ieByte unknown1;
158 ieByte MinStrength;
159 ieByte unknown2;
160 ieByte MinStrengthBonus;
161 //kit1
162 ieByte MinIntelligence;
163 //kit2
164 ieByte MinDexterity;
165 //kit3
166 ieByte MinWisdom;
167 //kit4
168 ieByte MinConstitution;
169 ieByte WeaProf;
170 ieByte MinCharisma;
171 ieByte unknown3;
172 ieDword KitUsability;
173 ieDword Price;
174 ieWord StackAmount;
175 ieResRef ItemIcon;
176 ieWord LoreToID;
177 ieResRef GroundIcon;
178 ieDword Weight;
179 ieStrRef ItemDesc;
180 ieStrRef ItemDescIdentified;
181 ieResRef DescriptionIcon;
182 ieDword Enchantment;
183 ieDword ExtHeaderOffset;
184 ieWord ExtHeaderCount;
185 ieDword FeatureBlockOffset;
186 ieWord EquippingFeatureOffset;
187 ieWord EquippingFeatureCount;
189 // PST only
190 ieResRef Dialog;
191 ieStrRef DialogName;
192 ieWord WieldColor;
194 // PST and IWD2 only
195 char unknown[26];
196 // flag items to mutually exclusive to equip
197 ieDword ItemExcl;
198 public:
199 ieStrRef GetItemName(bool identified) const
201 if(identified) {
202 if((int) ItemNameIdentified>=0) return ItemNameIdentified;
203 return ItemName;
205 if((int) ItemName>=0) {
206 return ItemName;
208 return ItemNameIdentified;
210 ieStrRef GetItemDesc(bool identified) const
212 if(identified) {
213 if((int) ItemDescIdentified>=0) return ItemDescIdentified;
214 return ItemDesc;
216 if((int) ItemDesc>=0) {
217 return ItemDesc;
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
229 if(which < 0)
230 return GetWeaponHeader(which == -2) ;
231 if(ExtHeaderCount<=which) {
232 return NULL;
234 return ext_headers+which;
236 ieDword GetWieldedGradient() const
238 return WieldColor;
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;
256 private:
259 #endif // ! ITEM_H