Planeshift
psspell.h
Go to the documentation of this file.
1 /*
2  * psspell.h
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef __PSSPELL_H__
21 #define __PSSPELL_H__
22 
23 //=============================================================================
24 // Crystal Space Includes
25 //=============================================================================
26 #include <csutil/csstring.h>
27 
28 //=============================================================================
29 // Project Includes
30 //=============================================================================
31 #include <idal.h>
32 #include "util/scriptvar.h"
33 #include "util/gameevent.h"
34 
35 //=============================================================================
36 // Local Includes
37 //=============================================================================
38 #include "psskills.h"
39 #include "psitemstats.h"
40 #include "deleteobjcallback.h"
41 
42 class Client;
43 class gemObject;
44 class gemActor;
45 class ProgressionScript;
46 class MathExpression;
47 
52 struct psWay
53 {
54  unsigned int id;
55  PSSKILL skill; // for example, Crystal Way
56  PSSKILL related_stat_skill; // for example, Charisma
57  csString name;
58 };
59 
61 {
62  float mana;
63  float stamina;
64 };
65 
66 typedef csArray <psItemStats*> glyphList_t;
67 
68 
74 class psSpell : public iScriptableVar
75 {
76 public:
77  psSpell();
78  ~psSpell();
79 
80  bool Load(iResultRow &row);
81  int GetID() const
82  {
83  return id;
84  }
85  const csString &GetName() const
86  {
87  return name;
88  }
89  const csString &GetImage() const
90  {
91  return image;
92  }
93  const csString &GetDescription() const
94  {
95  return description;
96  }
97  psSpellCost ManaCost(psCharacter* caster, float kFactor) const;
98  float PowerLevel(psCharacter* caster, float kFactor) const;
99  float ChanceOfCastSuccess(psCharacter* caster, float kFactor) const;
100  float ChanceOfResearchSuccess(psCharacter* researcher);
101 
105  bool MatchGlyphs(const csArray<psItemStats*> &glyphs);
106 
113  bool CanCast(gemActor* caster, float kFactor, csString &reason, bool canCastAllSpells);
114 
122  void Cast(gemActor* caster, float kFactor, Client* client) const;
123 
124  /*
125  * @param castingDuration The time it was waited before the spell could affect targets.
126  */
127  void Affect(gemActor* caster, gemObject* target, float range, float kFactor, float power, Client* client, csTicks castingDuration) const;
128 
129  int GetRealm()
130  {
131  return realm;
132  }
134  {
135  return way;
136  }
137  csArray<psItemStats*> &GetGlyphList()
138  {
139  return glyphList;
140  }
141 
145  double GetProperty(MathEnvironment* env, const char* ptr);
147  double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
148  const char* ToString()
149  {
150  return name.GetDataSafe();
151  }
153 
154 protected:
155  bool AffectTarget(gemActor* caster, gemObject* origTarget, gemObject* target, float power, Client* client) const;
156 
157  int id;
158  csString name;
160  int realm;
161  csString image;
162  csString description;
163  csString castingEffect;
164  bool offensive;
165 
167  float maxPower;
168 
171 
183 
185  csArray<psItemStats*> glyphList;
186 
189 
192 
195 };
196 
197 //-----------------------------------------------------------------------------
198 
203 {
204 public:
208  const psSpell* spell;
209 
210  float max_range;
211  float kFactor;
212  float powerLevel;
213  csTicks duration;
214 
215  psSpellCastGameEvent(const psSpell* spell,
216  gemActor* caster,
217  gemObject* target,
218  csTicks castingDuration,
219  float max_range,
220  float kFactor,
221  float power,
222  Client* client);
223 
225 
226  void Interrupt();
227 
228  virtual void Trigger(); // Abstract event processing function
229  virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
230 };
231 
234 #endif
const csString & GetName() const
Definition: psspell.h:85
int targetTypes
Bit field if valid target types for this spell.
Definition: psspell.h:170
float mana
Definition: psspell.h:62
ProgressionScript is the imperative script container.
Definition: scripting.h:78
float npcSpellRelativePower
Relative Power of spell, used as a hint to npc perception system.
Definition: psspell.h:194
Client * client
The client that cast the spell, NULL if superclient.
Definition: psspell.h:207
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
uint32_t npcSpellCategoryID
Hash ID of category of spell, use in network compression to npc perception system.
Definition: psspell.h:191
unsigned int id
Definition: psspell.h:54
psWay * GetWay()
Definition: psspell.h:133
csString description
Definition: psspell.h:162
MathExpression * castDuration
Math for various properties. Casting duration: (Power, WaySkill, RelatedStat) -> Seconds.
Definition: psspell.h:174
csArray< psItemStats * > glyphList_t
Definition: psspell.h:66
The base expression class.
Definition: mathscript.h:330
csArray< psItemStats * > glyphList
List of glyphs required to assemble the technique.
Definition: psspell.h:185
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
ProgressionScript * outcome
The progression script: (Power, Caster, Target) -> (side effects)
Definition: psspell.h:182
This event actually triggers a spell, after the casting wait time.
Definition: psspell.h:202
int id
Definition: psspell.h:157
PSSKILL
Definition: psskills.h:44
csArray< psItemStats * > & GetGlyphList()
Definition: psspell.h:137
int GetID() const
Definition: psspell.h:81
MathExpression * aoeAngle
AOE Angle: (Power, WaySkill, RelatedStat) -> Degrees.
Definition: psspell.h:180
int realm
Definition: psspell.h:160
MathExpression * aoeRadius
AOE Radius: (Power, WaySkill, RelatedStat) -> Meters.
Definition: psspell.h:178
const char * ToString()
Definition: psspell.h:148
Represents a spell.
Definition: psspell.h:74
bool offensive
Definition: psspell.h:164
Definition: psspell.h:52
PSSKILL skill
Definition: psspell.h:55
This class collects data of a netclient.
Definition: client.h:95
float maxPower
The Power (P) cap.
Definition: psspell.h:167
gemObject * target
Entity who is target of this spell.
Definition: psspell.h:206
csString castingEffect
Definition: psspell.h:163
MathExpression * range
Maximum range to target allowed: (Power, WaySkill, RelatedStat) -> Meters.
Definition: psspell.h:176
const psSpell * spell
The spell that is cast.
Definition: psspell.h:208
csString npcSpellCategory
Name of category of spell, which will sent to npc perception system.
Definition: psspell.h:188
csString name
Definition: psspell.h:57
float stamina
Definition: psspell.h:63
csString image
Definition: psspell.h:161
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
const csString & GetImage() const
Definition: psspell.h:89
const csString & GetDescription() const
Definition: psspell.h:93
int GetRealm()
Definition: psspell.h:129
csString name
Definition: psspell.h:158
All scheduled events must inherit from this class.
Definition: gameevent.h:36
This class generically allows objects to be notified when a gemObject is removed. ...
PSSKILL related_stat_skill
Definition: psspell.h:56
gemActor * caster
Entity who casting this spell.
Definition: psspell.h:205
psWay * way
Definition: psspell.h:159