Planeshift
activespell.h
Go to the documentation of this file.
1 /*
2  * activespell.h by Kenneth Graunke <kenneth@whitecape.org>
3  *
4  * Copyright (C) 2009 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation (version 2 of the License)
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #ifndef ACTIVESPELL_HEADER
19 #define ACTIVESPELL_HEADER
20 
21 //=============================================================================
22 // Crystal Space Includes
23 //=============================================================================
24 #include <csutil/parray.h>
25 
26 //=============================================================================
27 // Project Includes
28 //=============================================================================
29 #include "util/psconst.h"
30 
31 //=============================================================================
32 // Local Includes
33 //=============================================================================
34 #include "buffable.h"
35 
36 
37 struct iDocumentNode;
38 class gemActor;
39 
52 {
53 public:
54  virtual ~iCancelAction() { }
55  virtual void Cancel() = 0;
56 };
57 
68 class ActiveSpell : public CS::Utility::WeakReferenced
69 {
70 public:
71  ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration);
72  ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration, const csString &image);
74 
75  // These are only used by progression scripts, for loading/initializing it.
76  void Add(iSpellModifier &mod, const char* fmt, ...);
77  void Add(iCancelAction* action, const char* fmt, ...);
78 
79  void Register(gemActor* target);
80  void Link(ActiveSpell* other);
81 
82  void SetCancelOnDeath(bool x)
83  {
84  cancelOnDeath = x;
85  }
87  {
88  return cancelOnDeath;
89  }
90 
92  {
93  damagesHP = true;
94  }
95  bool DamagesHP()
96  {
97  return damagesHP;
98  }
99 
100  const csString &Name() const
101  {
102  return name;
103  }
104  const csString &Image() const
105  {
106  return image;
107  }
108  SPELL_TYPE Type() const
109  {
110  return type;
111  }
112  csTicks Duration() const
113  {
114  return duration;
115  }
116  csTicks RegistrationTime() const
117  {
118  return registrationTime;
119  }
120  void SetImage(csString imageName);
121  csString GetImage();
122 
128  bool Cancel();
129 
130  bool HasExpired() const;
131 
135  csString Persist() const;
136 
137 protected:
138  csString name;
139  csString image;
141  csString script;
142  csTicks duration;
144  bool damagesHP;
145 
148 
149  csArray<iSpellModifier*> modifiers;
150  csPDelArray<iCancelAction> actions;
151 };
152 
155 #endif
iCancelAction
Definition: activespell.h:51
virtual void Cancel()=0
const csString & Name() const
Definition: activespell.h:100
void MarkAsDamagingHP()
Definition: activespell.h:91
SPELL_TYPE Type() const
Definition: activespell.h:108
void SetCancelOnDeath(bool x)
Definition: activespell.h:82
SPELL_TYPE type
Spell type - buff, debuff, etc.
Definition: activespell.h:140
const csString & Image() const
Definition: activespell.h:104
csTicks duration
How long this spell lasts.
Definition: activespell.h:142
bool cancelOnDeath
Whether or not this spell should be cancelled on death.
Definition: activespell.h:143
virtual ~iCancelAction()
Definition: activespell.h:54
csString image
The icon representing the spell.
Definition: activespell.h:139
csString script
the contents of an <apply> node which recreates this effect
Definition: activespell.h:141
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
iSpellModifiers
Definition: buffable.h:37
csPDelArray< iCancelAction > actions
Actions to take when cancelling (i.e. unattaching scripts).
Definition: activespell.h:150
csTicks Duration() const
Definition: activespell.h:112
bool DamagesHP()
Definition: activespell.h:95
csArray< iSpellModifier * > modifiers
The iSpellModifiers this ActiveSpell altered, for cancelling.
Definition: activespell.h:149
csTicks registrationTime
Timestamp when the spell was registered, for comparison with csGetTicks().
Definition: activespell.h:147
ActiveSpells.
Definition: activespell.h:68
csString name
The name of the spell.
Definition: activespell.h:138
csTicks RegistrationTime() const
Definition: activespell.h:116
SPELL_TYPE
Definition: psconst.h:126
gemActor * target
Who this spell is registered with.
Definition: activespell.h:146
bool CancelOnDeath()
Definition: activespell.h:86
bool damagesHP
Whether or not this spell damages HP (for cancel on duel defeat)
Definition: activespell.h:144