Planeshift

activespell.h

Go to the documentation of this file.
00001 /*
00002  * activespell.h by Kenneth Graunke <[email protected]>
00003  *
00004  * Copyright (C) 2009 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation (version 2 of the License)
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016  */
00017 
00018 #ifndef ACTIVESPELL_HEADER
00019 #define ACTIVESPELL_HEADER
00020 
00021 //=============================================================================
00022 // Crystal Space Includes
00023 //=============================================================================
00024 #include <csutil/parray.h>
00025 
00026 //=============================================================================
00027 // Project Includes
00028 //=============================================================================
00029 #include "util/psconst.h"
00030 
00031 //=============================================================================
00032 // Local Includes
00033 //=============================================================================
00034 #include "buffable.h"
00035 
00036 
00037 struct iDocumentNode;
00038 class gemActor;
00039 
00051 class iCancelAction
00052 {
00053 public:
00054     virtual ~iCancelAction() { }
00055     virtual void Cancel() = 0;
00056 };
00057 
00068 class ActiveSpell : public CS::Utility::WeakReferenced
00069 {
00070 public:
00071     ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration);
00072     ActiveSpell(const csString &name, SPELL_TYPE type, csTicks duration, const csString &image);
00073     ~ActiveSpell() { }
00074 
00075     // These are only used by progression scripts, for loading/initializing it.
00076     void Add(iSpellModifier &mod, const char* fmt, ...);
00077     void Add(iCancelAction* action, const char* fmt, ...);
00078 
00079     void Register(gemActor* target);
00080     void Link(ActiveSpell* other);
00081 
00082     void SetCancelOnDeath(bool x)
00083     {
00084         cancelOnDeath = x;
00085     }
00086     bool CancelOnDeath()
00087     {
00088         return cancelOnDeath;
00089     }
00090 
00091     void MarkAsDamagingHP()
00092     {
00093         damagesHP = true;
00094     }
00095     bool DamagesHP()
00096     {
00097         return damagesHP;
00098     }
00099 
00100     const csString &Name() const
00101     {
00102         return name;
00103     }
00104     const csString &Image() const
00105     {
00106         return image;
00107     }
00108     SPELL_TYPE      Type() const
00109     {
00110         return type;
00111     }
00112     csTicks Duration() const
00113     {
00114         return duration;
00115     }
00116     csTicks RegistrationTime() const
00117     {
00118         return registrationTime;
00119     }
00120     void SetImage(csString imageName);
00121     csString GetImage();
00122 
00128     bool Cancel();
00129 
00130     bool HasExpired() const;
00131 
00135     csString Persist() const;
00136 
00137 protected:
00138     csString name;            
00139     csString image;            
00140     SPELL_TYPE type;          
00141     csString script;          
00142     csTicks duration;         
00143     bool cancelOnDeath;       
00144     bool damagesHP;           
00145 
00146     gemActor* target;         
00147     csTicks registrationTime; 
00148 
00149     csArray<iSpellModifier*> modifiers; 
00150     csPDelArray<iCancelAction> actions; 
00151 };
00152 
00155 #endif