Pol  Revision:cb584c9
spells.h
Go to the documentation of this file.
1 
7 #ifndef SPELLS_H
8 #define SPELLS_H
9 
10 #include <string>
11 #include <time.h>
12 #include <vector>
13 
14 #include "../clib/compilerspecifics.h"
15 #include "../clib/rawtypes.h"
16 #include "action.h"
17 #include "globals/uvars.h"
18 #include "polclock.h"
19 #include "reftypes.h"
20 #include "schedule.h"
21 #include "scrdef.h"
22 
23 namespace Pol
24 {
25 namespace Clib
26 {
27 class ConfigElem;
28 }
29 namespace Plib
30 {
31 class Package;
32 }
33 namespace Mobile
34 {
35 class Character;
36 }
37 namespace Network
38 {
39 class Client;
40 }
41 namespace Core
42 {
43 class USpell;
44 
46 {
47 public:
48  USpellParams();
50  // default ok USpellParams( const USpellParams& );
51 
52 public:
53  unsigned short manacost;
54  unsigned short difficulty;
55  unsigned short pointvalue;
56  unsigned short delay;
57 
58  // unsigned short magery_req_;
59  // unsigned short magery_auto_success_;
60 };
61 
63 {
64 public:
66 
67 public:
69 
70 private:
71  // not implemented:
72  SpellCircle( const SpellCircle& );
73  SpellCircle& operator=( const SpellCircle& );
74 };
75 
76 
77 class USpell
78 {
79 public:
80  USpell( Clib::ConfigElem& elem, Plib::Package* pkg );
81  size_t estimateSize() const;
82  unsigned short spell_id() const;
83  const std::string& name() const;
84 
85  void cast( Mobile::Character* caster );
86  unsigned short manacost() const;
87  unsigned short delay() const;
88  unsigned short difficulty() const;
89 
90  bool consume_reagents( Mobile::Character* chr );
91  bool check_mana( Mobile::Character* chr );
92  bool check_skill( Mobile::Character* chr );
93  void consume_mana( Mobile::Character* chr ); // assumes check_mana has returned true
94  void speak_power_words( Mobile::Character* chr, unsigned short font, unsigned short color );
95  UACTION animation() const;
96 
97  friend void register_spell( USpell* spell, unsigned short spellid );
98 
99 protected:
101 
102  unsigned short spellid_;
103  std::string name_;
104  std::string power_words_;
106 
107  typedef std::vector<unsigned int> RegList;
108  RegList reglist_;
110 
111  /* Only one of these will be set. */
113  /*
114  string script_;
115  void (*f_)(Character* caster);
116  TargetCursor *tcursor_;
117  */
118 
119  static void register_spell( USpell* spell );
120 };
121 inline unsigned short USpell::manacost() const
122 {
123  return params_.manacost;
124 }
125 inline unsigned short USpell::delay() const
126 {
127  return params_.delay;
128 }
129 inline unsigned short USpell::difficulty() const
130 {
131  return params_.difficulty;
132 }
133 inline const std::string& USpell::name() const
134 {
135  return name_;
136 }
138 {
139  return action_;
140 }
141 inline unsigned short USpell::spell_id() const
142 {
143  return spellid_;
144 }
145 
146 inline bool VALID_SPELL_ID( int spellid )
147 {
148  return ( spellid >= 1 && spellid <= int( gamestate.spells.size() ) );
149 }
150 
151 void do_cast( Network::Client* client, u16 spellid );
152 void clean_spells();
153 
154 class SpellTask : public OneShotTask
155 {
156 public:
157  SpellTask( OneShotTask** handle, polclock_t run_when, Mobile::Character* caster, USpell* spell,
158  bool dummy );
159  virtual void on_run() POL_OVERRIDE;
160 
161 private:
164 };
165 }
166 }
167 #endif
unsigned short spellid_
Definition: spells.h:102
std::string name_
Definition: spells.h:103
unsigned short manacost
Definition: spells.h:53
#define POL_OVERRIDE
USpellParams params_
Definition: spells.h:109
Plib::Package * pkg_
Definition: spells.h:100
UACTION action_
Definition: spells.h:105
USpellParams params
Definition: spells.h:68
void register_spell(USpell *spell, unsigned short spellid)
Definition: spells.cpp:395
void clean_spells()
Definition: spells.cpp:502
UACTION animation() const
Definition: spells.h:137
unsigned short manacost() const
Definition: spells.h:121
unsigned short delay() const
Definition: spells.h:125
CharacterRef caster_
Definition: spells.h:162
unsigned short delay
Definition: spells.h:56
ScriptDef scriptdef_
Definition: spells.h:112
const std::string & name() const
Definition: spells.h:133
void do_cast(Network::Client *client, u16 spellid)
Definition: spells.cpp:278
unsigned short u16
Definition: rawtypes.h:26
unsigned short pointvalue
Definition: spells.h:55
unsigned short spell_id() const
Definition: spells.h:141
unsigned short difficulty
Definition: spells.h:54
std::vector< unsigned int > RegList
Definition: spells.h:107
unsigned short difficulty() const
Definition: spells.h:129
USpell * spell_
Definition: spells.h:163
ref_ptr< Mobile::Character > CharacterRef
Definition: reftypes.h:42
void dummy()
Definition: testmisc.cpp:23
std::string power_words_
Definition: spells.h:104
int polclock_t
Definition: polclock.h:26
GameState gamestate
Definition: uvars.cpp:74
std::vector< USpell * > spells
Definition: uvars.h:186
std::string name
Definition: osmod.cpp:943
RegList reglist_
Definition: spells.h:108
Definition: berror.cpp:12
bool VALID_SPELL_ID(int spellid)
Definition: spells.h:146