Planeshift
|
00001 /* 00002 * scripting.h - by Kenneth Graunke <[email protected]> 00003 * 00004 * Copyright (C) 2009 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef SCRIPTING_HEADER 00021 #define SCRIPTING_HEADER 00022 00023 //============================================================================= 00024 // Crystal Space Includes 00025 //============================================================================= 00026 #include <iutil/document.h> 00027 #include <csutil/parray.h> 00028 #include <csutil/csstring.h> 00029 00030 //============================================================================= 00031 // Project Includes 00032 //============================================================================= 00033 #include "util/psconst.h" 00034 00054 // forward declarations 00055 class MathEnvironment; 00056 class MathExpression; 00057 class ActiveSpell; 00058 class EntityManager; 00059 class CacheManager; 00060 00064 enum SCRIPT_TRIGGER 00065 { 00066 ATTACK, 00067 DEFENSE, 00068 MOVE, 00069 NEARLYDEAD 00070 }; 00071 00072 class ImperativeOp; // forward declaration of private script operation 00073 00078 class ProgressionScript 00079 { 00080 public: 00084 ~ProgressionScript(); 00095 static ProgressionScript* Create(EntityManager* entitymanager,CacheManager* cachemanager, const char* name, const char* script); 00105 static ProgressionScript* Create(EntityManager* entitymanager,CacheManager* cachemanager, const char* name, iDocumentNode* top); 00106 00110 const csString &GetName() 00111 { 00112 return name; 00113 } 00118 void Run(MathEnvironment* env); 00119 00120 protected: 00126 ProgressionScript(const char* name) : name(name) { } 00127 00128 csString name; 00129 csArray<ImperativeOp*> ops; 00130 }; 00131 00132 class AppliedOp; // forward declaration of private script operation 00133 00143 class ApplicativeScript 00144 { 00145 public: 00149 ~ApplicativeScript(); 00159 static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, const char* script); 00168 static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, iDocumentNode* top); 00180 static ApplicativeScript* Create(EntityManager* entitymanager, CacheManager* cachemanager, iDocumentNode* top, SPELL_TYPE type, const char* name, const char* duration); 00181 00188 ActiveSpell* Apply(MathEnvironment* env, bool registerCancelEvent = true); 00189 /*** 00190 * retrieve the description of the Applicativescripts commands 00191 * @return csString containing a description of the scripts effect 00192 */ 00193 const csString &GetDescription(MathEnvironment* env); 00194 00195 void SetImage( csString tImage ) { image=tImage; } 00196 00197 protected: 00201 ApplicativeScript(); 00202 00203 SPELL_TYPE type; 00204 csString aim; 00205 csString name; 00206 csString description; 00207 csString image; 00208 MathExpression* duration; 00209 csPDelArray<AppliedOp> ops; 00210 }; 00211 00212 #if 0 00213 // Eventually, we'll want to be able to target items in the inventory, 00214 // and specific points on the ground, as well as entities in the world. 00215 class Target 00216 { 00217 public: 00218 Target(psItem* item) : type(TARGET_PSITEM), item(item) { } 00219 Target(gemObject* obj) : type(TARGET_GEMOBJECT), obj(obj) { } 00220 //Target(Location loc) : loc(loc), type(TARGET_LOCATION) { } 00221 00222 protected: 00223 enum Type 00224 { 00225 TARGET_GEMOBJECT, 00226 TARGET_PSITEM, 00227 TARGET_LOCATION 00228 }; 00229 Type type; 00230 00231 union 00232 { 00233 psItem* item; 00234 gemObject* obj; 00235 //Location loc; 00236 }; 00237 }; 00238 #endif 00239 00243 #endif