-
Notifications
You must be signed in to change notification settings - Fork 60
/
itemdesc.h
316 lines (264 loc) · 7.5 KB
/
itemdesc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/** @file
*
* @par History
*/
#ifndef ITEMDESC_H
#define ITEMDESC_H
#include <map>
#include <string>
#include <vector>
#include "../../clib/boostutils.h"
#include "../../clib/rawtypes.h"
#include "../dice.h"
#include "../proplist.h"
#include "../scrdef.h"
#include "../uobject.h"
#include "base/range.h"
#include "base/vector.h"
namespace Pol
{
namespace Clib
{
class ConfigElem;
} // namespace Clib
namespace Plib
{
class Package;
} // namespace Plib
} // namespace Pol
namespace Pol
{
namespace Bscript
{
class BStruct;
}
namespace Core
{
class ExportScript;
class ResourceDef;
} // namespace Core
namespace Items
{
struct ResourceComponent
{
Core::ResourceDef* rd;
unsigned amount;
ResourceComponent( const std::string& rname, unsigned amount );
};
class ItemDesc
{
public:
enum Type
{
ITEMDESC,
CONTAINERDESC,
DOORDESC,
WEAPONDESC,
ARMORDESC,
BOATDESC,
HOUSEDESC,
SPELLBOOKDESC,
SPELLSCROLLDESC,
MAPDESC
};
static ItemDesc* create( Clib::ConfigElem& elem, const Plib::Package* pkg );
ItemDesc( u32 objtype, Clib::ConfigElem& elem, Type type, const Plib::Package* pkg );
explicit ItemDesc( Type type );
virtual ~ItemDesc();
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const;
virtual size_t estimatedSize() const;
std::string objtype_description() const;
bool default_movable() const;
Type type;
const Plib::Package* pkg;
std::string objtypename;
u32 objtype;
u16 graphic;
u16 color;
// u16 weight;
u8 facing;
int weightmult;
int weightdiv;
boost_utils::object_name_flystring desc;
std::string tooltip;
Core::ScriptDef walk_on_script;
Core::ScriptDef on_use_script;
boost_utils::script_name_flystring equip_script;
boost_utils::script_name_flystring unequip_script;
Core::ScriptDef snoop_script;
Core::ScriptDef control_script;
Core::ScriptDef create_script;
Core::ScriptDef destroy_script;
bool requires_attention;
bool lockable;
unsigned int vendor_sells_for;
unsigned int vendor_buys_for;
unsigned decay_time;
enum Movable : u8
{
UNMOVABLE,
MOVABLE,
DEFAULT
} movable;
unsigned short doubleclick_range;
bool use_requires_los; // DAVE 11/24
bool ghosts_can_use; // DAVE 11/24
bool can_use_while_paralyzed;
bool can_use_while_frozen;
bool newbie;
bool insured;
bool invisible;
bool cursed;
bool decays_on_multis;
bool blocks_casting_if_in_hand;
bool no_drop;
unsigned short base_str_req;
unsigned short stack_limit;
double quality;
unsigned short multiid;
unsigned short maxhp;
unsigned short lower_reag_cost;
unsigned short spell_damage_increase;
unsigned short faster_casting;
unsigned short faster_cast_recovery;
unsigned short defence_increase;
unsigned short defence_increase_cap;
unsigned short lower_mana_cost;
unsigned short hit_chance;
unsigned short resist_fire_cap;
unsigned short resist_cold_cap;
unsigned short resist_energy_cap;
unsigned short resist_physical_cap;
unsigned short resist_poison_cap;
unsigned short defence_increase_mod;
unsigned short defence_increase_cap_mod;
unsigned short lower_mana_cost_mod;
unsigned short hit_chance_mod;
unsigned short resist_fire_cap_mod;
unsigned short resist_cold_cap_mod;
unsigned short resist_energy_cap_mod;
unsigned short resist_physical_cap_mod;
unsigned short resist_poison_cap_mod;
unsigned short lower_reagent_cost_mod;
unsigned short spell_damage_increase_mod;
unsigned short faster_casting_mod;
unsigned short faster_cast_recovery_mod;
unsigned short luck;
unsigned short luck_mod;
unsigned short swing_speed_increase;
unsigned short swing_speed_increase_mod;
Core::Dice resist_dice;
Core::Resistances element_resist;
Core::ElementDamages element_damage;
std::vector<ResourceComponent> resources;
Core::PropertyList props;
std::set<std::string> ignore_cprops; // dave added 1/26/3
Core::ExportScript* method_script;
bool save_on_exit;
void unload_scripts();
};
class ContainerDesc : public ItemDesc
{
typedef ItemDesc base;
public:
ContainerDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~ContainerDesc(){};
virtual size_t estimatedSize() const override;
// string name;
// u16 objtype;
u16 gump;
Core::Range2d bounds;
u16 max_weight;
u16 max_items;
u8 max_slots;
bool no_drop_exception;
Core::ScriptDef can_insert_script;
Core::ScriptDef on_insert_script;
Core::ScriptDef can_remove_script;
Core::ScriptDef on_remove_script;
};
class DoorDesc final : public ItemDesc
{
typedef ItemDesc base;
public:
DoorDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~DoorDesc(){};
virtual size_t estimatedSize() const override;
Core::Vec2d mod;
u16 open_graphic;
};
class SpellbookDesc final : public ContainerDesc
{
typedef ContainerDesc base;
public:
SpellbookDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~SpellbookDesc(){};
virtual size_t estimatedSize() const override;
std::string spelltype;
};
class SpellScrollDesc final : public ItemDesc
{
typedef ItemDesc base;
public:
SpellScrollDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~SpellScrollDesc(){};
virtual size_t estimatedSize() const override;
std::string spelltype;
};
class MultiDesc : public ItemDesc
{
typedef ItemDesc base;
public:
MultiDesc( u32 objtype, Clib::ConfigElem& elem, Type type, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~MultiDesc(){};
virtual size_t estimatedSize() const override;
};
class BoatDesc final : public MultiDesc
{
typedef MultiDesc base;
public:
BoatDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~BoatDesc(){};
virtual size_t estimatedSize() const override;
std::vector<u16> alternates;
};
class HouseDesc final : public MultiDesc
{
typedef MultiDesc base;
public:
HouseDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~HouseDesc(){};
virtual size_t estimatedSize() const override;
};
class MapDesc final : public ItemDesc
{
typedef ItemDesc base;
public:
MapDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
virtual void PopulateStruct( Bscript::BStruct* descriptor ) const override;
virtual ~MapDesc(){};
virtual size_t estimatedSize() const override;
bool editable;
};
const ItemDesc& find_itemdesc( unsigned int objtype );
const ContainerDesc& find_container_desc( u32 objtype );
const DoorDesc& fast_find_doordesc( u32 objtype );
const MultiDesc& find_multidesc( u32 objtype );
bool has_itemdesc( u32 objtype );
unsigned short getgraphic( unsigned int objtype );
unsigned short getcolor( unsigned int objtype );
unsigned int get_objtype_byname( const char* name );
unsigned int get_objtype_from_string( const std::string& str );
bool objtype_is_lockable( u32 objtype );
void load_itemdesc( Clib::ConfigElem& elem );
const ItemDesc* CreateItemDescriptor( Bscript::BStruct* itemdesc_struct );
} // namespace Items
} // namespace Pol
#endif