Pol  Revision:f37d500
itemdesc.h
Go to the documentation of this file.
1 
7 #ifndef ITEMDESC_H
8 #define ITEMDESC_H
9 
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 #include "../../clib/boostutils.h"
15 #include "../../clib/compilerspecifics.h"
16 #include "../../clib/rawtypes.h"
17 #include "../dice.h"
18 #include "../proplist.h"
19 #include "../scrdef.h"
20 #include "../uobject.h"
21 
22 namespace Pol
23 {
24 namespace Clib
25 {
26 class ConfigElem;
27 } // namespace Clib
28 namespace Plib
29 {
30 class Package;
31 } // namespace Plib
32 } // namespace Pol
33 
34 namespace Pol
35 {
36 namespace Bscript
37 {
38 class BStruct;
39 }
40 namespace Core
41 {
42 class ExportScript;
43 class ResourceDef;
44 }
45 namespace Items
46 {
48 {
50  unsigned amount;
51 
52  ResourceComponent( const std::string& rname, unsigned amount );
53 };
54 
55 class ItemDesc
56 {
57 public:
58  enum Type
59  {
69  MAPDESC
70  };
71 
72  static ItemDesc* create( Clib::ConfigElem& elem, const Plib::Package* pkg );
73 
74  ItemDesc( u32 objtype, Clib::ConfigElem& elem, Type type, const Plib::Package* pkg );
75  explicit ItemDesc( Type type );
76  virtual ~ItemDesc();
77  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const;
78  virtual size_t estimatedSize() const;
79  std::string objtype_description() const;
80  bool default_movable() const;
81 
83 
85  std::string objtypename;
86 
90  // u16 weight;
93  int weightdiv;
95  std::string tooltip;
104  bool lockable;
105  unsigned int vendor_sells_for;
106  unsigned int vendor_buys_for;
107  unsigned decay_time;
108  enum Movable : u8
109  {
112  DEFAULT
113  } movable;
114  unsigned short doubleclick_range;
115  bool use_requires_los; // DAVE 11/24
116  bool ghosts_can_use; // DAVE 11/24
119  bool newbie;
120  bool insured;
121  bool invisible;
124  bool no_drop;
125  unsigned short base_str_req;
126  unsigned short stack_limit;
127  double quality;
128  unsigned short multiid;
129  unsigned short maxhp;
130 
132 
135 
136  std::vector<ResourceComponent> resources;
137 
139  std::set<std::string> ignore_cprops; // dave added 1/26/3
140 
142 
144 
145  void unload_scripts();
146 };
147 
148 class ContainerDesc : public ItemDesc
149 {
150  typedef ItemDesc base;
151 
152 public:
153  ContainerDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
154  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
155  virtual ~ContainerDesc(){};
156  virtual size_t estimatedSize() const POL_OVERRIDE;
157 
158  // string name;
159  // u16 objtype;
161  u16 minx, maxx;
162  u16 miny, maxy;
163 
166 
168 
170 
175 };
176 
177 class DoorDesc : public ItemDesc
178 {
179  typedef ItemDesc base;
180 
181 public:
182  DoorDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
183  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
184  virtual ~DoorDesc(){};
185  virtual size_t estimatedSize() const POL_OVERRIDE;
189 };
190 
192 {
194 
195 public:
196  SpellbookDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
197  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
198  virtual ~SpellbookDesc(){};
199  virtual size_t estimatedSize() const POL_OVERRIDE;
200 
201  std::string spelltype;
202 };
203 
204 class SpellScrollDesc : public ItemDesc
205 {
206  typedef ItemDesc base;
207 
208 public:
209  SpellScrollDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
210  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
211  virtual ~SpellScrollDesc(){};
212  virtual size_t estimatedSize() const POL_OVERRIDE;
213 
214  std::string spelltype;
215 };
216 
217 class MultiDesc : public ItemDesc
218 {
219  typedef ItemDesc base;
220 
221 public:
222  MultiDesc( u32 objtype, Clib::ConfigElem& elem, Type type, const Plib::Package* pkg );
223  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
224  virtual ~MultiDesc(){};
225  virtual size_t estimatedSize() const POL_OVERRIDE;
226 };
227 
228 class BoatDesc : public MultiDesc
229 {
230  typedef MultiDesc base;
231 
232 public:
233  BoatDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
234  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
235  virtual ~BoatDesc(){};
236  virtual size_t estimatedSize() const POL_OVERRIDE;
237 };
238 
239 class HouseDesc : public MultiDesc
240 {
241  typedef MultiDesc base;
242 
243 public:
244  HouseDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
245  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
246  virtual ~HouseDesc(){};
247  virtual size_t estimatedSize() const POL_OVERRIDE;
248 };
249 
250 class MapDesc : public ItemDesc
251 {
252  typedef ItemDesc base;
253 
254 public:
255  MapDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg );
256  virtual void PopulateStruct( Bscript::BStruct* descriptor ) const POL_OVERRIDE;
257  virtual ~MapDesc(){};
258  virtual size_t estimatedSize() const POL_OVERRIDE;
259  bool editable;
260 };
261 
262 
263 const ItemDesc& find_itemdesc( unsigned int objtype );
264 const ContainerDesc& find_container_desc( u32 objtype );
265 const DoorDesc& fast_find_doordesc( u32 objtype );
266 const MultiDesc& find_multidesc( u32 objtype );
267 
268 bool has_itemdesc( u32 objtype );
269 
270 unsigned short getgraphic( unsigned int objtype );
271 unsigned short getcolor( unsigned int objtype );
272 
273 unsigned int get_objtype_byname( const char* name );
274 unsigned int get_objtype_from_string( const std::string& str );
275 bool objtype_is_lockable( u32 objtype );
276 
277 void load_itemdesc( Clib::ConfigElem& elem );
278 
279 const ItemDesc* CreateItemDescriptor( Bscript::BStruct* itemdesc_struct );
280 }
281 }
282 #endif
unsigned short doubleclick_range
Definition: itemdesc.h:114
unsigned char u8
Definition: rawtypes.h:25
virtual ~DoorDesc()
Definition: itemdesc.h:184
unsigned short stack_limit
Definition: itemdesc.h:126
Core::PropertyList props
Definition: itemdesc.h:138
#define POL_OVERRIDE
Core::ExportScript * method_script
Definition: itemdesc.h:141
unsigned decay_time
Definition: itemdesc.h:107
unsigned int get_objtype_byname(const char *str)
Definition: itemdesc.cpp:58
std::string objtypename
Definition: itemdesc.h:85
virtual ~HouseDesc()
Definition: itemdesc.h:246
Core::ScriptDef on_remove_script
Definition: itemdesc.h:174
std::set< std::string > ignore_cprops
Definition: itemdesc.h:139
std::string tooltip
Definition: itemdesc.h:95
unsigned short base_str_req
Definition: itemdesc.h:125
unsigned int vendor_sells_for
Definition: itemdesc.h:105
unsigned short getcolor(unsigned int objtype)
Definition: itemdesc.cpp:927
std::vector< ResourceComponent > resources
Definition: itemdesc.h:136
bool blocks_casting_if_in_hand
Definition: itemdesc.h:123
const ItemDesc & find_itemdesc(unsigned int objtype)
Definition: itemdesc.cpp:933
unsigned short multiid
Definition: itemdesc.h:128
Core::ScriptDef on_insert_script
Definition: itemdesc.h:172
Core::ElementDamages element_damage
Definition: itemdesc.h:134
virtual ~MapDesc()
Definition: itemdesc.h:257
Core::ScriptDef on_use_script
Definition: itemdesc.h:97
unsigned short getgraphic(u32 objtype)
Definition: itemdesc.cpp:906
unsigned short u16
Definition: rawtypes.h:26
Core::ScriptDef destroy_script
Definition: itemdesc.h:102
unsigned int u32
Definition: rawtypes.h:27
unsigned short maxhp
Definition: itemdesc.h:129
const Plib::Package * pkg
Definition: itemdesc.h:84
unsigned int get_objtype_from_string(const std::string &str)
Definition: itemdesc.cpp:67
signed short s16
Definition: rawtypes.h:30
boost_utils::script_name_flystring equip_script
Definition: itemdesc.h:98
Core::ScriptDef walk_on_script
Definition: itemdesc.h:96
boost_utils::object_name_flystring desc
Definition: itemdesc.h:94
Core::ScriptDef can_insert_script
Definition: itemdesc.h:171
ContainerDesc base
Definition: itemdesc.h:193
boost_utils::script_name_flystring unequip_script
Definition: itemdesc.h:99
void load_itemdesc(Clib::ConfigElem &elem)
Core::Resistances element_resist
Definition: itemdesc.h:133
virtual ~MultiDesc()
Definition: itemdesc.h:224
virtual ~BoatDesc()
Definition: itemdesc.h:235
Core::Dice resist_dice
Definition: itemdesc.h:131
boost::flyweight< std::string, boost::flyweights::tag< script_name_tag >, FLYWEIGHT_HASH_FACTORY > script_name_flystring
Definition: boostutils.h:148
const MultiDesc & find_multidesc(u32 objtype)
Definition: itemdesc.cpp:958
const ItemDesc * CreateItemDescriptor(Bscript::BStruct *itemdesc_struct)
Definition: itemdesc.cpp:965
Core::ScriptDef can_remove_script
Definition: itemdesc.h:173
Core::ResourceDef * rd
Definition: itemdesc.h:49
std::string name
Definition: osmod.cpp:943
bool objtype_is_lockable(u32 objtype)
Definition: itemdesc.cpp:900
const DoorDesc & fast_find_doordesc(u32 objtype)
Definition: itemdesc.cpp:951
Core::ScriptDef control_script
Definition: itemdesc.h:100
const ContainerDesc & find_container_desc(u32 objtype)
Definition: itemdesc.cpp:942
unsigned int vendor_buys_for
Definition: itemdesc.h:106
bool has_itemdesc(u32 objtype)
Definition: itemdesc.cpp:895
boost::flyweight< std::string, boost::flyweights::tag< object_name_tag >, FLYWEIGHT_HASH_FACTORY > object_name_flystring
Definition: boostutils.h:142
Definition: berror.cpp:12
Core::ScriptDef create_script
Definition: itemdesc.h:101
bool can_use_while_paralyzed
Definition: itemdesc.h:117