Planeshift
scripting.h
Go to the documentation of this file.
1 /*
2  * scripting.h - by Kenneth Graunke <kenneth@whitecape.org>
3  *
4  * Copyright (C) 2009 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 SCRIPTING_HEADER
21 #define SCRIPTING_HEADER
22 
23 //=============================================================================
24 // Crystal Space Includes
25 //=============================================================================
26 #include <iutil/document.h>
27 #include <csutil/parray.h>
28 #include <csutil/csstring.h>
29 
30 //=============================================================================
31 // Project Includes
32 //=============================================================================
33 #include "util/psconst.h"
34 
54 // forward declarations
55 class MathEnvironment;
56 class MathExpression;
57 class ActiveSpell;
58 class EntityManager;
59 class CacheManager;
60 
65 {
68  MOVE,
70 };
71 
72 class ImperativeOp; // forward declaration of private script operation
73 
79 {
80 public:
95  static ProgressionScript* Create(EntityManager* entitymanager,CacheManager* cachemanager, const char* name, const char* script);
105  static ProgressionScript* Create(EntityManager* entitymanager,CacheManager* cachemanager, const char* name, iDocumentNode* top);
106 
110  const csString &GetName()
111  {
112  return name;
113  }
118  void Run(MathEnvironment* env);
119 
120 protected:
126  ProgressionScript(const char* name) : name(name) { }
127 
128  csString name;
129  csArray<ImperativeOp*> ops;
130 };
131 
132 class AppliedOp; // forward declaration of private script operation
133 
144 {
145 public:
159  static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, const char* script);
168  static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, iDocumentNode* top);
180  static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, iDocumentNode* top, SPELL_TYPE type, const char* name, const char* duration);
181 
188  ActiveSpell* Apply(MathEnvironment* env, bool registerCancelEvent = true);
189  /***
190  * retrieve the description of the Applicativescripts commands
191  * @return csString containing a description of the scripts effect
192  */
193  const csString &GetDescription(MathEnvironment* env);
194 
195  void SetImage( csString tImage ) { image=tImage; }
196 
197 protected:
202 
204  csString aim;
205  csString name;
206  csString description;
207  csString image;
209  csPDelArray<AppliedOp> ops;
210 };
211 
212 #if 0
213 // Eventually, we'll want to be able to target items in the inventory,
214 // and specific points on the ground, as well as entities in the world.
215 class Target
216 {
217 public:
218  Target(psItem* item) : type(TARGET_PSITEM), item(item) { }
219  Target(gemObject* obj) : type(TARGET_GEMOBJECT), obj(obj) { }
220  //Target(Location loc) : loc(loc), type(TARGET_LOCATION) { }
221 
222 protected:
223  enum Type
224  {
225  TARGET_GEMOBJECT,
226  TARGET_PSITEM,
227  TARGET_LOCATION
228  };
229  Type type;
230 
231  union
232  {
233  psItem* item;
234  gemObject* obj;
235  //Location loc;
236  };
237 };
238 #endif
239 
243 #endif
Manages CEL entities on the server.
Definition: entitymanager.h:77
ProgressionScript is the imperative script container.
Definition: scripting.h:78
triggered <on type="nearlydead">
Definition: scripting.h:69
void SetImage(csString tImage)
Definition: scripting.h:195
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
SPELL_TYPE type
spell type...buff, debuff, etc.
Definition: scripting.h:203
csString name
the name of the spell
Definition: scripting.h:205
ProgressionScript(const char *name)
internal constructor for Create().
Definition: scripting.h:126
csString description
textual representation of the effect
Definition: scripting.h:206
The base expression class.
Definition: mathscript.h:330
static ProgressionScript * Create(EntityManager *entitymanager, CacheManager *cachemanager, const char *name, const char *script)
create a progressionscript from a string containing a xml script
SCRIPT_TRIGGER
Events that can trigger scripts, i.e.
Definition: scripting.h:64
csPDelArray< AppliedOp > ops
all the sub-operations
Definition: scripting.h:209
const csString & GetName()
fetch the name of this progressionscript object
Definition: scripting.h:110
~ProgressionScript()
default destructor deletes all internally stored script operation object
csString image
graphical representation of the effect
Definition: scripting.h:207
ActiveSpells.
Definition: activespell.h:68
ApplicativeScript is the applied script container.
Definition: scripting.h:143
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
MathExpression * duration
an embedded MathExpression
Definition: scripting.h:208
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
triggered <on type="move">
Definition: scripting.h:68
csString aim
name of the MathScript var to aim at
Definition: scripting.h:204
triggered <on type="attack">
Definition: scripting.h:66
SPELL_TYPE
Definition: psconst.h:126
triggered <on type="defense">
Definition: scripting.h:67
void Run(MathEnvironment *env)
Run is executing the internally stored script.
csArray< ImperativeOp * > ops
script operation objects, warning: may have objects that contain further arrays of operations ...
Definition: scripting.h:129
csString name
name of the script object (identifier?)
Definition: scripting.h:128
This class embodies item instances in the game.
Definition: psitem.h:238