2014-11-12 10:36:34 +02:00
|
|
|
/*
|
2015-02-02 11:22:19 +02:00
|
|
|
* ISpellMechanics.cpp, part of VCMI engine
|
2014-11-12 10:36:34 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
2015-02-02 10:25:26 +02:00
|
|
|
#include "ISpellMechanics.h"
|
2014-11-12 10:36:34 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "../CRandomGenerator.h"
|
2022-06-28 10:05:30 +02:00
|
|
|
#include "../VCMI_Lib.h"
|
2017-03-17 17:48:44 +02:00
|
|
|
|
2023-05-01 19:29:53 +02:00
|
|
|
#include "../bonuses/Bonus.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "../battle/CBattleInfoCallback.h"
|
|
|
|
#include "../battle/IBattleState.h"
|
|
|
|
#include "../battle/Unit.h"
|
2015-09-17 07:42:30 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "../mapObjects/CGHeroInstance.h"
|
|
|
|
|
|
|
|
#include "../serializer/JsonDeserializer.h"
|
|
|
|
#include "../serializer/JsonSerializer.h"
|
|
|
|
|
|
|
|
#include "TargetCondition.h"
|
|
|
|
#include "Problem.h"
|
2014-11-12 10:36:34 +02:00
|
|
|
|
2015-02-02 11:22:19 +02:00
|
|
|
#include "AdventureSpellMechanics.h"
|
|
|
|
#include "BattleSpellMechanics.h"
|
2014-11-13 03:53:25 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "effects/Effects.h"
|
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
|
|
|
#include "effects/Registry.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "effects/Damage.h"
|
|
|
|
#include "effects/Timed.h"
|
|
|
|
|
|
|
|
#include "CSpellHandler.h"
|
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
|
|
|
#include "../NetPacks.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
#include "../CHeroHandler.h"//todo: remove
|
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
|
|
|
#include "../IGameCallback.h"//todo: remove
|
2022-06-28 10:05:30 +02:00
|
|
|
#include "../BattleFieldHandler.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
namespace spells
|
|
|
|
{
|
|
|
|
|
|
|
|
static std::shared_ptr<TargetCondition> makeCondition(const CSpell * s)
|
|
|
|
{
|
|
|
|
std::shared_ptr<TargetCondition> res = std::make_shared<TargetCondition>();
|
|
|
|
|
|
|
|
JsonDeserializer deser(nullptr, s->targetCondition);
|
|
|
|
res->serializeJson(deser, TargetConditionItemFactory::getDefault());
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CustomMechanicsFactory : public ISpellMechanicsFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::unique_ptr<Mechanics> create(const IBattleCast * event) const override
|
|
|
|
{
|
2023-02-11 17:18:05 +02:00
|
|
|
auto * ret = new BattleSpellMechanics(event, effects, targetCondition);
|
2017-07-20 06:08:49 +02:00
|
|
|
return std::unique_ptr<Mechanics>(ret);
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
std::shared_ptr<effects::Effects> effects;
|
|
|
|
|
|
|
|
CustomMechanicsFactory(const CSpell * s)
|
|
|
|
: ISpellMechanicsFactory(s), effects(new effects::Effects)
|
|
|
|
{
|
|
|
|
targetCondition = makeCondition(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadEffects(const JsonNode & config, const int level)
|
|
|
|
{
|
|
|
|
JsonDeserializer deser(nullptr, config);
|
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
|
|
|
effects->serializeJson(VLC->spellEffects(), deser, level);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
private:
|
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
|
|
|
std::shared_ptr<IReceptiveCheck> targetCondition;
|
2017-07-20 06:08:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigurableMechanicsFactory : public CustomMechanicsFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ConfigurableMechanicsFactory(const CSpell * s)
|
|
|
|
: CustomMechanicsFactory(s)
|
|
|
|
{
|
|
|
|
for(int level = 0; level < GameConstants::SPELL_SCHOOL_LEVELS; level++)
|
|
|
|
loadEffects(s->getLevelInfo(level).battleEffects, level);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//to be used for spells configured with old format
|
|
|
|
class FallbackMechanicsFactory : public CustomMechanicsFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FallbackMechanicsFactory(const CSpell * s)
|
|
|
|
: CustomMechanicsFactory(s)
|
|
|
|
{
|
|
|
|
for(int level = 0; level < GameConstants::SPELL_SCHOOL_LEVELS; level++)
|
|
|
|
{
|
|
|
|
const CSpell::LevelInfo & levelInfo = s->getLevelInfo(level);
|
|
|
|
assert(levelInfo.battleEffects.isNull());
|
|
|
|
|
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
|
|
|
if(s->isOffensive())
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
//default constructed object should be enough
|
|
|
|
effects->add("directDamage", std::make_shared<effects::Damage>(), level);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<effects::Effect> effect;
|
|
|
|
|
|
|
|
if(!levelInfo.effects.empty())
|
|
|
|
{
|
2023-02-11 17:18:05 +02:00
|
|
|
auto * timed = new effects::Timed();
|
2017-07-20 06:08:49 +02:00
|
|
|
timed->cumulative = false;
|
|
|
|
timed->bonus = levelInfo.effects;
|
|
|
|
effect.reset(timed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!levelInfo.cumulativeEffects.empty())
|
|
|
|
{
|
2023-02-11 17:18:05 +02:00
|
|
|
auto * timed = new effects::Timed();
|
2017-07-20 06:08:49 +02:00
|
|
|
timed->cumulative = true;
|
|
|
|
timed->bonus = levelInfo.cumulativeEffects;
|
|
|
|
effect.reset(timed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(effect)
|
|
|
|
effects->add("timed", effect, level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-11 17:18:05 +02:00
|
|
|
BattleCast::BattleCast(const CBattleInfoCallback * cb_, const Caster * caster_, const Mode mode_, const CSpell * spell_):
|
|
|
|
spell(spell_),
|
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
|
|
|
cb(cb_),
|
2023-02-11 17:18:05 +02:00
|
|
|
gameCb(IObjectInterface::cb), //FIXME: pass player callback (problem is that BattleAI do not have one)
|
2017-07-20 06:08:49 +02:00
|
|
|
caster(caster_),
|
|
|
|
mode(mode_),
|
2018-02-10 06:31:02 +02:00
|
|
|
smart(boost::logic::indeterminate),
|
|
|
|
massive(boost::logic::indeterminate)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BattleCast::BattleCast(const BattleCast & orig, const Caster * caster_)
|
|
|
|
: spell(orig.spell),
|
|
|
|
cb(orig.cb),
|
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
|
|
|
gameCb(orig.gameCb),
|
2017-07-20 06:08:49 +02:00
|
|
|
caster(caster_),
|
|
|
|
mode(Mode::MAGIC_MIRROR),
|
2018-03-02 12:22:51 +02:00
|
|
|
magicSkillLevel(orig.magicSkillLevel),
|
2017-07-20 06:08:49 +02:00
|
|
|
effectPower(orig.effectPower),
|
|
|
|
effectDuration(orig.effectDuration),
|
2018-02-10 06:31:02 +02:00
|
|
|
effectValue(orig.effectValue),
|
|
|
|
smart(true),
|
|
|
|
massive(false)
|
2015-09-29 20:47:04 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
2016-02-15 12:34:37 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
BattleCast::~BattleCast() = default;
|
|
|
|
|
|
|
|
const CSpell * BattleCast::getSpell() const
|
|
|
|
{
|
|
|
|
return spell;
|
2015-09-29 20:47:04 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
Mode BattleCast::getMode() const
|
2015-09-29 20:47:04 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
return mode;
|
|
|
|
}
|
2016-02-15 12:34:37 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
const Caster * BattleCast::getCaster() const
|
|
|
|
{
|
|
|
|
return caster;
|
2015-09-29 20:47:04 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
const CBattleInfoCallback * BattleCast::getBattle() const
|
2015-09-16 09:50:33 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
return cb;
|
|
|
|
}
|
2016-09-06 12:33:11 +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 IGameInfoCallback * BattleCast::getGame() const
|
|
|
|
{
|
|
|
|
return gameCb;
|
|
|
|
}
|
|
|
|
|
2018-03-02 12:22:51 +02:00
|
|
|
BattleCast::OptionalValue BattleCast::getSpellLevel() const
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2018-03-02 12:22:51 +02:00
|
|
|
return magicSkillLevel;
|
2015-09-16 09:50:33 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
BattleCast::OptionalValue BattleCast::getEffectPower() const
|
2016-09-06 12:51:53 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
return effectPower;
|
2016-09-06 12:51:53 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
BattleCast::OptionalValue BattleCast::getEffectDuration() const
|
2015-09-29 20:47:04 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
return effectDuration;
|
2015-09-29 20:47:04 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
BattleCast::OptionalValue64 BattleCast::getEffectValue() const
|
|
|
|
{
|
|
|
|
return effectValue;
|
|
|
|
}
|
|
|
|
|
2018-02-10 06:31:02 +02:00
|
|
|
boost::logic::tribool BattleCast::isSmart() const
|
|
|
|
{
|
|
|
|
return smart;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::logic::tribool BattleCast::isMassive() const
|
|
|
|
{
|
|
|
|
return massive;
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void BattleCast::setSpellLevel(BattleCast::Value value)
|
|
|
|
{
|
2023-04-16 19:42:56 +02:00
|
|
|
magicSkillLevel = std::make_optional(value);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleCast::setEffectPower(BattleCast::Value value)
|
|
|
|
{
|
2023-04-16 19:42:56 +02:00
|
|
|
effectPower = std::make_optional(value);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleCast::setEffectDuration(BattleCast::Value value)
|
|
|
|
{
|
2023-04-16 19:42:56 +02:00
|
|
|
effectDuration = std::make_optional(value);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleCast::setEffectValue(BattleCast::Value64 value)
|
|
|
|
{
|
2023-04-16 19:42:56 +02:00
|
|
|
effectValue = std::make_optional(value);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2023-02-11 17:18:05 +02:00
|
|
|
void BattleCast::applyEffects(ServerCallback * server, const Target & target, bool indirect, bool ignoreImmunity) const
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
auto m = spell->battleMechanics(this);
|
|
|
|
|
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
|
|
|
m->applyEffects(server, target, indirect, ignoreImmunity);
|
2015-09-29 20:47:04 +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
|
|
|
void BattleCast::cast(ServerCallback * server, Target target)
|
2015-09-29 20:47:04 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
if(target.empty())
|
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
|
|
|
target.emplace_back();
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
auto m = spell->battleMechanics(this);
|
|
|
|
|
|
|
|
const battle::Unit * mainTarget = nullptr;
|
|
|
|
|
|
|
|
if(target.front().unitValue)
|
|
|
|
{
|
|
|
|
mainTarget = target.front().unitValue;
|
|
|
|
}
|
|
|
|
else if(target.front().hexValue.isValid())
|
|
|
|
{
|
|
|
|
mainTarget = cb->battleGetUnitByPos(target.front().hexValue, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool tryMagicMirror = (mainTarget != nullptr) && (mode == Mode::HERO || mode == Mode::CREATURE_ACTIVE);//TODO: recheck
|
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
|
|
|
tryMagicMirror = tryMagicMirror && (mainTarget->unitOwner() != caster->getCasterOwner()) && !spell->isPositive();//TODO: recheck
|
2017-07-20 06:08:49 +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
|
|
|
m->cast(server, target);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
//Magic Mirror effect
|
|
|
|
if(tryMagicMirror)
|
|
|
|
{
|
|
|
|
const std::string magicMirrorCacheStr = "type_MAGIC_MIRROR";
|
2023-05-01 00:20:01 +02:00
|
|
|
static const auto magicMirrorSelector = Selector::type()(BonusType::MAGIC_MIRROR);
|
2017-07-20 06:08:49 +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
|
|
|
auto rangeGen = server->getRNG()->getInt64Range(0, 99);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
const int mirrorChance = mainTarget->valOfBonuses(magicMirrorSelector, magicMirrorCacheStr);
|
|
|
|
|
|
|
|
if(rangeGen() < mirrorChance)
|
|
|
|
{
|
|
|
|
auto mirrorTargets = cb->battleGetUnitsIf([this](const battle::Unit * unit)
|
|
|
|
{
|
|
|
|
//Get all caster stacks. Magic mirror can reflect to immune creature (with no effect)
|
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
|
|
|
return unit->unitOwner() == caster->getCasterOwner() && unit->isValidTarget(true);
|
2017-07-20 06:08:49 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if(!mirrorTargets.empty())
|
|
|
|
{
|
2023-02-11 17:18:05 +02:00
|
|
|
const auto * mirrorDestination = (*RandomGeneratorUtil::nextItem(mirrorTargets, *server->getRNG()));
|
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
|
|
|
|
|
|
|
Target mirrorTarget;
|
2021-02-20 01:31:00 +02:00
|
|
|
mirrorTarget.emplace_back(mirrorDestination);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
BattleCast mirror(*this, mainTarget);
|
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
|
|
|
mirror.cast(server, mirrorTarget);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-29 20:47:04 +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
|
|
|
void BattleCast::castEval(ServerCallback * server, Target target)
|
2017-03-18 13:08:02 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
//TODO: make equivalent to normal cast
|
|
|
|
if(target.empty())
|
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
|
|
|
target.emplace_back();
|
2017-07-20 06:08:49 +02:00
|
|
|
auto m = spell->battleMechanics(this);
|
|
|
|
|
|
|
|
//TODO: reflection
|
|
|
|
//TODO: random effects evaluation
|
|
|
|
|
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
|
|
|
m->castEval(server, target);
|
2017-07-20 06:08:49 +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
|
|
|
bool BattleCast::castIfPossible(ServerCallback * server, Target target)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
if(spell->canBeCast(cb, mode, caster))
|
2017-06-05 20:41:27 +02:00
|
|
|
{
|
2023-02-11 17:18:05 +02:00
|
|
|
cast(server, std::move(target));
|
2017-06-05 20:41:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-03-18 13:08:02 +02:00
|
|
|
}
|
|
|
|
|
2023-08-08 17:38:41 +02:00
|
|
|
std::vector<Target> BattleCast::findPotentialTargets(bool fast) const
|
2015-09-17 07:42:30 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
//TODO: for more than 2 destinations per target much more efficient algorithm is required
|
|
|
|
|
|
|
|
auto m = spell->battleMechanics(this);
|
|
|
|
|
|
|
|
auto targetTypes = m->getTargetTypes();
|
|
|
|
|
|
|
|
|
|
|
|
if(targetTypes.empty() || targetTypes.size() > 2)
|
2017-03-18 13:08:02 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
return std::vector<Target>();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<Target> previous;
|
|
|
|
std::vector<Target> next;
|
|
|
|
|
|
|
|
for(size_t index = 0; index < targetTypes.size(); index++)
|
|
|
|
{
|
|
|
|
std::swap(previous, next);
|
|
|
|
next.clear();
|
|
|
|
|
|
|
|
std::vector<Destination> destinations;
|
|
|
|
|
|
|
|
if(previous.empty())
|
|
|
|
{
|
|
|
|
Target empty;
|
2023-08-08 17:38:41 +02:00
|
|
|
destinations = m->getPossibleDestinations(index, targetTypes.at(index), empty, fast);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
for(auto & destination : destinations)
|
|
|
|
{
|
|
|
|
Target target;
|
|
|
|
target.emplace_back(destination);
|
|
|
|
next.push_back(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(const Target & current : previous)
|
|
|
|
{
|
2023-08-08 17:38:41 +02:00
|
|
|
destinations = m->getPossibleDestinations(index, targetTypes.at(index), current, fast);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
for(auto & destination : destinations)
|
|
|
|
{
|
|
|
|
Target target = current;
|
|
|
|
target.emplace_back(destination);
|
|
|
|
next.push_back(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(next.empty())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return next;
|
2017-03-18 13:08:02 +02:00
|
|
|
}
|
2015-09-17 07:42:30 +02:00
|
|
|
}
|
2015-09-16 09:50:33 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
///ISpellMechanicsFactory
|
|
|
|
ISpellMechanicsFactory::ISpellMechanicsFactory(const CSpell * s)
|
|
|
|
: spell(s)
|
2016-09-18 14:27:22 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2016-09-18 14:27:22 +02:00
|
|
|
}
|
|
|
|
|
2023-02-11 17:18:05 +02:00
|
|
|
//must be instantiated in .cpp file for access to complete types of all member fields
|
|
|
|
ISpellMechanicsFactory::~ISpellMechanicsFactory() = default;
|
2014-11-13 06:34:20 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::unique_ptr<ISpellMechanicsFactory> ISpellMechanicsFactory::get(const CSpell * s)
|
2014-11-25 13:58:42 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
if(s->hasBattleEffects())
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<ConfigurableMechanicsFactory>(s);
|
2017-07-20 06:08:49 +02:00
|
|
|
else
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<FallbackMechanicsFactory>(s);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
///Mechanics
|
|
|
|
Mechanics::Mechanics()
|
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
|
|
|
: caster(nullptr),
|
2017-07-20 06:08:49 +02:00
|
|
|
casterSide(0)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Mechanics::~Mechanics() = default;
|
|
|
|
|
2023-02-11 17:18:05 +02:00
|
|
|
BaseMechanics::BaseMechanics(const IBattleCast * event):
|
2017-07-20 06:08:49 +02:00
|
|
|
owner(event->getSpell()),
|
2018-02-10 06:31:02 +02:00
|
|
|
mode(event->getMode()),
|
|
|
|
smart(event->isSmart()),
|
2023-02-11 17:18:05 +02:00
|
|
|
massive(event->isMassive()),
|
|
|
|
cb(event->getBattle()),
|
|
|
|
gameCb(event->getGame())
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
caster = event->getCaster();
|
|
|
|
|
2018-03-04 10:13:07 +02:00
|
|
|
//FIXME: do not crash on invalid side
|
2023-04-16 19:42:56 +02:00
|
|
|
casterSide = cb->playerToSide(caster->getCasterOwner()).value();
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2014-11-25 13:58:42 +02:00
|
|
|
{
|
2018-03-02 12:22:51 +02:00
|
|
|
auto value = event->getSpellLevel();
|
2023-04-16 19:42:56 +02:00
|
|
|
rangeLevel = value.value_or(caster->getSpellSchoolLevel(owner));
|
2017-07-20 06:08:49 +02:00
|
|
|
vstd::abetween(rangeLevel, 0, 3);
|
|
|
|
}
|
|
|
|
{
|
2018-03-02 12:22:51 +02:00
|
|
|
auto value = event->getSpellLevel();
|
2023-04-16 19:42:56 +02:00
|
|
|
effectLevel = value.value_or(caster->getEffectLevel(owner));
|
2017-07-20 06:08:49 +02:00
|
|
|
vstd::abetween(effectLevel, 0, 3);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto value = event->getEffectPower();
|
2023-04-16 19:42:56 +02:00
|
|
|
effectPower = value.value_or(caster->getEffectPower(owner));
|
2017-07-20 06:08:49 +02:00
|
|
|
vstd::amax(effectPower, 0);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto value = event->getEffectDuration();
|
2023-04-16 19:42:56 +02:00
|
|
|
effectDuration = value.value_or(caster->getEnchantPower(owner));
|
2017-07-20 06:08:49 +02:00
|
|
|
vstd::amax(effectDuration, 0); //???
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto value = event->getEffectValue();
|
2023-04-16 19:42:56 +02:00
|
|
|
auto casterValue = caster->getEffectValue(owner) ? caster->getEffectValue(owner) : owner->calculateRawEffectValue(effectLevel, effectPower, 1);
|
|
|
|
effectValue = value.value_or(casterValue);
|
2017-07-20 06:08:49 +02:00
|
|
|
vstd::amax(effectValue, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseMechanics::~BaseMechanics() = default;
|
|
|
|
|
|
|
|
bool BaseMechanics::adaptGenericProblem(Problem & target) const
|
|
|
|
{
|
|
|
|
MetaString text;
|
|
|
|
// %s recites the incantations but they seem to have no effect.
|
2023-06-18 11:18:25 +02:00
|
|
|
text.appendLocalString(EMetaText::GENERAL_TXT, 541);
|
2022-09-24 16:30:00 +02:00
|
|
|
assert(caster);
|
2017-07-20 06:08:49 +02:00
|
|
|
caster->getCasterName(text);
|
|
|
|
|
|
|
|
target.add(std::move(text), spells::Problem::NORMAL);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::adaptProblem(ESpellCastProblem::ESpellCastProblem source, Problem & target) const
|
|
|
|
{
|
|
|
|
if(source == ESpellCastProblem::OK)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
switch(source)
|
|
|
|
{
|
|
|
|
case ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED:
|
|
|
|
{
|
|
|
|
MetaString text;
|
|
|
|
//TODO: refactor
|
2023-02-11 17:18:05 +02:00
|
|
|
const auto * hero = dynamic_cast<const CGHeroInstance *>(caster);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(!hero)
|
|
|
|
return adaptGenericProblem(target);
|
|
|
|
|
|
|
|
//Recanter's Cloak or similar effect. Try to retrieve bonus
|
2023-05-01 00:20:01 +02:00
|
|
|
const auto b = hero->getBonusLocalFirst(Selector::type()(BonusType::BLOCK_MAGIC_ABOVE));
|
2017-07-20 06:08:49 +02:00
|
|
|
//TODO what about other values and non-artifact sources?
|
2023-05-01 00:20:01 +02:00
|
|
|
if(b && b->val == 2 && b->source == BonusSource::ARTIFACT)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
//The %s prevents %s from casting 3rd level or higher spells.
|
2023-06-18 11:18:25 +02:00
|
|
|
text.appendLocalString(EMetaText::GENERAL_TXT, 536);
|
|
|
|
text.replaceLocalString(EMetaText::ART_NAMES, b->sid);
|
2017-07-20 06:08:49 +02:00
|
|
|
caster->getCasterName(text);
|
|
|
|
target.add(std::move(text), spells::Problem::NORMAL);
|
|
|
|
}
|
2023-05-01 00:20:01 +02:00
|
|
|
else if(b && b->source == BonusSource::TERRAIN_OVERLAY && VLC->battlefields()->getByIndex(b->sid)->identifier == "cursed_ground")
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
text.appendLocalString(EMetaText::GENERAL_TXT, 537);
|
2017-07-20 06:08:49 +02:00
|
|
|
target.add(std::move(text), spells::Problem::NORMAL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return adaptGenericProblem(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ESpellCastProblem::WRONG_SPELL_TARGET:
|
|
|
|
case ESpellCastProblem::STACK_IMMUNE_TO_SPELL:
|
|
|
|
case ESpellCastProblem::NO_APPROPRIATE_TARGET:
|
|
|
|
{
|
|
|
|
MetaString text;
|
2023-06-18 11:18:25 +02:00
|
|
|
text.appendLocalString(EMetaText::GENERAL_TXT, 185);
|
2017-07-20 06:08:49 +02:00
|
|
|
target.add(std::move(text), spells::Problem::NORMAL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ESpellCastProblem::INVALID:
|
|
|
|
{
|
|
|
|
MetaString text;
|
2023-06-18 11:18:25 +02:00
|
|
|
text.appendRawString("Internal error during check of spell cast.");
|
2017-07-20 06:08:49 +02:00
|
|
|
target.add(std::move(text), spells::Problem::CRITICAL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return adaptGenericProblem(target);
|
2016-09-04 07:19:28 +02:00
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t BaseMechanics::getSpellIndex() const
|
|
|
|
{
|
|
|
|
return getSpellId().toEnum();
|
2016-09-04 07:19:28 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
SpellID BaseMechanics::getSpellId() const
|
|
|
|
{
|
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
|
|
|
return owner->getId();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string BaseMechanics::getSpellName() const
|
|
|
|
{
|
2023-01-18 23:56:01 +02:00
|
|
|
return owner->getNameTranslated();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t BaseMechanics::getSpellLevel() const
|
|
|
|
{
|
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
|
|
|
return owner->getLevel();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::isSmart() const
|
|
|
|
{
|
2018-02-10 06:31:02 +02:00
|
|
|
if(boost::logic::indeterminate(smart))
|
|
|
|
{
|
|
|
|
const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
|
|
|
|
return targetInfo.smart;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-24 17:09:01 +02:00
|
|
|
return (bool)smart;
|
2018-02-10 06:31:02 +02:00
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::isMassive() const
|
|
|
|
{
|
2018-02-10 06:31:02 +02:00
|
|
|
if(boost::logic::indeterminate(massive))
|
|
|
|
{
|
|
|
|
const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
|
|
|
|
return targetInfo.massive;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-24 17:09:01 +02:00
|
|
|
return (bool)massive;
|
2018-02-10 06:31:02 +02:00
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::requiresClearTiles() const
|
|
|
|
{
|
|
|
|
const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
|
|
|
|
return targetInfo.clearAffected;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::alwaysHitFirstTarget() const
|
|
|
|
{
|
|
|
|
return mode == Mode::SPELL_LIKE_ATTACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::isNegativeSpell() const
|
|
|
|
{
|
|
|
|
return owner->isNegative();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::isPositiveSpell() const
|
|
|
|
{
|
|
|
|
return owner->isPositive();
|
|
|
|
}
|
|
|
|
|
2023-03-21 11:18:31 +02:00
|
|
|
bool BaseMechanics::isMagicalEffect() const
|
|
|
|
{
|
|
|
|
return owner->isMagical();
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
int64_t BaseMechanics::adjustEffectValue(const battle::Unit * target) const
|
|
|
|
{
|
|
|
|
return owner->adjustRawDamage(caster, target, getEffectValue());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int64_t BaseMechanics::applySpellBonus(int64_t value, const battle::Unit * target) const
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
return caster->getSpellBonus(owner, value, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t BaseMechanics::applySpecificSpellBonus(int64_t value) const
|
|
|
|
{
|
|
|
|
return caster->getSpecificSpellBonus(owner, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t BaseMechanics::calculateRawEffectValue(int32_t basePowerMultiplier, int32_t levelPowerMultiplier) const
|
|
|
|
{
|
|
|
|
return owner->calculateRawEffectValue(getEffectLevel(), basePowerMultiplier, levelPowerMultiplier);
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
std::vector<BonusType> BaseMechanics::getElementalImmunity() const
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
std::vector<BonusType> ret;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
owner->forEachSchool([&](const SchoolInfo & cnf, bool & stop)
|
|
|
|
{
|
|
|
|
ret.push_back(cnf.immunityBonus);
|
|
|
|
});
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::ownerMatches(const battle::Unit * unit) const
|
|
|
|
{
|
|
|
|
return ownerMatches(unit, owner->getPositiveness());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseMechanics::ownerMatches(const battle::Unit * unit, const boost::logic::tribool positivness) const
|
|
|
|
{
|
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
|
|
|
return cb->battleMatchOwner(caster->getCasterOwner(), unit, positivness);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IBattleCast::Value BaseMechanics::getEffectLevel() const
|
|
|
|
{
|
|
|
|
return effectLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBattleCast::Value BaseMechanics::getRangeLevel() const
|
|
|
|
{
|
|
|
|
return rangeLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBattleCast::Value BaseMechanics::getEffectPower() const
|
|
|
|
{
|
|
|
|
return effectPower;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBattleCast::Value BaseMechanics::getEffectDuration() const
|
|
|
|
{
|
|
|
|
return effectDuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBattleCast::Value64 BaseMechanics::getEffectValue() const
|
|
|
|
{
|
|
|
|
return effectValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerColor BaseMechanics::getCasterColor() const
|
|
|
|
{
|
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
|
|
|
return caster->getCasterOwner();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<AimType> BaseMechanics::getTargetTypes() const
|
|
|
|
{
|
|
|
|
std::vector<AimType> ret;
|
2022-12-22 23:11:55 +02:00
|
|
|
detail::ProblemImpl ignored;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2022-12-22 23:11:55 +02:00
|
|
|
if(canBeCast(ignored))
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
auto spellTargetType = owner->getTargetType();
|
|
|
|
|
|
|
|
if(isMassive())
|
|
|
|
spellTargetType = AimType::NO_TARGET;
|
|
|
|
else if(spellTargetType == AimType::OBSTACLE)
|
|
|
|
spellTargetType = AimType::LOCATION;
|
|
|
|
|
|
|
|
ret.push_back(spellTargetType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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 CreatureService * BaseMechanics::creatures() const
|
|
|
|
{
|
|
|
|
return VLC->creatures(); //todo: redirect
|
|
|
|
}
|
|
|
|
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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 scripting::Service * BaseMechanics::scripts() const
|
|
|
|
{
|
|
|
|
return VLC->scripts(); //todo: redirect
|
|
|
|
}
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
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 Service * BaseMechanics::spells() const
|
|
|
|
{
|
|
|
|
return VLC->spells(); //todo: redirect
|
|
|
|
}
|
|
|
|
|
|
|
|
const IGameInfoCallback * BaseMechanics::game() const
|
|
|
|
{
|
|
|
|
return gameCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CBattleInfoCallback * BaseMechanics::battle() const
|
|
|
|
{
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
} //namespace spells
|
|
|
|
|
|
|
|
///IAdventureSpellMechanics
|
|
|
|
IAdventureSpellMechanics::IAdventureSpellMechanics(const CSpell * s)
|
|
|
|
: owner(s)
|
2016-09-04 07:19:28 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-06 06:53:51 +02:00
|
|
|
std::unique_ptr<IAdventureSpellMechanics> IAdventureSpellMechanics::createMechanics(const CSpell * s)
|
2016-09-04 07:19:28 +02:00
|
|
|
{
|
|
|
|
switch (s->id)
|
|
|
|
{
|
2014-12-25 23:02:50 +02:00
|
|
|
case SpellID::SUMMON_BOAT:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<SummonBoatMechanics>(s);
|
2015-02-26 19:59:18 +02:00
|
|
|
case SpellID::SCUTTLE_BOAT:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<ScuttleBoatMechanics>(s);
|
2014-12-25 23:02:50 +02:00
|
|
|
case SpellID::DIMENSION_DOOR:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<DimensionDoorMechanics>(s);
|
2014-12-25 23:02:50 +02:00
|
|
|
case SpellID::FLY:
|
|
|
|
case SpellID::WATER_WALK:
|
2015-02-06 14:41:26 +02:00
|
|
|
case SpellID::VISIONS:
|
|
|
|
case SpellID::DISGUISE:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<AdventureSpellMechanics>(s); //implemented using bonus system
|
2014-12-25 23:02:50 +02:00
|
|
|
case SpellID::TOWN_PORTAL:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<TownPortalMechanics>(s);
|
2014-12-25 23:02:50 +02:00
|
|
|
case SpellID::VIEW_EARTH:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<ViewEarthMechanics>(s);
|
2015-02-26 19:59:18 +02:00
|
|
|
case SpellID::VIEW_AIR:
|
2022-12-07 23:36:20 +02:00
|
|
|
return std::make_unique<ViewAirMechanics>(s);
|
2015-02-26 19:59:18 +02:00
|
|
|
default:
|
2022-12-07 23:36:20 +02:00
|
|
|
return s->combat ? std::unique_ptr<IAdventureSpellMechanics>() : std::make_unique<AdventureSpellMechanics>(s);
|
2015-02-26 19:59:18 +02:00
|
|
|
}
|
2014-11-25 13:58:42 +02:00
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|