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
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "ISpellMechanics.h"
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "effects/Effects.h"
|
2016-03-01 11:20:38 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
struct BattleSpellCast;
|
2015-09-16 06:33:36 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
namespace spells
|
2015-04-03 02:28:20 +02:00
|
|
|
{
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
class BattleSpellMechanics : public BaseMechanics
|
2015-02-02 11:22:19 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-07-20 06:08:49 +02:00
|
|
|
BattleSpellMechanics(const IBattleCast * event, std::shared_ptr<effects::Effects> effects_, std::shared_ptr<IReceptiveCheck> targetCondition_);
|
|
|
|
virtual ~BattleSpellMechanics();
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
// TODO: ??? (what's the difference compared to cast?)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
void applyEffects(ServerCallback * server, const Target & targets, bool indirect, bool ignoreImmunity) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
/// Returns false if spell can not be cast at all, e.g. due to not having any possible target on battlefield
|
2017-07-20 06:08:49 +02:00
|
|
|
bool canBeCast(Problem & problem) const override;
|
2022-12-22 23:11:55 +02:00
|
|
|
|
2024-06-24 03:23:26 +02:00
|
|
|
/// Returns false if spell can not be cast at specified target
|
2021-02-20 03:57:50 +02:00
|
|
|
bool canBeCastAt(const Target & target, Problem & problem) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
// TODO: ??? (what's the difference compared to applyEffects?)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
void cast(ServerCallback * server, const Target & target) override final;
|
2022-12-22 23:11:55 +02:00
|
|
|
// TODO: ??? (what's the difference compared to cast?)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
void castEval(ServerCallback * server, const Target & target) override final;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
/// Returns list of affected stack using currently configured target
|
2017-07-20 06:08:49 +02:00
|
|
|
std::vector<const CStack *> getAffectedStacks(const Target & target) const override final;
|
2015-03-18 12:27:07 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
/// Returns list of target types that can be targeted by spell
|
2017-07-20 06:08:49 +02:00
|
|
|
std::vector<AimType> getTargetTypes() const override final;
|
2022-12-22 23:11:55 +02:00
|
|
|
|
|
|
|
/// Returns vector of all possible destinations for specified aim type
|
|
|
|
/// index - ???
|
|
|
|
/// current - ???
|
2023-08-08 17:38:41 +02:00
|
|
|
std::vector<Destination> getPossibleDestinations(size_t index, AimType aimType, const Target & current, bool fast) const override final;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
/// Returns true if spell can be cast on unit
|
2017-07-20 06:08:49 +02:00
|
|
|
bool isReceptive(const battle::Unit * target) const override;
|
2016-09-05 12:34:48 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
/// Returns list of hexes that are affected by spell assuming cast at centralHex
|
|
|
|
std::vector<BattleHex> rangeInHexes(BattleHex centralHex) const override;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
const Spell * getSpell() const override;
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
bool counteringSelector(const Bonus * bonus) const;
|
2016-09-05 12:34:48 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
private:
|
|
|
|
std::shared_ptr<effects::Effects> effects;
|
|
|
|
std::shared_ptr<IReceptiveCheck> targetCondition;
|
2016-09-05 12:34:48 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::vector<const battle::Unit *> affectedUnits;
|
|
|
|
effects::Effects::EffectsToApply effectsToApply;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void beforeCast(BattleSpellCast & sc, vstd::RNG & rng, const Target & target);
|
2016-09-05 12:34:48 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::set<const battle::Unit *> collectTargets() const;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2023-08-31 17:45:52 +02:00
|
|
|
void doRemoveEffects(ServerCallback * server, const std::vector<const battle::Unit *> & targets, const CSelector & selector);
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::set<BattleHex> spellRangeInHexes(BattleHex centralHex) const;
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
Target transformSpellTarget(const Target & aimPoint) const;
|
2015-02-02 11:22:19 +02:00
|
|
|
};
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
2015-02-02 11:22:19 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|