melee / ranged effects
[gemrb.git] / gemrb / core / Item.h
blobf26754503a7a8454e086a2f703134364e92f7477
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 //modder extensions
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
67 //modder extensions
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
75 //attack types
76 #define ITEM_AT_MELEE 1
77 #define ITEM_AT_PROJECTILE 2
78 #define ITEM_AT_MAGIC 3
79 #define ITEM_AT_BOW 4
81 //target types
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
92 #define PROJ_ARROW 1
93 #define PROJ_BOLT 2
94 #define PROJ_BULLET 4
96 //charge depletion flags
97 #define CHG_NONE 0
98 #define CHG_BREAK 1
99 #define CHG_NOSOUND 2
100 #define CHG_DAY 3
103 * @class ITMExtHeader
104 * Header for special effects and uses of an Item.
107 class GEM_EXPORT ITMExtHeader {
108 public:
109 ITMExtHeader();
110 ~ITMExtHeader();
111 ieByte AttackType;
112 ieByte IDReq;
113 ieByte Location;
114 ieByte unknown1;
115 ieResRef UseIcon;
116 ieByte Target;
117 ieByte TargetNumber;
118 ieWord Range;
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;
124 ieWord Speed;
125 ieWord THAC0Bonus;
126 ieWord DiceSides;
127 ieWord DiceThrown;
128 ieWordSigned DamageBonus; //this must be signed!!!
129 ieWord DamageType;
130 ieWord FeatureCount;
131 ieWord FeatureOffset;
132 ieWord Charges;
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
139 Effect *features;
143 * @class Item
144 * Class for all things your PCs can pick, carry and wear and many they can't.
147 class GEM_EXPORT Item {
148 public:
149 Item();
150 ~Item();
152 ITMExtHeader *ext_headers;
153 Effect *equipping_features;
154 ieResRef Name; //the resref of the item itself!
156 ieStrRef ItemName;
157 ieStrRef ItemNameIdentified;
158 ieResRef ReplacementItem;
159 ieDword Flags;
160 ieWord ItemType;
161 ieDword UsabilityBitmask;
162 char AnimationType[2];
163 ieByte MinLevel;
164 ieByte unknown1;
165 ieByte MinStrength;
166 ieByte unknown2;
167 ieByte MinStrengthBonus;
168 //kit1
169 ieByte MinIntelligence;
170 //kit2
171 ieByte MinDexterity;
172 //kit3
173 ieByte MinWisdom;
174 //kit4
175 ieByte MinConstitution;
176 ieByte WeaProf;
177 ieByte MinCharisma;
178 ieByte unknown3;
179 ieDword KitUsability;
180 ieDword Price;
181 ieWord StackAmount;
182 ieResRef ItemIcon;
183 ieWord LoreToID;
184 ieResRef GroundIcon;
185 ieDword Weight;
186 ieStrRef ItemDesc;
187 ieStrRef ItemDescIdentified;
188 ieResRef DescriptionIcon;
189 ieDword Enchantment;
190 ieDword ExtHeaderOffset;
191 ieWord ExtHeaderCount;
192 ieDword FeatureBlockOffset;
193 ieWord EquippingFeatureOffset;
194 ieWord EquippingFeatureCount;
196 // PST only
197 ieResRef Dialog;
198 ieStrRef DialogName;
199 ieWord WieldColor;
201 // PST and IWD2 only
202 char unknown[26];
203 // flag items to mutually exclusive to equip
204 ieDword ItemExcl;
205 public:
206 ieStrRef GetItemName(bool identified) const
208 if(identified) {
209 if((int) ItemNameIdentified>=0) return ItemNameIdentified;
210 return ItemName;
212 if((int) ItemName>=0) {
213 return ItemName;
215 return ItemNameIdentified;
217 ieStrRef GetItemDesc(bool identified) const
219 if(identified) {
220 if((int) ItemDescIdentified>=0) return ItemDescIdentified;
221 return ItemDesc;
223 if((int) ItemDesc>=0) {
224 return ItemDesc;
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
236 if(which < 0)
237 return GetWeaponHeader(which == -2) ;
238 if(ExtHeaderCount<=which) {
239 return NULL;
241 return ext_headers+which;
243 ieDword GetWieldedGradient() const
245 return WieldColor;
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;
263 private:
266 #endif // ! ITEM_H