Pol  Revision:cb584c9
weapon.h
Go to the documentation of this file.
1 
8 #ifndef WEAPON_H
9 #define WEAPON_H
10 
11 
12 #include <iosfwd>
13 #include <memory>
14 #include <string>
15 
16 #include "../../bscript/bobject.h"
17 #include "../../clib/compilerspecifics.h"
18 #include "../../clib/rawtypes.h"
19 #include "../action.h"
20 #include "../dynproperties.h"
21 #include "../scrdef.h"
22 #include "equipmnt.h"
23 
24 namespace Pol
25 {
26 namespace Clib
27 {
28 class ConfigElem;
29 class StreamWriter;
30 } // namespace Clib
31 namespace Core
32 {
33 class UContainer;
34 } // namespace Core
35 namespace Items
36 {
37 class Item;
38 } // namespace Items
39 namespace Plib
40 {
41 class Package;
42 } // namespace Plib
43 } // namespace Pol
44 
45 #define WEAPON_TMPL ( static_cast<const WeaponDesc*>( tmpl ) )
46 
47 namespace Pol
48 {
49 namespace Mobile
50 {
51 class Attribute;
52 class Character;
53 }
54 namespace Items
55 {
56 class UWeapon;
57 class WeaponDesc;
58 
59 
60 class UWeapon : public Equipment
61 {
62  typedef Equipment base;
63 
64 public:
65  virtual ~UWeapon(){};
66 
67  unsigned short speed() const;
68  unsigned short delay() const;
69 
70  const Mobile::Attribute& attribute() const;
71  unsigned short get_random_damage() const;
72  bool is_projectile() const;
73  bool consume_projectile( Core::UContainer* cont ) const;
74  bool in_range( const Mobile::Character* wielder, const Mobile::Character* target ) const;
75  unsigned short projectile_sound() const;
76  unsigned short projectile_anim() const;
77  // UACTION projectile_action() const;
78  Core::UACTION anim() const;
79  Core::UACTION mounted_anim() const;
80  unsigned short hit_sound() const;
81  unsigned short miss_sound() const;
82 
83  const WeaponDesc& descriptor() const;
84  const Core::ScriptDef& hit_script() const;
85  void set_hit_script( const std::string& scriptname );
86 
87  virtual Item* clone() const POL_OVERRIDE;
88  virtual size_t estimatedSize() const POL_OVERRIDE;
89 
90  DYN_PROPERTY( damage_mod, s16, Core::PROP_DMG_MOD, 0 );
91  DYN_PROPERTY( speed_mod, s16, Core::PROP_SPEED_MOD, 0 );
92 
93 protected:
94  virtual void printProperties( Clib::StreamWriter& sw ) const POL_OVERRIDE;
95  virtual void readProperties( Clib::ConfigElem& elem ) POL_OVERRIDE;
96  // BObjectImp* script_member( const char *membername );
97  virtual Bscript::BObjectImp* get_script_member( const char* membername ) const POL_OVERRIDE;
98  virtual Bscript::BObjectImp* get_script_member_id( const int id ) const POL_OVERRIDE;
99 
100  virtual Bscript::BObjectImp* set_script_member( const char* membername,
101  const std::string& value ) POL_OVERRIDE;
102  virtual Bscript::BObjectImp* set_script_member( const char* membername, int value ) POL_OVERRIDE;
103  virtual Bscript::BObjectImp* set_script_member_double( const char* membername,
104  double value ) POL_OVERRIDE;
105  virtual Bscript::BObjectImp* set_script_member_id( const int id, const std::string& value )
106  POL_OVERRIDE; // id test
107  virtual Bscript::BObjectImp* set_script_member_id( const int id,
108  int value ) POL_OVERRIDE; // id test
109  virtual Bscript::BObjectImp* set_script_member_id_double( const int id,
110  double value ) POL_OVERRIDE; // id test
111  virtual bool script_isa( unsigned isatype ) const POL_OVERRIDE;
112  UWeapon( const WeaponDesc& descriptor, const WeaponDesc* permanent_descriptor );
113  friend class Item;
114  friend void load_data();
115  friend UWeapon* create_intrinsic_weapon( const char* name, Clib::ConfigElem& elem,
116  const Plib::Package* pkg );
117  friend void load_intrinsic_weapons();
118 
119 private:
120  /*
121  max repair % in template
122  quality(0-200%), repair( 0-125%)
123  effective repair is min(repair,100%)
124  quality drops after each repair attempt
125  effects on damage/speed: damage * f( quality, effective repair)
126  f ranges from .5 to 1.5
127  effects on speed: speed * g(quality, effective_repair)
128  g ranges from .75 to 1.25
129  */
130 
132 };
133 
135 {
136  return hit_script_;
137 }
138 
139 bool isa_weapon( u32 objtype );
140 
143  const Plib::Package* pkg );
144 }
145 }
146 #endif
#define POL_OVERRIDE
UWeapon * create_intrinsic_weapon(Clib::ConfigElem &elem)
unsigned int u32
Definition: rawtypes.h:27
Equipment base
Definition: weapon.h:62
signed short s16
Definition: rawtypes.h:30
Core::ScriptDef hit_script_
Definition: weapon.h:131
const Core::ScriptDef & hit_script() const
Definition: weapon.h:134
#define DYN_PROPERTY(name, type, id, defaultvalue)
Definition: dynproperties.h:62
std::string name
Definition: osmod.cpp:943
UWeapon * create_intrinsic_weapon_from_npctemplate(Clib::ConfigElem &elem, const Plib::Package *pkg)
Creates a new intrinic weapon for an NPC template and returns it.
Definition: weapon.cpp:278
void load_intrinsic_weapons()
Creates the intrinsic wrestling weapon for PCs must be called at startup.
Definition: weapon.cpp:244
Definition: berror.cpp:12
bool isa_weapon(u32 objtype)
void load_data()
Definition: loadunld.cpp:152
virtual ~UWeapon()
Definition: weapon.h:65