2015-02-02 10:40:06 +02:00
|
|
|
/*
|
|
|
|
* BattleSpellMechanics.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CDefaultSpellMechanics.h"
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2016-03-01 11:20:38 +02:00
|
|
|
class CObstacleInstance;
|
2016-09-05 12:34:48 +02:00
|
|
|
class SpellCreatedObstacle;
|
2016-03-01 11:20:38 +02:00
|
|
|
|
2015-09-16 06:33:36 +02:00
|
|
|
class DLL_LINKAGE HealingSpellMechanics : public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
2016-02-15 12:34:37 +02:00
|
|
|
enum class EHealLevel
|
2015-09-16 06:56:02 +02:00
|
|
|
{
|
|
|
|
HEAL,
|
|
|
|
RESURRECT,
|
|
|
|
TRUE_RESURRECT
|
|
|
|
};
|
2015-09-16 08:03:36 +02:00
|
|
|
|
2016-02-15 12:34:37 +02:00
|
|
|
HealingSpellMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2015-09-16 06:33:36 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-09-16 14:43:39 +02:00
|
|
|
virtual int calculateHealedHP(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
2015-09-16 06:56:02 +02:00
|
|
|
virtual EHealLevel getHealLevel(int effectLevel) const = 0;
|
2015-09-16 06:33:36 +02:00
|
|
|
};
|
|
|
|
|
2015-04-03 02:28:20 +02:00
|
|
|
class DLL_LINKAGE AntimagicMechanics : public DefaultSpellMechanics
|
|
|
|
{
|
|
|
|
public:
|
2016-02-15 12:34:37 +02:00
|
|
|
AntimagicMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
|
|
|
|
|
|
|
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
|
2015-04-03 02:28:20 +02:00
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE ChainLightningMechanics : public DefaultSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-02-26 19:59:18 +02:00
|
|
|
ChainLightningMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2016-09-06 06:05:55 +02:00
|
|
|
protected:
|
|
|
|
std::vector<const CStack *> calculateAffectedStacks(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE CloneMechanics : public DefaultSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CloneMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2015-09-26 19:09:54 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2015-09-16 06:33:36 +02:00
|
|
|
class DLL_LINKAGE CureMechanics : public HealingSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-09-16 06:33:36 +02:00
|
|
|
CureMechanics(CSpell * s): HealingSpellMechanics(s){};
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2015-03-09 21:07:28 +02:00
|
|
|
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
|
2016-09-11 12:48:14 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2016-02-15 12:34:37 +02:00
|
|
|
|
2015-09-16 06:56:02 +02:00
|
|
|
EHealLevel getHealLevel(int effectLevel) const override final;
|
2016-09-11 12:48:14 +02:00
|
|
|
private:
|
|
|
|
static bool dispellSelector(const Bonus * b);
|
2015-02-26 19:59:18 +02:00
|
|
|
};
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispellMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2015-09-26 19:09:54 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2015-04-03 02:02:16 +02:00
|
|
|
|
2015-03-09 21:07:28 +02:00
|
|
|
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
|
2015-04-03 02:01:05 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2016-09-06 07:20:17 +02:00
|
|
|
class DLL_LINKAGE EarthquakeMechanics : public SpecialSpellMechanics
|
2015-03-18 12:27:07 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-06 07:20:17 +02:00
|
|
|
EarthquakeMechanics(CSpell * s): SpecialSpellMechanics(s){};
|
2016-09-18 15:30:03 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2016-09-05 10:36:25 +02:00
|
|
|
bool requiresCreatureTarget() const override;
|
2015-03-18 12:27:07 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-03-18 12:27:07 +02:00
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE HypnotizeMechanics : public DefaultSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-02-26 19:59:18 +02:00
|
|
|
HypnotizeMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2015-09-26 19:09:54 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2015-02-26 19:59:18 +02:00
|
|
|
};
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2016-09-06 07:20:17 +02:00
|
|
|
class DLL_LINKAGE ObstacleMechanics : public SpecialSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-06 07:20:17 +02:00
|
|
|
ObstacleMechanics(CSpell * s): SpecialSpellMechanics(s){};
|
2016-09-04 04:15:37 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const override;
|
2016-09-05 12:34:48 +02:00
|
|
|
protected:
|
2016-09-23 19:27:55 +02:00
|
|
|
static bool isHexAviable(const CBattleInfoCallback * cb, const BattleHex & hex, const bool mustBeClear);
|
2016-09-05 12:34:48 +02:00
|
|
|
void placeObstacle(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, const BattleHex & pos) const;
|
|
|
|
virtual void setupObstacle(SpellCreatedObstacle * obstacle) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PatchObstacleMechanics : public ObstacleMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PatchObstacleMechanics(CSpell * s): ObstacleMechanics(s){};
|
2016-09-24 10:25:29 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2016-09-05 12:34:48 +02:00
|
|
|
class DLL_LINKAGE LandMineMechanics : public PatchObstacleMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LandMineMechanics(CSpell * s): PatchObstacleMechanics(s){};
|
|
|
|
bool requiresCreatureTarget() const override;
|
|
|
|
protected:
|
|
|
|
void setupObstacle(SpellCreatedObstacle * obstacle) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE QuicksandMechanics : public PatchObstacleMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QuicksandMechanics(CSpell * s): PatchObstacleMechanics(s){};
|
|
|
|
bool requiresCreatureTarget() const override;
|
|
|
|
protected:
|
|
|
|
void setupObstacle(SpellCreatedObstacle * obstacle) const override;
|
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE WallMechanics : public ObstacleMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-02-26 19:59:18 +02:00
|
|
|
WallMechanics(CSpell * s): ObstacleMechanics(s){};
|
|
|
|
std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2016-09-05 12:34:48 +02:00
|
|
|
class DLL_LINKAGE FireWallMechanics : public WallMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FireWallMechanics(CSpell * s): WallMechanics(s){};
|
|
|
|
bool requiresCreatureTarget() const override;
|
|
|
|
protected:
|
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
|
|
|
void setupObstacle(SpellCreatedObstacle * obstacle) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE ForceFieldMechanics : public WallMechanics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ForceFieldMechanics(CSpell * s): WallMechanics(s){};
|
|
|
|
bool requiresCreatureTarget() const override;
|
|
|
|
protected:
|
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
|
|
|
void setupObstacle(SpellCreatedObstacle * obstacle) const override;
|
|
|
|
};
|
|
|
|
|
2016-09-06 07:20:17 +02:00
|
|
|
class DLL_LINKAGE RemoveObstacleMechanics : public SpecialSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-06 07:20:17 +02:00
|
|
|
RemoveObstacleMechanics(CSpell * s): SpecialSpellMechanics(s){};
|
2016-09-18 15:30:03 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2016-09-04 04:15:37 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const override;
|
2016-09-05 10:36:25 +02:00
|
|
|
bool requiresCreatureTarget() const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2016-03-01 11:20:38 +02:00
|
|
|
private:
|
|
|
|
bool canRemove(const CObstacleInstance * obstacle, const int spellLevel) const;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
///all rising spells
|
2015-09-16 06:33:36 +02:00
|
|
|
class DLL_LINKAGE RisingSpellMechanics : public HealingSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-09-16 06:33:36 +02:00
|
|
|
RisingSpellMechanics(CSpell * s): HealingSpellMechanics(s){};
|
2016-03-04 15:42:55 +02:00
|
|
|
|
2015-09-16 06:56:02 +02:00
|
|
|
EHealLevel getHealLevel(int effectLevel) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE SacrificeMechanics : public RisingSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-02-26 19:59:18 +02:00
|
|
|
SacrificeMechanics(CSpell * s): RisingSpellMechanics(s){};
|
2015-04-02 23:35:29 +02:00
|
|
|
|
2016-09-18 15:30:03 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2016-09-05 10:36:25 +02:00
|
|
|
bool requiresCreatureTarget() const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2016-02-15 12:34:37 +02:00
|
|
|
int calculateHealedHP(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2016-03-04 15:42:55 +02:00
|
|
|
///ANIMATE_DEAD and RESURRECTION
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE SpecialRisingSpellMechanics : public RisingSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SpecialRisingSpellMechanics(CSpell * s): RisingSpellMechanics(s){};
|
2016-09-04 04:15:37 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const override;
|
2015-09-26 19:09:54 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2016-09-06 07:20:17 +02:00
|
|
|
class DLL_LINKAGE SummonMechanics : public SpecialSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-06 07:20:17 +02:00
|
|
|
SummonMechanics(CSpell * s, CreatureID cre): SpecialSpellMechanics(s), creatureToSummon(cre){};
|
2015-04-02 23:35:29 +02:00
|
|
|
|
2016-09-18 15:30:03 +02:00
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2016-09-05 10:36:25 +02:00
|
|
|
bool requiresCreatureTarget() const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-04-11 11:09:48 +02:00
|
|
|
private:
|
|
|
|
CreatureID creatureToSummon;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2015-03-09 20:24:45 +02:00
|
|
|
class DLL_LINKAGE TeleportMechanics: public DefaultSpellMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TeleportMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
2016-09-18 15:30:03 +02:00
|
|
|
|
|
|
|
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ECastingMode::ECastingMode mode, const ISpellCaster * caster) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
protected:
|
2015-09-26 20:35:30 +02:00
|
|
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|