00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __SPELLS_H__
00030 #define __SPELLS_H__
00031
00033
00034
00035
00036
00037
00038 #include <string>
00039 #include <vector>
00040 #include "unitsound.h"
00041
00042
00043
00044
00045
00046 class CUnit;
00047 class CUnitType;
00048 class CPlayer;
00049 struct lua_State;
00050 class SpellType;
00051 class MissileType;
00052
00053
00054
00055
00056
00060 enum TargetType {
00061 TargetSelf,
00062 TargetPosition,
00063 TargetUnit
00064 };
00065
00069 enum LocBaseType {
00070 LocBaseCaster,
00071 LocBaseTarget
00072 };
00073
00080 class SpellActionMissileLocation {
00081 public:
00082 SpellActionMissileLocation(LocBaseType base) : Base(base), AddX(0), AddY(0),
00083 AddRandX(0), AddRandY(0) {} ;
00084
00085 LocBaseType Base;
00086 int AddX;
00087 int AddY;
00088 int AddRandX;
00089 int AddRandY;
00090 };
00091
00092 class SpellActionTypeAdjustVariable {
00093 public:
00094 SpellActionTypeAdjustVariable() : Enable(0), Value(0), Max(0), Increase(0),
00095 ModifEnable(0), ModifValue(0), ModifMax(0), ModifIncrease(0),
00096 InvertEnable(0), AddValue(0), AddMax(0), AddIncrease(0), IncreaseTime(0),
00097 TargetIsCaster(0) {};
00098
00099 int Enable;
00100 int Value;
00101 int Max;
00102 int Increase;
00103
00104 char ModifEnable;
00105 char ModifValue;
00106 char ModifMax;
00107 char ModifIncrease;
00108
00109 char InvertEnable;
00110 int AddValue;
00111 int AddMax;
00112 int AddIncrease;
00113 int IncreaseTime;
00114 char TargetIsCaster;
00115 };
00116
00117
00122 class SpellActionType {
00123 public:
00124 SpellActionType(int mod = 0) : ModifyManaCaster(mod) {};
00125 virtual ~SpellActionType() {};
00126
00127 virtual int Cast(CUnit *caster, const SpellType *spell,
00128 CUnit *target, int x, int y) = 0;
00129
00130 const int ModifyManaCaster;
00131 };
00132
00133
00134
00135
00136
00137 class AreaAdjustVitals : public SpellActionType
00138 {
00139 public:
00140 AreaAdjustVitals() : HP(0), Mana(0) {};
00141 virtual int Cast(CUnit *caster, const SpellType *spell,
00142 CUnit *target, int x, int y);
00143
00144 int HP;
00145 int Mana;
00146 } ;
00147
00148 class SpawnMissile : public SpellActionType {
00149 public:
00150 SpawnMissile() : Damage(0), TTL(-1), Delay(0),
00151 StartPoint(LocBaseCaster), EndPoint(LocBaseTarget), Missile(0) {};
00152 virtual int Cast(CUnit *caster, const SpellType *spell,
00153 CUnit *target, int x, int y);
00154
00155 int Damage;
00156 int TTL;
00157 int Delay;
00158 SpellActionMissileLocation StartPoint;
00159 SpellActionMissileLocation EndPoint;
00160 MissileType *Missile;
00161 };
00162
00163 class Demolish : public SpellActionType {
00164 public:
00165 Demolish() : Damage(0), Range(0) {};
00166 virtual int Cast(CUnit *caster, const SpellType *spell,
00167 CUnit *target, int x, int y);
00168
00169 int Damage;
00170 int Range;
00171 };
00172
00173 class AreaBombardment : public SpellActionType {
00174 public:
00175 AreaBombardment() : Fields(0), Shards(0), Damage(0),
00176 StartOffsetX(0), StartOffsetY(0), Missile(NULL) {};
00177 virtual int Cast(CUnit *caster, const SpellType *spell,
00178 CUnit *target, int x, int y);
00179
00180 int Fields;
00181 int Shards;
00182 int Damage;
00183 int StartOffsetX;
00184 int StartOffsetY;
00185 MissileType *Missile;
00186 };
00187
00188 class SpawnPortal : public SpellActionType {
00189 public:
00190 SpawnPortal() : PortalType(0) {};
00191 virtual int Cast(CUnit *caster, const SpellType *spell,
00192 CUnit *target, int x, int y);
00193
00194 CUnitType *PortalType;
00195 };
00196
00197 class AdjustVariable : public SpellActionType {
00198 public:
00199 AdjustVariable() : Var (NULL) {};
00200 ~AdjustVariable() { delete [] (this->Var); };
00201 virtual int Cast(CUnit *caster, const SpellType *spell,
00202 CUnit *target, int x, int y);
00203
00204 SpellActionTypeAdjustVariable *Var;
00205 };
00206
00207 class AdjustVitals : public SpellActionType {
00208 public:
00209 AdjustVitals() : SpellActionType(1), HP(0), Mana(0), MaxMultiCast(0) {};
00210 virtual int Cast(CUnit *caster, const SpellType *spell,
00211 CUnit *target, int x, int y);
00212
00213 int HP;
00214 int Mana;
00215
00216
00217 int MaxMultiCast;
00218 };
00219
00220 class Polymorph : public SpellActionType {
00221 public:
00222 Polymorph() : SpellActionType(1), NewForm(NULL), PlayerNeutral(0) {};
00223 virtual int Cast(CUnit *caster, const SpellType *spell,
00224 CUnit *target, int x, int y);
00225
00226 CUnitType *NewForm;
00227 int PlayerNeutral;
00228
00229 };
00230
00231 class Summon : public SpellActionType {
00232 public:
00233 Summon() : SpellActionType(1), UnitType(NULL), TTL(0), RequireCorpse(0) {};
00234 virtual int Cast(CUnit *caster, const SpellType *spell,
00235 CUnit *target, int x, int y);
00236
00237 CUnitType *UnitType;
00238 int TTL;
00239 int RequireCorpse;
00240 };
00241
00242 class Capture : public SpellActionType {
00243 public:
00244 Capture() : SacrificeEnable(0), Damage(0), DamagePercent(0) {};
00245 virtual int Cast(CUnit *caster, const SpellType *spell,
00246 CUnit *target, int x, int y);
00247
00248 char SacrificeEnable;
00249 int Damage;
00250 int DamagePercent;
00251
00252 };
00253
00254
00255
00256
00257
00258
00259
00260 class Target {
00261 public:
00262 Target(TargetType type, CUnit *unit, int x, int y) :
00263 Type(type), Unit(unit), X(x), Y(y) {}
00264
00265 TargetType Type;
00266 CUnit *Unit;
00267 int X;
00268 int Y;
00269 };
00270
00271
00272
00273
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
00293 };
00294
00300 class ConditionInfo {
00301 public:
00302 ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(0),
00303 Building(0), Organic(0), Variable(NULL) {};
00304 ~ConditionInfo() {
00305 delete[] Variable;
00306 };
00307
00308
00309
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 Building;
00319 char Organic;
00320
00321 ConditionInfoVariable *Variable;
00322
00323
00324
00325
00326 };
00327
00331 class AutoCastInfo {
00332 public:
00333 AutoCastInfo() : Range(0), Condition(0), Combat(0) {};
00334 ~AutoCastInfo() { delete Condition; };
00336 int Range;
00337
00338 ConditionInfo *Condition;
00339
00342 int Combat;
00343
00346 };
00347
00351 class SpellType {
00352 public:
00353 SpellType(int slot, const std::string &ident);
00354 ~SpellType();
00355
00356
00357 std::string Ident;
00358 std::string Name;
00359 int Slot;
00360
00361
00362 TargetType Target;
00363 std::vector<SpellActionType *> Action;
00364
00365 int Range;
00366 #define INFINITE_RANGE 0xFFFFFFF
00367 int ManaCost;
00368 int RepeatCast;
00369
00370 int DependencyId;
00371 ConditionInfo *Condition;
00372
00373
00374 AutoCastInfo *AutoCast;
00375 AutoCastInfo *AICast;
00376
00377
00378 SoundConfig SoundWhenCast;
00379 };
00380
00381
00382
00383
00384
00388 extern std::vector<SpellType *> SpellTypeTable;
00389
00390
00391
00392
00393
00394
00396 extern void SpellCclRegister(void);
00397
00399 extern void InitSpells(void);
00400
00402 extern void CleanSpells(void);
00403
00405 extern bool SpellIsAvailable(const CPlayer *player, int SpellId);
00406
00408 extern bool CanCastSpell(const CUnit *caster, const SpellType *spell,
00409 const CUnit *target, int x, int y);
00410
00412 extern int SpellCast(CUnit *caster, const SpellType *spell,
00413 CUnit *target, int x, int y);
00414
00416 extern int AutoCastSpell(CUnit *caster, const SpellType *spell);
00417
00419 extern SpellType *SpellTypeByIdent(const std::string &ident);
00420
00422 extern char Ccl2Condition(lua_State *l, const char *value);
00423
00425
00426 #endif // !__SPELLS_H__