$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1999-2006 by Vladi Belperchinov-Shabanski, 00014 // Joris DAUPHIN, and Jimmy Salmon 00015 // 00016 // This program is free software; you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation; only version 2 of the License. 00019 // 00020 // This program is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 // GNU General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU General Public License 00026 // along with this program; if not, write to the Free Software 00027 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 // 02111-1307, USA. 00029 // 00030 00031 #ifndef __SPELLS_H__ 00032 #define __SPELLS_H__ 00033 00035 00036 /*---------------------------------------------------------------------------- 00037 -- Includes 00038 ----------------------------------------------------------------------------*/ 00039 00040 #include "unitsound.h" 00041 #include "vec2i.h" 00042 00043 /*---------------------------------------------------------------------------- 00044 -- Declarations 00045 ----------------------------------------------------------------------------*/ 00046 00047 class CUnit; 00048 class CUnitType; 00049 class CPlayer; 00050 struct lua_State; 00051 class SpellType; 00052 class MissileType; 00053 00054 /*---------------------------------------------------------------------------- 00055 -- Definitons 00056 ----------------------------------------------------------------------------*/ 00057 00062 class SpellActionType 00063 { 00064 public: 00065 SpellActionType(int mod = 0) : ModifyManaCaster(mod) {}; 00066 virtual ~SpellActionType() {}; 00067 00068 virtual int Cast(CUnit &caster, const SpellType &spell, 00069 CUnit *target, const Vec2i &goalPos) = 0; 00070 virtual void Parse(lua_State *l, int startIndex, int endIndex) = 0; 00071 00072 const int ModifyManaCaster; 00073 }; 00074 00075 00079 enum TargetType { 00080 TargetSelf, 00081 TargetPosition, 00082 TargetUnit 00083 }; 00084 00085 /* 00086 ** ******************* 00087 ** Target definition. 00088 ** ******************* 00089 */ 00090 00091 class Target 00092 { 00093 public: 00094 Target(TargetType type, CUnit *unit, const Vec2i &pos) : 00095 Type(type), Unit(unit), targetPos(pos) {} 00096 00097 TargetType Type; 00098 CUnit *Unit; 00099 Vec2i targetPos; 00100 }; 00101 00102 /* 00103 ** ******************* 00104 ** Conditions definition. 00105 ** ******************* 00106 */ 00107 00108 class ConditionInfoVariable 00109 { 00110 public: 00111 ConditionInfoVariable() : Enable(0), Check(false), MinValue(0), MaxValue(0), 00112 MinMax(0), MinValuePercent(0), MaxValuePercent(0), 00113 ConditionApplyOnCaster(0) {}; 00114 00115 char Enable; 00116 bool Check; 00117 00118 int MinValue; 00119 int MaxValue; 00120 int MinMax; 00121 int MinValuePercent; 00122 int MaxValuePercent; 00123 00124 char ConditionApplyOnCaster; 00125 // FIXME : More (increase, MaxMax) ? 00126 }; 00127 00133 class ConditionInfo 00134 { 00135 public: 00136 ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(0), 00137 BoolFlag(NULL), Variable(NULL) {}; 00138 ~ConditionInfo() { 00139 delete[] BoolFlag; 00140 delete[] Variable; 00141 }; 00142 // 00143 // Conditions that check specific flags. Possible values are the defines below. 00144 // 00145 #define CONDITION_FALSE 1 00146 #define CONDITION_TRUE 0 00147 #define CONDITION_ONLY 2 00148 char Alliance; 00149 char Opponent; 00150 char TargetSelf; 00151 00152 char *BoolFlag; 00153 00154 ConditionInfoVariable *Variable; 00155 // 00156 // @todo more? feel free to add, here and to 00157 // @todo PassCondition, CclSpellParseCondition, SaveSpells 00158 // 00159 }; 00160 00164 class AutoCastInfo 00165 { 00166 public: 00167 AutoCastInfo() : Range(0), Condition(0), Combat(0) {}; 00168 ~AutoCastInfo() { delete Condition; }; 00170 int Range; 00171 00172 ConditionInfo *Condition; 00173 00176 int Combat; 00177 00180 }; 00181 00185 class SpellType 00186 { 00187 public: 00188 SpellType(int slot, const std::string &ident); 00189 ~SpellType(); 00190 00191 // Identification stuff 00192 std::string Ident; 00193 std::string Name; 00194 int Slot; 00195 00196 // Spell Specifications 00197 TargetType Target; 00198 std::vector<SpellActionType *> Action; 00199 00200 int Range; 00201 #define INFINITE_RANGE 0xFFFFFFF 00202 int ManaCost; 00203 int RepeatCast; 00204 00205 int DependencyId; 00206 ConditionInfo *Condition; 00207 00208 // Autocast informations. No AICast means the AI use AutoCast. 00209 AutoCastInfo *AutoCast; 00210 AutoCastInfo *AICast; 00211 00212 // Graphics and sounds. Add something else here? 00213 SoundConfig SoundWhenCast; 00214 00215 bool IsCasterOnly() const { 00216 return !Range && Target == TargetSelf; 00217 } 00218 00219 }; 00220 00221 /*---------------------------------------------------------------------------- 00222 -- Variables 00223 ----------------------------------------------------------------------------*/ 00224 00228 extern std::vector<SpellType *> SpellTypeTable; 00229 00230 00231 /*---------------------------------------------------------------------------- 00232 -- Functions 00233 ----------------------------------------------------------------------------*/ 00234 00236 extern void SpellCclRegister(); 00237 00239 extern void InitSpells(); 00240 00242 extern void CleanSpells(); 00243 00245 extern bool SpellIsAvailable(const CPlayer &player, int SpellId); 00246 00248 extern bool CanCastSpell(const CUnit &caster, const SpellType &spell, 00249 const CUnit *target, const Vec2i &goalPos); 00250 00252 extern int SpellCast(CUnit &caster, const SpellType &spell, 00253 CUnit *target, const Vec2i &goalPos); 00254 00256 extern int AutoCastSpell(CUnit &caster, const SpellType &spell); 00257 00259 extern SpellType *SpellTypeByIdent(const std::string &ident); 00260 00262 extern char Ccl2Condition(lua_State *l, const char *value); 00263 00265 00266 #endif // !__SPELLS_H__