$treeview $search $mathjax
Stratagus
2.2.6
$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 00061 enum TargetType { 00062 TargetSelf, 00063 TargetPosition, 00064 TargetUnit 00065 }; 00066 00070 enum LocBaseType { 00071 LocBaseCaster, 00072 LocBaseTarget 00073 }; 00074 00081 class SpellActionMissileLocation { 00082 public: 00083 SpellActionMissileLocation(LocBaseType base) : Base(base), AddX(0), AddY(0), 00084 AddRandX(0), AddRandY(0) {} ; 00085 00086 LocBaseType Base; 00087 int AddX; 00088 int AddY; 00089 int AddRandX; 00090 int AddRandY; 00091 }; 00092 00093 class SpellActionTypeAdjustVariable { 00094 public: 00095 SpellActionTypeAdjustVariable() : Enable(0), Value(0), Max(0), Increase(0), 00096 ModifEnable(0), ModifValue(0), ModifMax(0), ModifIncrease(0), 00097 InvertEnable(0), AddValue(0), AddMax(0), AddIncrease(0), IncreaseTime(0), 00098 TargetIsCaster(0) {}; 00099 00100 int Enable; 00101 int Value; 00102 int Max; 00103 int Increase; 00104 00105 char ModifEnable; 00106 char ModifValue; 00107 char ModifMax; 00108 char ModifIncrease; 00109 00110 char InvertEnable; 00111 int AddValue; 00112 int AddMax; 00113 int AddIncrease; 00114 int IncreaseTime; 00115 char TargetIsCaster; 00116 }; 00117 00118 00123 class SpellActionType { 00124 public: 00125 SpellActionType(int mod = 0) : ModifyManaCaster(mod) {}; 00126 virtual ~SpellActionType() {}; 00127 00128 virtual int Cast(CUnit &caster, const SpellType *spell, 00129 CUnit *target, int x, int y) = 0; 00130 00131 const int ModifyManaCaster; 00132 }; 00133 00134 // 00135 // Specific spells. 00136 // 00137 00138 class AreaAdjustVitals : public SpellActionType 00139 { 00140 public: 00141 AreaAdjustVitals() : HP(0), Mana(0) {}; 00142 virtual int Cast(CUnit &caster, const SpellType *spell, 00143 CUnit *target, int x, int y); 00144 00145 int HP; 00146 int Mana; 00147 } ; 00148 00149 class SpawnMissile : public SpellActionType { 00150 public: 00151 SpawnMissile() : Damage(0), TTL(-1), Delay(0), 00152 StartPoint(LocBaseCaster), EndPoint(LocBaseTarget), Missile(0) {}; 00153 virtual int Cast(CUnit &caster, const SpellType *spell, 00154 CUnit *target, int x, int y); 00155 00156 int Damage; 00157 int TTL; 00158 int Delay; 00159 SpellActionMissileLocation StartPoint; 00160 SpellActionMissileLocation EndPoint; 00161 MissileType *Missile; 00162 }; 00163 00164 class Demolish : public SpellActionType { 00165 public: 00166 Demolish() : Damage(0), Range(0) {}; 00167 virtual int Cast(CUnit &caster, const SpellType *spell, 00168 CUnit *target, int x, int y); 00169 00170 int Damage; 00171 int Range; 00172 }; 00173 00174 class AreaBombardment : public SpellActionType { 00175 public: 00176 AreaBombardment() : Fields(0), Shards(0), Damage(0), 00177 StartOffsetX(0), StartOffsetY(0), Missile(NULL) {}; 00178 virtual int Cast(CUnit &caster, const SpellType *spell, 00179 CUnit *target, int x, int y); 00180 00181 int Fields; 00182 int Shards; 00183 int Damage; 00184 int StartOffsetX; 00185 int StartOffsetY; 00186 MissileType *Missile; 00187 }; 00188 00189 class SpawnPortal : public SpellActionType { 00190 public: 00191 SpawnPortal() : PortalType(0) {}; 00192 virtual int Cast(CUnit &caster, const SpellType *spell, 00193 CUnit *target, int x, int y); 00194 00195 CUnitType *PortalType; 00196 }; 00197 00198 class AdjustVariable : public SpellActionType { 00199 public: 00200 AdjustVariable() : Var (NULL) {}; 00201 ~AdjustVariable() { delete [] (this->Var); }; 00202 virtual int Cast(CUnit &caster, const SpellType *spell, 00203 CUnit *target, int x, int y); 00204 00205 SpellActionTypeAdjustVariable *Var; 00206 }; 00207 00208 class AdjustVitals : public SpellActionType { 00209 public: 00210 AdjustVitals() : SpellActionType(1), HP(0), Mana(0), MaxMultiCast(0) {}; 00211 virtual int Cast(CUnit &caster, const SpellType *spell, 00212 CUnit *target, int x, int y); 00213 00214 int HP; 00215 int Mana; 00216 00217 00218 int MaxMultiCast; 00219 }; 00220 00221 class Polymorph : public SpellActionType { 00222 public: 00223 Polymorph() : SpellActionType(1), NewForm(NULL), PlayerNeutral(0) {}; 00224 virtual int Cast(CUnit &caster, const SpellType *spell, 00225 CUnit *target, int x, int y); 00226 00227 CUnitType *NewForm; 00228 int PlayerNeutral; 00229 // TODO: temporary polymorphs would be awesome, but hard to implement 00230 }; 00231 00232 class Summon : public SpellActionType { 00233 public: 00234 Summon() : SpellActionType(1), UnitType(NULL), TTL(0), RequireCorpse(0) {}; 00235 virtual int Cast(CUnit &caster, const SpellType *spell, 00236 CUnit *target, int x, int y); 00237 00238 CUnitType *UnitType; 00239 int TTL; 00240 int RequireCorpse; 00241 }; 00242 00243 class Capture : public SpellActionType { 00244 public: 00245 Capture() : SacrificeEnable(0), Damage(0), DamagePercent(0) {}; 00246 virtual int Cast(CUnit &caster, const SpellType *spell, 00247 CUnit *target, int x, int y); 00248 00249 char SacrificeEnable; 00250 int Damage; 00251 int DamagePercent; 00252 00253 }; 00254 00255 /* 00256 ** ******************* 00257 ** Target definition. 00258 ** ******************* 00259 */ 00260 00261 class Target { 00262 public: 00263 Target(TargetType type, CUnit *unit, const Vec2i &pos) : 00264 Type(type), Unit(unit), targetPos(pos) {} 00265 00266 TargetType Type; 00267 CUnit *Unit; 00268 Vec2i targetPos; 00269 }; 00270 00271 /* 00272 ** ******************* 00273 ** Conditions definition. 00274 ** ******************* 00275 */ 00276 00277 class ConditionInfoVariable { 00278 public: 00279 ConditionInfoVariable() : Enable(0), MinValue(0), MaxValue(0), 00280 MinMax(0), MinValuePercent(0), MaxValuePercent(0), 00281 ConditionApplyOnCaster(0) {}; 00282 00283 char Enable; 00284 00285 int MinValue; 00286 int MaxValue; 00287 int MinMax; 00288 int MinValuePercent; 00289 int MaxValuePercent; 00290 00291 char ConditionApplyOnCaster; 00292 // FIXME : More (increase, MaxMax) ? 00293 }; 00294 00300 class ConditionInfo { 00301 public: 00302 ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(0), 00303 BoolFlag(NULL), Variable(NULL) {}; 00304 ~ConditionInfo() { 00305 delete[] BoolFlag; 00306 delete[] Variable; 00307 }; 00308 // 00309 // Conditions that check specific flags. Possible values are the defines below. 00310 // 00311 #define CONDITION_FALSE 1 00312 #define CONDITION_TRUE 0 00313 #define CONDITION_ONLY 2 00314 char Alliance; 00315 char Opponent; 00316 char TargetSelf; 00317 00318 char *BoolFlag; 00319 00320 ConditionInfoVariable *Variable; 00321 // 00322 // @todo more? feel free to add, here and to 00323 // @todo PassCondition, CclSpellParseCondition, SaveSpells 00324 // 00325 }; 00326 00330 class AutoCastInfo { 00331 public: 00332 AutoCastInfo() : Range(0), Condition(0), Combat(0) {}; 00333 ~AutoCastInfo() { delete Condition; }; 00335 int Range; 00336 00337 ConditionInfo *Condition; 00338 00341 int Combat; 00342 00345 }; 00346 00350 class SpellType { 00351 public: 00352 SpellType(int slot, const std::string &ident); 00353 ~SpellType(); 00354 00355 // Identification stuff 00356 std::string Ident; 00357 std::string Name; 00358 int Slot; 00359 00360 // Spell Specifications 00361 TargetType Target; 00362 std::vector<SpellActionType *> Action; 00363 00364 int Range; 00365 #define INFINITE_RANGE 0xFFFFFFF 00366 int ManaCost; 00367 int RepeatCast; 00368 00369 int DependencyId; 00370 ConditionInfo *Condition; 00371 00372 // Autocast informations. No AICast means the AI use AutoCast. 00373 AutoCastInfo *AutoCast; 00374 AutoCastInfo *AICast; 00375 00376 // Graphics and sounds. Add something else here? 00377 SoundConfig SoundWhenCast; 00378 00379 bool IsCasterOnly() const 00380 { 00381 return !Range && Target == TargetSelf; 00382 } 00383 00384 }; 00385 00386 /*---------------------------------------------------------------------------- 00387 -- Variables 00388 ----------------------------------------------------------------------------*/ 00389 00393 extern std::vector<SpellType *> SpellTypeTable; 00394 00395 00396 /*---------------------------------------------------------------------------- 00397 -- Functions 00398 ----------------------------------------------------------------------------*/ 00399 00401 extern void SpellCclRegister(); 00402 00404 extern void InitSpells(); 00405 00407 extern void CleanSpells(); 00408 00410 extern bool SpellIsAvailable(const CPlayer &player, int SpellId); 00411 00413 extern bool CanCastSpell(const CUnit &caster, const SpellType *spell, 00414 const CUnit *target, int x, int y); 00415 00417 extern int SpellCast(CUnit &caster, const SpellType *spell, 00418 CUnit *target, int x, int y); 00419 00421 extern int AutoCastSpell(CUnit &caster, const SpellType *spell); 00422 00424 extern SpellType *SpellTypeByIdent(const std::string &ident); 00425 00427 extern char Ccl2Condition(lua_State *l, const char *value); 00428 00430 00431 #endif // !__SPELLS_H__