My Project
 
Loading...
Searching...
No Matches
wand.h
Go to the documentation of this file.
1#pragma once
2
3#include "kindofweapon.h"
4#include "itemstatushandler.h"
5#include "buff.h"
6#include "mob.h"
7#include "wndbag.h"
8#include "callback.h"
9
10class Wand :public KindOfWeapon{
11protected:
12 class Charger :public Buff{
13 public:
14 virtual std::string getClassName() { return "Charger"; }
15 virtual std::string toString() { return "Charger"; };
16 virtual bool attachTo(Char* target) {
18 delay();
19
20 return true;
21 }
22
23 virtual bool act();
24
26 Charger(Wand* wa) :w(wa){}
27 protected:
28 void delay();
29 private:
30 static const float TIME_TO_CHARGE;
31 };
32private:
33 static const int USAGES_TO_KNOW = 40;
34 static const std::string TXT_WOOD;
35 static const std::string TXT_DAMAGE;
36 static const std::string TXT_WEAPON;
37
38 static const std::string TXT_FIZZLES;
39 static const std::string TXT_SELF_TARGET;
40
41 static const std::string TXT_IDENTIFY;
42
43 static const float TIME_TO_ZAP;
44
45 static const std::string _woods[];
46 static std::vector<std::string> woods;
47
48 static const int _images[];
49 static std::vector<int> images;
50
51 static std::string _wands[];
52 static std::vector<std::string> wands;
53
54 static ItemStatusHandler* handler;
55
56 bool curChargeKnown;
57
58 int usagesToKnow;
59
60 static const std::string UNFAMILIRIARITY;
61 static const std::string MAX_CHARGES;
62 static const std::string CUR_CHARGES;
63 static const std::string CUR_CHARGE_KNOWN;
64
65 std::string wood;
66public:
69
70 static const std::string AC_ZAP;
71
72 Wand();
73
74 virtual int min() {
75 int tier = 1 + effectiveLevel() / 3;
76 return tier;
77 }
78 virtual int max() {
79 int level = effectiveLevel();
80 int tier = 1 + level / 3;
81 return (tier * tier - tier + 10) / 2 + level;
82 }
83
84 static void initWoods();
85 static void save(Bundle* bundle);
86 static void restore(Bundle* bundle);
87
88 virtual void actions(Hero* hero, std::vector<std::string>& actions);
89 virtual bool doUnequip(Hero* hero, bool collect, bool single);
90 virtual void activate(Hero* hero);
91
92 virtual void execute(Hero* hero, const std::string& action);
93 virtual bool collect(Bag* container);
94
95 void charge(Char* owner);
96 void onDetach() {
98 }
99 void stopCharging() {
100 if (charger != NULL)
101 {
102 charger->detach();
103 charger = NULL;
104 }
105 }
106 int power();
107 void setKnown();
108 virtual Item* identify();
109 virtual std::string toString();
110 virtual std::string Name() {
111 return isKnown() ? name : wood + " wand";
112 }
113 virtual std::string info();
114 virtual bool isIdentified();
115 virtual std::string status();
116 virtual Item* upgrade();
117 virtual Item* degrade();
118 virtual int maxDurability(int lvl) {
119 return 6 * (lvl < 16 ? 16 - lvl : 1);
120 }
121 virtual Item* random();
122 static bool allKnown();
123 virtual int price() {
124 return considerState(50);
125 }
126 virtual void storeInBundle(Bundle* bundle);
127 virtual void restoreFromBundle(Bundle* bundle);
128protected:
132
133 virtual void init();
134 virtual int initialCharges() { return 2; }
135
136 virtual void onZap(int cell) = 0;
137 bool isKnown();
138 void updateLevel();
139 virtual void fx(int cell, Callback* callback);
140 void wandUsed();
141};
142
144public:
146
147 virtual std::string desc() {
148 return BPT::getText("lang.WandOfTeleportation_Desc");
149 //std::string("A blast from this wand will teleport a creature against ") +
150 //std::string("its will to a random place on the current level.");
151 }
152 virtual std::string getClassName() { return "WandOfTeleportation"; }
153 static Item* Create(){ return new WandOfTeleportation(); }
154protected:
155 virtual void onZap(int cell);
156 void fx(int cell, Callback* callback);
157};
158
159class WandOfSlowness :public Wand{
160public:
162 virtual std::string desc() {
163 return BPT::getText("lang.WandOfSlowness_Desc");
164 //std::string("This wand will cause a creature to move and attack ") +
165 //std::string("at half its ordinary speed until the effect ends");
166 }
167 virtual std::string getClassName() { return "WandOfSlowness"; }
168 static Item* Create(){ return new WandOfSlowness(); }
169protected:
170 virtual void onZap(int cell);
171 void fx(int cell, Callback* callback);
172};
173
174class WandOfFirebolt :public Wand{
175public:
177 virtual std::string desc() {
178 return BPT::getText("lang.WandOfFirebolt_Desc");
179 //std::string("This wand unleashes bursts of magical fire. It will ignite ") +
180 //std::string("flammable terrain, and will damage and burn a creature it hits.");
181 }
182 virtual std::string getClassName() { return "WandOfFirebolt"; }
183 static Item* Create(){ return new WandOfFirebolt(); }
184protected:
185 virtual void onZap(int cell);
186 void fx(int cell, Callback* callback);
187};
188
189class WandOfPoison :public Wand{
190public:
191 WandOfPoison();
192
193 virtual std::string desc() {
194 return BPT::getText("lang.WandOfPoison_Desc");
195 //std::string("The vile blast of this twisted bit of wood will imbue its target ") +
196 //std::string("with a deadly venom. A creature that is poisoned will suffer periodic ") +
197 //std::string("damage until the effect ends. The duration of the effect increases ") +
198 //std::string("with the level of the staff.");
199 }
200 virtual std::string getClassName() { return "WandOfPoison"; }
201 static Item* Create(){ return new WandOfPoison(); }
202protected:
203 virtual void onZap(int cell);
204 void fx(int cell, Callback* callback);
205};
206
207class WandOfRegrowth :public Wand{
208public:
210 virtual std::string desc() {
211 return BPT::getText("lang.WandOfRegrowth_Desc");
212 //std::string("\"When life ceases new life always begins to grow... The eternal cycle always remains!\"");
213 }
214 virtual std::string getClassName() { return "WandOfRegrowth"; }
215 static Item* Create(){ return new WandOfRegrowth(); }
216protected:
217 virtual void onZap(int cell);
218 void fx(int cell, Callback* callback);
219};
220
221class WandOfBlink :public Wand{
222public:
223 WandOfBlink();
224
225 static void appear(Char* ch, int pos);
226 virtual std::string desc() {
227 return BPT::getText("lang.WandOfBlink_Desc");
228 //std::string("This wand will allow you to teleport in the chosen direction. ") +
229 //std::string("Creatures and inanimate obstructions will block the teleportation.");
230 }
231 virtual std::string getClassName() { return "WandOfBlink"; }
232 static Item* Create(){ return new WandOfBlink(); }
233protected:
234 virtual void onZap(int cell);
235 void fx(int cell, Callback* callback);
236};
237
238class WandOfLightning :public Wand{
239public:
241 virtual std::string getClassName() { return "WandOfLightning"; }
242 static Item* Create(){ return new WandOfLightning(); }
243
244 virtual std::string desc() {
245 return BPT::getText("lang.WandOfLightning_Desc");
246 //std::string("This wand conjures forth deadly arcs of electricity, which deal damage ") +
247 //std::string("to several creatures standing close to each other.");
248 }
249
250private:
251 std::list<Char*> affected;
252
253 std::vector<int> points;
254 int nPoints;
255
256 void hit(Char* ch, int damage);
257
258
259protected:
260 virtual void onZap(int cell);
261 void fx(int cell, Callback* callback);
262};
263
264class WandOfAmok :public Wand{
265public:
266 WandOfAmok();
267
268 virtual std::string desc() {
269 return BPT::getText("lang.WandOfAmok_Desc");
270 //std::string("The purple light from this wand will make the target run amok ") +
271 //std::string("attacking random creatures in its vicinity.");
272 }
273 virtual std::string getClassName() { return "WandOfAmok"; }
274 static Item* Create(){ return new WandOfAmok(); }
275protected:
276 virtual void onZap(int cell);
277 void fx(int cell, Callback* callback);
278};
279
280class WandOfReach :public Wand{
281public:
282 WandOfReach();
283
284 virtual std::string desc() {
285 return
286 std::string("This utility wand can be used to grab objects from a distance and to switch places with enemies. ") +
287 std::string("Waves of magic force radiated from it will affect all cells on their way triggering traps, ") +
288 std::string("trampling high vegetation, opening closed doors and closing open ones.");
289 }
290 virtual std::string getClassName() { return "WandOfReach"; }
291 static Item* Create(){ return new WandOfReach(); }
292private:
293 static const std::string TXT_YOU_NOW_HAVE;
294
295 void transport(Heap* heap);
296protected:
297 virtual void onZap(int cell);
298 void fx(int cell, Callback* callback);
299};
300
301class WandOfFlock :public Wand{
302public:
303 class Sheep :public NPC{
304 public:
305 Sheep();
306
307 virtual CharSprite* Sprite();
308 virtual std::string getClassName() { return "Sheep"; }
309 float lifespan;
310
311 virtual void damage(int dmg, const std::string& src) {
312 }
313 virtual std::string description() {
314 return BPT::getText("lang.WandOfFlock_Sheep_Desc");
315 //std::string("This is a magic sheep. What's so magical about it? You can't kill it. ") +
316 //std::string("It will stand there until it magcially fades away, all the while chewing cud with a blank stare.");
317 }
318 virtual void interact();
319 protected:
320 virtual bool act();
321 private:
322 static const std::string QUOTES[4];
323 bool initialized;
324 };
325public:
326 WandOfFlock();
327
328 virtual std::string desc() {
329 return BPT::getText("lang.WandOfFlock_Desc");
330 //std::string("A flick of this wand summons a flock of magic sheep, creating temporary impenetrable obstacle.");
331 }
332 virtual std::string getClassName() { return "WandOfFlock"; }
333 static Item* Create(){ return new WandOfFlock(); }
334protected:
335 virtual void onZap(int cell);
336 void fx(int cell, Callback* callback);
337};
338
340public:
342
343 virtual std::string desc() {
344 return BPT::getText("lang.WandOfDisintegration_Desc");
345 //std::string("This wand emits a beam of destructive energy, which pierces all creatures in its way. ") +
346 //std::string("The more targets it hits, the more damage it inflicts to each of them.");
347 }
348 virtual std::string getClassName() { return "WandOfDisintegration"; }
349 static Item* Create(){ return new WandOfDisintegration(); }
350private:
351 int distance() {
352 return Level() + 4;
353 }
354protected:
355 virtual void onZap(int cell);
356 void fx(int cell, Callback* callback);
357};
358
359class WandOfAvalanche :public Wand{
360public:
362
363 virtual std::string desc() {
364 return BPT::getText("lang.WandOfAvalanche_Desc");
365 //std::string ("When a discharge of this wand hits a wall (or any other solid obstacle) it causes ") +
366 //std::string("an avalanche of stones, damaging and stunning all creatures in the affected area.");
367 }
368 virtual std::string getClassName() { return "WandOfAvalanche"; }
369 static Item* Create(){ return new WandOfAvalanche(); }
370protected:
371 virtual void onZap(int cell);
372 void fx(int cell, Callback* callback);
373};
374
376public:
378
379 virtual std::string getClassName() { return "WandOfMagicMissile"; }
380 static Item* Create(){ return new WandOfMagicMissile(); }
381
382 static const String AC_DISENCHANT;
383
384 virtual void actions(Hero* hero, std::vector<std::string>& actions);
385 virtual void execute(Hero* hero, const std::string& action);
386 virtual void setKnown() {
387 }
388 virtual String desc() {
389 return BPT::getText("lang.WandOfMagicMissile_Desc");
390 //"This wand launches missiles of pure magical energy, dealing moderate damage to a target creature.";
391 }
392
394 static const float TIME_TO_DISENCHANT;
395
397private:
398 static const String TXT_SELECT_WAND;
399
400 WndBag::Listener* itemSelector;
401protected:
402 virtual void onZap(int cell);
403 virtual boolean isKnown() {
404 return true;
405 }
406 virtual int initialCharges() {
407 return 3;
408 }
409};
static std::string getText(const std::string &key)
Definition bpt.cpp:26
Definition bag.h:9
Char * target
Definition buff.h:13
Buff()
Definition buff.cpp:20
virtual bool attachTo(Char *target)
Definition buff.cpp:25
Definition cellselector.h:9
Definition char.h:9
Definition charsprite.h:13
Definition heap.h:11
Definition hero.h:18
Definition item.h:15
int Level()
Definition item.h:119
int considerState(int price)
Definition item.cpp:394
std::string name
Definition item.h:48
virtual int effectiveLevel()
Definition item.cpp:231
Definition itemstatushandler.h:10
Definition kindofweapon.h:5
NPC()
Definition mob.cpp:548
Definition wand.h:12
virtual std::string toString()
Definition wand.h:15
virtual bool attachTo(Char *target)
Definition wand.h:16
Wand * w
Definition wand.h:25
Charger(Wand *wa)
Definition wand.h:26
virtual bool act()
Definition wand.cpp:417
virtual std::string getClassName()
Definition wand.h:14
void delay()
Definition wand.cpp:430
virtual int price()
Definition wand.h:123
virtual Item * upgrade()
Definition wand.cpp:212
int maxCharges
Definition wand.h:67
virtual int initialCharges()
Definition wand.h:134
virtual Item * degrade()
Definition wand.cpp:223
virtual Item * identify()
Definition wand.cpp:151
void stopCharging()
Definition wand.h:99
void updateLevel()
Definition wand.cpp:340
static const std::string AC_ZAP
Definition wand.h:70
virtual int min()
Definition wand.h:74
virtual Item * random()
Definition wand.cpp:233
virtual void onZap(int cell)=0
virtual void fx(int cell, Callback *callback)
Definition wand.cpp:346
bool isKnown()
Definition wand.cpp:334
virtual void init()
Definition wand.cpp:329
virtual void activate(Hero *hero)
Definition wand.cpp:88
static void initWoods()
Definition wand.cpp:39
virtual void actions(Hero *hero, std::vector< std::string > &actions)
Definition wand.cpp:54
virtual int maxDurability(int lvl)
Definition wand.h:118
virtual void execute(Hero *hero, const std::string &action)
Definition wand.cpp:92
int curCharges
Definition wand.h:68
static CellSelector::Listener * zapper
Definition wand.h:131
virtual bool isIdentified()
Definition wand.cpp:196
Charger * charger
Definition wand.h:129
virtual std::string Name()
Definition wand.h:110
virtual bool collect(Bag *container)
Definition wand.cpp:107
void charge(Char *owner)
Definition wand.cpp:121
static bool allKnown()
Definition wand.cpp:245
Wand()
Definition wand.cpp:25
static void save(Bundle *bundle)
Definition wand.cpp:44
void setKnown()
Definition wand.cpp:142
void wandUsed()
Definition wand.cpp:352
virtual std::string status()
Definition wand.cpp:201
virtual void restoreFromBundle(Bundle *bundle)
Definition wand.cpp:260
virtual std::string toString()
Definition wand.cpp:162
static void restore(Bundle *bundle)
Definition wand.cpp:49
virtual void storeInBundle(Bundle *bundle)
Definition wand.cpp:251
virtual int max()
Definition wand.h:78
bool hitChars
Definition wand.h:130
int power()
Definition wand.cpp:129
void onDetach()
Definition wand.h:96
virtual std::string info()
Definition wand.cpp:179
virtual bool doUnequip(Hero *hero, bool collect, bool single)
Definition wand.cpp:82
virtual void onZap(int cell)
Definition wand.cpp:752
static Item * Create()
Definition wand.h:274
WandOfAmok()
Definition wand.cpp:747
virtual std::string desc()
Definition wand.h:268
void fx(int cell, Callback *callback)
Definition wand.cpp:772
virtual std::string getClassName()
Definition wand.h:273
WandOfAvalanche()
Definition wand.cpp:1034
virtual std::string getClassName()
Definition wand.h:368
void fx(int cell, Callback *callback)
Definition wand.cpp:1101
virtual void onZap(int cell)
Definition wand.cpp:1040
virtual std::string desc()
Definition wand.h:363
static Item * Create()
Definition wand.h:369
static Item * Create()
Definition wand.h:349
void fx(int cell, Callback *callback)
Definition wand.cpp:1027
virtual void onZap(int cell)
Definition wand.cpp:974
WandOfDisintegration()
Definition wand.cpp:968
virtual std::string desc()
Definition wand.h:343
virtual std::string getClassName()
Definition wand.h:348
static Item * Create()
Definition wand.h:183
virtual std::string getClassName()
Definition wand.h:182
void fx(int cell, Callback *callback)
Definition wand.cpp:555
virtual void onZap(int cell)
Definition wand.cpp:527
virtual std::string desc()
Definition wand.h:177
WandOfFirebolt()
Definition wand.cpp:522
virtual bool act()
Definition wand.cpp:949
Sheep()
Definition wand.cpp:930
virtual void interact()
Definition wand.cpp:942
virtual std::string description()
Definition wand.h:313
virtual CharSprite * Sprite()
Definition wand.cpp:937
virtual void damage(int dmg, const std::string &src)
Definition wand.h:311
virtual std::string getClassName()
Definition wand.h:308
float lifespan
Definition wand.h:309
WandOfFlock()
Definition wand.cpp:868
virtual std::string desc()
Definition wand.h:328
virtual void onZap(int cell)
Definition wand.cpp:873
void fx(int cell, Callback *callback)
Definition wand.cpp:924
virtual std::string getClassName()
Definition wand.h:332
static Item * Create()
Definition wand.h:333
virtual std::string desc()
Definition wand.h:244
virtual void onZap(int cell)
Definition wand.cpp:715
static Item * Create()
Definition wand.h:242
WandOfLightning()
Definition wand.cpp:677
void fx(int cell, Callback *callback)
Definition wand.cpp:725
virtual std::string getClassName()
Definition wand.h:241
static Item * Create()
Definition wand.h:380
virtual void actions(Hero *hero, std::vector< std::string > &actions)
Definition wand.cpp:1109
static const float TIME_TO_DISENCHANT
Definition wand.h:394
virtual void execute(Hero *hero, const std::string &action)
Definition wand.cpp:1117
virtual int initialCharges()
Definition wand.h:406
virtual String desc()
Definition wand.h:388
boolean disenchantEquipped
Definition wand.h:396
virtual void setKnown()
Definition wand.h:386
static const String TXT_DISENCHANTED
Definition wand.h:393
static const String AC_DISENCHANT
Definition wand.h:382
virtual void onZap(int cell)
Definition wand.cpp:1148
virtual boolean isKnown()
Definition wand.h:403
WandOfMagicMissile()
Definition wand.cpp:1198
virtual std::string getClassName()
Definition wand.h:379
void fx(int cell, Callback *callback)
Definition wand.cpp:581
virtual std::string desc()
Definition wand.h:193
virtual void onZap(int cell)
Definition wand.cpp:566
virtual std::string getClassName()
Definition wand.h:200
static Item * Create()
Definition wand.h:201
WandOfPoison()
Definition wand.cpp:561
virtual void onZap(int cell)
Definition wand.cpp:810
WandOfReach()
Definition wand.cpp:778
virtual std::string desc()
Definition wand.h:284
virtual std::string getClassName()
Definition wand.h:290
static Item * Create()
Definition wand.h:291
void fx(int cell, Callback *callback)
Definition wand.cpp:862
static Item * Create()
Definition wand.h:215
void fx(int cell, Callback *callback)
Definition wand.cpp:627
WandOfRegrowth()
Definition wand.cpp:587
virtual void onZap(int cell)
Definition wand.cpp:592
virtual std::string getClassName()
Definition wand.h:214
virtual std::string desc()
Definition wand.h:210
WandOfSlowness()
Definition wand.cpp:496
void fx(int cell, Callback *callback)
Definition wand.cpp:516
virtual std::string getClassName()
Definition wand.h:167
static Item * Create()
Definition wand.h:168
virtual void onZap(int cell)
Definition wand.cpp:501
virtual std::string desc()
Definition wand.h:162
virtual std::string getClassName()
Definition wand.h:152
WandOfTeleportation()
Definition wand.cpp:440
static Item * Create()
Definition wand.h:153
virtual std::string desc()
Definition wand.h:147
void fx(int cell, Callback *callback)
Definition wand.cpp:490
virtual void onZap(int cell)
Definition wand.cpp:445
Definition wndbag.h:23
std::string String
Definition typedefine.h:8