2015-02-26 19:59:18 +02:00
|
|
|
/*
|
|
|
|
* CSpellHandler.cpp, 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 10:25:26 +02:00
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
#include "CSpellHandler.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "Problem.h"
|
2015-02-02 10:25:26 +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
|
|
|
#include <vcmi/spells/Caster.h>
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
#include "../CGeneralTextHandler.h"
|
|
|
|
#include "../filesystem/Filesystem.h"
|
|
|
|
|
|
|
|
#include "../CModHandler.h"
|
|
|
|
#include "../StringConstants.h"
|
|
|
|
|
2017-06-24 16:42:05 +02:00
|
|
|
#include "../battle/BattleInfo.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
#include "../battle/CBattleInfoCallback.h"
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "../battle/Unit.h"
|
2015-09-17 07:42:30 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
#include "../mapObjects/CGHeroInstance.h" //todo: remove
|
|
|
|
#include "../serializer/CSerializer.h"
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2015-03-10 22:14:58 +02:00
|
|
|
#include "ISpellMechanics.h"
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
namespace SpellConfig
|
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
static const std::string LEVEL_NAMES[] = {"none", "basic", "advanced", "expert"};
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
static const spells::SchoolInfo SCHOOL[4] =
|
|
|
|
{
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
ESpellSchool::AIR,
|
|
|
|
Bonus::AIR_SPELL_DMG_PREMY,
|
|
|
|
Bonus::AIR_IMMUNITY,
|
|
|
|
"air",
|
|
|
|
SecondarySkill::AIR_MAGIC,
|
|
|
|
Bonus::AIR_SPELLS
|
|
|
|
},
|
2016-10-17 02:33:29 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
ESpellSchool::FIRE,
|
|
|
|
Bonus::FIRE_SPELL_DMG_PREMY,
|
|
|
|
Bonus::FIRE_IMMUNITY,
|
|
|
|
"fire",
|
|
|
|
SecondarySkill::FIRE_MAGIC,
|
|
|
|
Bonus::FIRE_SPELLS
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ESpellSchool::WATER,
|
|
|
|
Bonus::WATER_SPELL_DMG_PREMY,
|
|
|
|
Bonus::WATER_IMMUNITY,
|
|
|
|
"water",
|
|
|
|
SecondarySkill::WATER_MAGIC,
|
|
|
|
Bonus::WATER_SPELLS
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ESpellSchool::EARTH,
|
|
|
|
Bonus::EARTH_SPELL_DMG_PREMY,
|
|
|
|
Bonus::EARTH_IMMUNITY,
|
|
|
|
"earth",
|
|
|
|
SecondarySkill::EARTH_MAGIC,
|
|
|
|
Bonus::EARTH_SPELLS
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//order as described in http://bugs.vcmi.eu/view.php?id=91
|
|
|
|
static const ESpellSchool SCHOOL_ORDER[4] =
|
|
|
|
{
|
|
|
|
ESpellSchool::AIR, //=0
|
|
|
|
ESpellSchool::FIRE, //=1
|
|
|
|
ESpellSchool::EARTH,//=3(!)
|
|
|
|
ESpellSchool::WATER //=2(!)
|
|
|
|
};
|
|
|
|
} //namespace SpellConfig
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
///CSpell::LevelInfo
|
|
|
|
CSpell::LevelInfo::LevelInfo()
|
2018-02-10 03:03:17 +02:00
|
|
|
: description(""),
|
|
|
|
cost(0),
|
|
|
|
power(0),
|
|
|
|
AIValue(0),
|
|
|
|
smartTarget(true),
|
|
|
|
clearTarget(false),
|
|
|
|
clearAffected(false),
|
|
|
|
range("0")
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CSpell::LevelInfo::~LevelInfo()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
///CSpell
|
|
|
|
CSpell::CSpell():
|
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
|
|
|
id(SpellID::NONE),
|
|
|
|
level(0),
|
2016-11-27 21:37:41 +02:00
|
|
|
power(0),
|
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
|
|
|
combat(false),
|
|
|
|
creatureAbility(false),
|
2015-02-02 10:25:26 +02:00
|
|
|
positiveness(ESpellPositiveness::NEUTRAL),
|
|
|
|
defaultProbability(0),
|
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
|
|
|
rising(false),
|
|
|
|
damage(false),
|
|
|
|
offensive(false),
|
|
|
|
special(true),
|
2017-07-20 06:08:49 +02:00
|
|
|
targetType(spells::AimType::NO_TARGET),
|
2016-09-04 07:19:28 +02:00
|
|
|
mechanics(),
|
|
|
|
adventureMechanics()
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
levels.resize(GameConstants::SPELL_SCHOOL_LEVELS);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSpell::~CSpell()
|
|
|
|
{
|
2016-09-04 07:19:28 +02:00
|
|
|
|
2015-02-02 10:25:26 +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 CSpell::adventureCast(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
assert(env);
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2016-09-04 07:19:28 +02:00
|
|
|
if(!adventureMechanics.get())
|
|
|
|
{
|
|
|
|
env->complain("Invalid adventure spell cast attempt!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return adventureMechanics->adventureCast(env, parameters);
|
2015-02-02 10:25:26 +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 CSpell::LevelInfo & CSpell::getLevelInfo(const int32_t level) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
if(level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
|
|
|
{
|
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
|
|
|
logGlobal->error("CSpell::getLevelInfo: invalid school level %d", level);
|
|
|
|
return levels.at(0);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return levels.at(level);
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
int64_t CSpell::calculateDamage(const spells::Caster * caster) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
//check if spell really does damage - if not, return 0
|
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(!isDamage())
|
2015-02-02 10:25:26 +02:00
|
|
|
return 0;
|
2017-07-20 06:08:49 +02:00
|
|
|
auto rawDamage = calculateRawEffectValue(caster->getEffectLevel(this), caster->getEffectPower(this), 1);
|
|
|
|
|
|
|
|
return caster->getSpellBonus(this, rawDamage, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::canBeCast(const CBattleInfoCallback * cb, spells::Mode mode, const spells::Caster * caster) const
|
|
|
|
{
|
|
|
|
//if caller do not interested in description just discard it and do not pollute even debug log
|
|
|
|
spells::detail::ProblemImpl problem;
|
|
|
|
return canBeCast(problem, cb, mode, caster);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
bool CSpell::canBeCast(spells::Problem & problem, const CBattleInfoCallback * cb, spells::Mode mode, const spells::Caster * caster) const
|
2015-03-18 15:39:07 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
spells::BattleCast event(cb, caster, mode, this);
|
|
|
|
auto mechanics = battleMechanics(&event);
|
|
|
|
|
|
|
|
return mechanics->canBeCast(problem);
|
2015-03-18 15:39:07 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
spells::AimType CSpell::getTargetType() const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
return targetType;
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void CSpell::forEachSchool(const std::function<void(const spells::SchoolInfo &, bool &)>& cb) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
bool stop = false;
|
2016-10-17 02:33:29 +02:00
|
|
|
for(ESpellSchool iter : SpellConfig::SCHOOL_ORDER)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
const spells::SchoolInfo & cnf = SpellConfig::SCHOOL[(ui8)iter];
|
2015-02-02 10:25:26 +02:00
|
|
|
if(school.at(cnf.id))
|
|
|
|
{
|
|
|
|
cb(cnf, stop);
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
if(stop)
|
|
|
|
break;
|
2015-02-26 19:59:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-02 10:25:26 +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
|
|
|
SpellID CSpell::getId() const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CSpell::getName() const
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CSpell::getJsonKey() const
|
|
|
|
{
|
|
|
|
return identifier;
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
int32_t CSpell::getIndex() const
|
|
|
|
{
|
|
|
|
return id.toEnum();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int32_t CSpell::getIconIndex() const
|
|
|
|
{
|
|
|
|
return getIndex();
|
|
|
|
}
|
|
|
|
|
2018-03-02 12:22:51 +02:00
|
|
|
int32_t CSpell::getLevel() const
|
|
|
|
{
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
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 CSpell::isCombat() const
|
2015-02-02 10:25:26 +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
|
|
|
return combat;
|
2015-02-02 10:25:26 +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 CSpell::isAdventure() const
|
2015-02-02 10:25:26 +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
|
|
|
return !combat;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::isCreatureAbility() const
|
|
|
|
{
|
|
|
|
return creatureAbility;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::isPositive() const
|
|
|
|
{
|
|
|
|
return positiveness == POSITIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::isNegative() const
|
|
|
|
{
|
|
|
|
return positiveness == NEGATIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::isNeutral() const
|
|
|
|
{
|
|
|
|
return positiveness == NEUTRAL;
|
|
|
|
}
|
|
|
|
|
2016-09-29 22:14:22 +02:00
|
|
|
boost::logic::tribool CSpell::getPositiveness() const
|
|
|
|
{
|
|
|
|
switch (positiveness)
|
|
|
|
{
|
|
|
|
case CSpell::POSITIVE:
|
|
|
|
return true;
|
|
|
|
case CSpell::NEGATIVE:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return boost::logic::indeterminate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 CSpell::isDamage() const
|
2015-02-02 10:25:26 +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
|
|
|
return damage;
|
2015-02-02 10:25:26 +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 CSpell::isOffensive() const
|
2015-02-02 10:25:26 +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
|
|
|
return offensive;
|
2015-02-02 10:25:26 +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 CSpell::isSpecial() const
|
2015-02-02 10:25:26 +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
|
|
|
return special;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpell::hasEffects() const
|
|
|
|
{
|
2016-11-02 19:11:01 +02:00
|
|
|
return !levels[0].effects.empty() || !levels[0].cumulativeEffects.empty();
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
bool CSpell::hasBattleEffects() const
|
|
|
|
{
|
|
|
|
return levels[0].battleEffects.getType() == JsonNode::JsonType::DATA_STRUCT && !levels[0].battleEffects.Struct().empty();
|
|
|
|
}
|
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
const std::string & CSpell::getIconImmune() const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
return iconImmune;
|
|
|
|
}
|
|
|
|
|
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 std::string & CSpell::getIconBook() const
|
|
|
|
{
|
|
|
|
return iconBook;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CSpell::getIconEffect() const
|
|
|
|
{
|
|
|
|
return iconEffect;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CSpell::getIconScenarioBonus() const
|
|
|
|
{
|
|
|
|
return iconScenarioBonus;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CSpell::getIconScroll() const
|
|
|
|
{
|
|
|
|
return iconScroll;
|
|
|
|
}
|
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
const std::string & CSpell::getCastSound() const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
return castSound;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int32_t CSpell::getCost(const int32_t skillLevel) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
return getLevelInfo(skillLevel).cost;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int32_t CSpell::getBasePower() const
|
|
|
|
{
|
|
|
|
return power;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CSpell::getLevelPower(const int32_t skillLevel) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
return getLevelInfo(skillLevel).power;
|
|
|
|
}
|
|
|
|
|
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 std::string & CSpell::getLevelDescription(const int32_t skillLevel) const
|
|
|
|
{
|
|
|
|
return getLevelInfo(skillLevel).description;
|
|
|
|
}
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
si32 CSpell::getProbability(const TFaction factionId) const
|
|
|
|
{
|
|
|
|
if(!vstd::contains(probabilities,factionId))
|
|
|
|
{
|
|
|
|
return defaultProbability;
|
|
|
|
}
|
|
|
|
return probabilities.at(factionId);
|
|
|
|
}
|
|
|
|
|
2017-07-15 13:08:20 +02:00
|
|
|
void CSpell::getEffects(std::vector<Bonus> & lst, const int level, const bool cumulative, const si32 duration, boost::optional<si32 *> maxDuration) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
if(level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("invalid school level %d", level);
|
2015-02-02 10:25:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
const auto & levelObject = levels.at(level);
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
if(levelObject.effects.empty() && levelObject.cumulativeEffects.empty())
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("This spell (%s) has no effects for level %d", name, level);
|
2015-02-02 10:25:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
const auto & effects = cumulative ? levelObject.cumulativeEffects : levelObject.effects;
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
lst.reserve(lst.size() + effects.size());
|
|
|
|
|
2022-05-19 14:14:50 +02:00
|
|
|
for(const auto& b : effects)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2016-11-02 19:11:01 +02:00
|
|
|
Bonus nb(*b);
|
|
|
|
|
|
|
|
//use configured duration if present
|
|
|
|
if(nb.turnsRemain == 0)
|
|
|
|
nb.turnsRemain = duration;
|
|
|
|
if(maxDuration)
|
|
|
|
vstd::amax(*(maxDuration.get()), nb.turnsRemain);
|
|
|
|
|
|
|
|
lst.push_back(nb);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Unit * affectedCreature, int64_t rawDamage) const
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
auto ret = rawDamage;
|
2015-09-16 14:43:39 +02:00
|
|
|
//affected creature-specific part
|
|
|
|
if(nullptr != affectedCreature)
|
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
auto bearer = affectedCreature;
|
2015-09-16 14:43:39 +02:00
|
|
|
//applying protections - when spell has more then one elements, only one protection should be applied (I think)
|
2017-07-20 06:08:49 +02:00
|
|
|
forEachSchool([&](const spells::SchoolInfo & cnf, bool & stop)
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
if(bearer->hasBonusOfType(Bonus::SPELL_DAMAGE_REDUCTION, (ui8)cnf.id))
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
ret *= 100 - bearer->valOfBonuses(Bonus::SPELL_DAMAGE_REDUCTION, (ui8)cnf.id);
|
2015-09-16 14:43:39 +02:00
|
|
|
ret /= 100;
|
|
|
|
stop = true;//only bonus from one school is used
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-11-11 21:43:40 +02:00
|
|
|
CSelector selector = Selector::type()(Bonus::SPELL_DAMAGE_REDUCTION).And(Selector::subtype()(-1));
|
2017-08-01 15:59:45 +02:00
|
|
|
|
2015-09-16 14:43:39 +02:00
|
|
|
//general spell dmg reduction
|
2017-07-20 06:08:49 +02:00
|
|
|
if(bearer->hasBonus(selector))
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
ret *= 100 - bearer->valOfBonuses(selector);
|
2015-09-16 14:43:39 +02:00
|
|
|
ret /= 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
//dmg increasing
|
2017-07-20 06:08:49 +02:00
|
|
|
if(bearer->hasBonusOfType(Bonus::MORE_DAMAGE_FROM_SPELL, id))
|
2015-09-16 14:43:39 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
ret *= 100 + bearer->valOfBonuses(Bonus::MORE_DAMAGE_FROM_SPELL, id.toEnum());
|
2015-09-16 14:43:39 +02:00
|
|
|
ret /= 100;
|
|
|
|
}
|
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
ret = caster->getSpellBonus(this, ret, affectedCreature);
|
2015-09-16 14:43:39 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
int64_t CSpell::calculateRawEffectValue(int32_t effectLevel, int32_t basePowerMultiplier, int32_t levelPowerMultiplier) const
|
2015-09-16 14:43:39 +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
|
|
|
return (int64_t)basePowerMultiplier * getBasePower() + levelPowerMultiplier * getLevelPower(effectLevel);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSpell::setIsOffensive(const bool val)
|
|
|
|
{
|
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
|
|
|
offensive = val;
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
if(val)
|
|
|
|
{
|
|
|
|
positiveness = CSpell::NEGATIVE;
|
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
|
|
|
damage = true;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSpell::setIsRising(const bool val)
|
|
|
|
{
|
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
|
|
|
rising = val;
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
if(val)
|
|
|
|
{
|
|
|
|
positiveness = CSpell::POSITIVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
JsonNode CSpell::convertTargetCondition(const BTVector & immunity, const BTVector & absImmunity, const BTVector & limit, const BTVector & absLimit) const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
static const std::string CONDITION_NORMAL = "normal";
|
|
|
|
static const std::string CONDITION_ABSOLUTE = "absolute";
|
|
|
|
|
|
|
|
#define BONUS_NAME(x) { Bonus::x, #x },
|
|
|
|
static const std::map<Bonus::BonusType, std::string> bonusNameRMap = { BONUS_LIST };
|
|
|
|
#undef BONUS_NAME
|
|
|
|
|
|
|
|
JsonNode res;
|
|
|
|
|
|
|
|
auto convertVector = [&](const std::string & targetName, const BTVector & source, const std::string & value)
|
|
|
|
{
|
|
|
|
for(auto bonusType : source)
|
|
|
|
{
|
|
|
|
auto iter = bonusNameRMap.find(bonusType);
|
|
|
|
if(iter != bonusNameRMap.end())
|
|
|
|
{
|
|
|
|
auto fullId = CModHandler::makeFullIdentifier("", "bonus", iter->second);
|
|
|
|
res[targetName][fullId].String() = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logGlobal->error("Invalid bonus type %d", static_cast<int32_t>(bonusType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto convertSection = [&](const std::string & targetName, const BTVector & normal, const BTVector & absolute)
|
|
|
|
{
|
|
|
|
convertVector(targetName, normal, CONDITION_NORMAL);
|
|
|
|
convertVector(targetName, absolute, CONDITION_ABSOLUTE);
|
|
|
|
};
|
|
|
|
|
|
|
|
convertSection("allOf", limit, absLimit);
|
|
|
|
convertSection("noneOf", immunity, absImmunity);
|
|
|
|
|
|
|
|
return res;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSpell::setupMechanics()
|
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
mechanics = spells::ISpellMechanicsFactory::get(this);
|
2016-09-04 07:19:28 +02:00
|
|
|
adventureMechanics = IAdventureSpellMechanics::createMechanics(this);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::unique_ptr<spells::Mechanics> CSpell::battleMechanics(const spells::IBattleCast * event) const
|
|
|
|
{
|
|
|
|
return mechanics->create(event);
|
|
|
|
}
|
|
|
|
|
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 CSpell::registerIcons(const IconRegistar & cb) const
|
|
|
|
{
|
2022-11-29 14:47:51 +02:00
|
|
|
cb(getIndex(), 0, "SPELLS", iconBook);
|
|
|
|
cb(getIndex()+1, 0, "SPELLINT", iconEffect);
|
|
|
|
cb(getIndex(), 0, "SPELLBON", iconScenarioBonus);
|
|
|
|
cb(getIndex(), 0, "SPELLSCR", iconScroll);
|
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 CSpell::updateFrom(const JsonNode & data)
|
|
|
|
{
|
|
|
|
//todo:CSpell::updateFrom
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSpell::serializeJson(JsonSerializeFormat & handler)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-09-12 22:52:04 +02:00
|
|
|
///CSpell::AnimationInfo
|
2022-12-22 00:25:35 +02:00
|
|
|
CSpell::AnimationItem::AnimationItem() :
|
|
|
|
verticalPosition(VerticalPosition::TOP),
|
|
|
|
pause(0)
|
2015-09-12 22:52:04 +02:00
|
|
|
{
|
2016-02-13 18:41:28 +02:00
|
|
|
|
2015-09-12 22:52:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
///CSpell::AnimationInfo
|
|
|
|
CSpell::AnimationInfo::AnimationInfo()
|
|
|
|
{
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CSpell::AnimationInfo::~AnimationInfo()
|
|
|
|
{
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSpell::AnimationInfo::selectProjectile(const double angle) const
|
2015-02-26 19:59:18 +02:00
|
|
|
{
|
|
|
|
std::string res;
|
2015-02-02 10:25:26 +02:00
|
|
|
double maximum = 0.0;
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
for(const auto & info : projectile)
|
|
|
|
{
|
2022-12-01 22:06:42 +02:00
|
|
|
if(info.minimumAngle < angle && info.minimumAngle >= maximum)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
maximum = info.minimumAngle;
|
|
|
|
res = info.resourceName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-04 01:06:02 +02:00
|
|
|
return res;
|
2015-02-26 19:59:18 +02:00
|
|
|
}
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
///CSpell::TargetInfo
|
2017-07-20 06:08:49 +02:00
|
|
|
CSpell::TargetInfo::TargetInfo(const CSpell * spell, const int level, spells::Mode mode)
|
|
|
|
: type(spell->getTargetType()),
|
|
|
|
smart(false),
|
|
|
|
massive(false),
|
|
|
|
clearAffected(false),
|
|
|
|
clearTarget(false)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
auto & levelInfo = spell->getLevelInfo(level);
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
smart = levelInfo.smartTarget;
|
|
|
|
massive = levelInfo.range == "X";
|
|
|
|
clearAffected = levelInfo.clearAffected;
|
|
|
|
clearTarget = levelInfo.clearTarget;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
bool DLL_LINKAGE isInScreenRange(const int3 & center, const int3 & pos)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
int3 diff = pos - center;
|
2019-03-20 21:58:15 +02:00
|
|
|
return diff.x >= -9 && diff.x <= 9 && diff.y >= -8 && diff.y <= 8;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
///CSpellHandler
|
2017-07-20 06:08:49 +02:00
|
|
|
CSpellHandler::CSpellHandler() = default;
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
CSpellHandler::~CSpellHandler() = default;
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
std::vector<JsonNode> CSpellHandler::loadLegacyData(size_t dataSize)
|
|
|
|
{
|
|
|
|
using namespace SpellConfig;
|
|
|
|
std::vector<JsonNode> legacyData;
|
|
|
|
|
|
|
|
CLegacyConfigParser parser("DATA/SPTRAITS.TXT");
|
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
auto readSchool = [&](JsonMap & schools, const std::string & name)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
if (parser.readString() == "x")
|
|
|
|
{
|
|
|
|
schools[name].Bool() = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-19 12:52:02 +02:00
|
|
|
auto read = [&](bool combat, bool ability)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2017-11-26 23:18:18 +02:00
|
|
|
JsonNode lineNode(JsonNode::JsonType::DATA_STRUCT);
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
const auto id = legacyData.size();
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
lineNode["index"].Integer() = id;
|
2015-02-02 10:25:26 +02:00
|
|
|
lineNode["type"].String() = ability ? "ability" : (combat ? "combat" : "adventure");
|
|
|
|
|
|
|
|
lineNode["name"].String() = parser.readString();
|
|
|
|
|
|
|
|
parser.readString(); //ignored unused abbreviated name
|
2020-10-01 10:38:06 +02:00
|
|
|
lineNode["level"].Integer() = static_cast<si64>(parser.readNumber());
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
auto& schools = lineNode["school"].Struct();
|
|
|
|
|
|
|
|
readSchool(schools, "earth");
|
|
|
|
readSchool(schools, "water");
|
|
|
|
readSchool(schools, "fire");
|
|
|
|
readSchool(schools, "air");
|
|
|
|
|
|
|
|
auto& levels = lineNode["levels"].Struct();
|
|
|
|
|
|
|
|
auto getLevel = [&](const size_t idx)->JsonMap&
|
|
|
|
{
|
|
|
|
assert(idx < GameConstants::SPELL_SCHOOL_LEVELS);
|
|
|
|
return levels[LEVEL_NAMES[idx]].Struct();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto costs = parser.readNumArray<si32>(GameConstants::SPELL_SCHOOL_LEVELS);
|
2020-10-01 10:38:06 +02:00
|
|
|
lineNode["power"].Integer() = static_cast<si64>(parser.readNumber());
|
2015-02-02 10:25:26 +02:00
|
|
|
auto powers = parser.readNumArray<si32>(GameConstants::SPELL_SCHOOL_LEVELS);
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
auto & chances = lineNode["gainChance"].Struct();
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
for(size_t i = 0; i < GameConstants::F_NUMBER; i++)
|
2020-10-01 10:38:06 +02:00
|
|
|
chances[ETownType::names[i]].Integer() = static_cast<si64>(parser.readNumber());
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
auto AIVals = parser.readNumArray<si32>(GameConstants::SPELL_SCHOOL_LEVELS);
|
|
|
|
|
|
|
|
std::vector<std::string> descriptions;
|
2015-02-26 19:59:18 +02:00
|
|
|
for(size_t i = 0; i < GameConstants::SPELL_SCHOOL_LEVELS; i++)
|
2015-02-02 10:25:26 +02:00
|
|
|
descriptions.push_back(parser.readString());
|
|
|
|
|
|
|
|
parser.readString(); //ignore attributes. All data present in JSON
|
|
|
|
|
|
|
|
//save parsed level specific data
|
|
|
|
for(size_t i = 0; i < GameConstants::SPELL_SCHOOL_LEVELS; i++)
|
|
|
|
{
|
|
|
|
auto& level = getLevel(i);
|
|
|
|
level["description"].String() = descriptions[i];
|
2017-07-20 06:08:49 +02:00
|
|
|
level["cost"].Integer() = costs[i];
|
|
|
|
level["power"].Integer() = powers[i];
|
|
|
|
level["aiValue"].Integer() = AIVals[i];
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
legacyData.push_back(lineNode);
|
|
|
|
}
|
|
|
|
while (parser.endLine() && !parser.isNextEntryEmpty());
|
|
|
|
};
|
|
|
|
|
|
|
|
auto skip = [&](int cnt)
|
|
|
|
{
|
|
|
|
for(int i=0; i<cnt; i++)
|
|
|
|
parser.endLine();
|
|
|
|
};
|
|
|
|
|
|
|
|
skip(5);// header
|
|
|
|
read(false,false); //read adventure map spells
|
|
|
|
skip(3);
|
|
|
|
read(true,false); //read battle spells
|
|
|
|
skip(3);
|
|
|
|
read(true,true);//read creature abilities
|
|
|
|
|
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
|
|
|
//TODO: maybe move to config
|
2015-02-02 10:25:26 +02:00
|
|
|
//clone Acid Breath attributes for Acid Breath damage effect
|
|
|
|
JsonNode temp = legacyData[SpellID::ACID_BREATH_DEFENSE];
|
2017-07-20 06:08:49 +02:00
|
|
|
temp["index"].Integer() = SpellID::ACID_BREATH_DAMAGE;
|
2015-02-02 10:25:26 +02:00
|
|
|
legacyData.push_back(temp);
|
|
|
|
|
|
|
|
objects.resize(legacyData.size());
|
|
|
|
|
|
|
|
return legacyData;
|
|
|
|
}
|
|
|
|
|
2018-03-31 07:56:40 +02:00
|
|
|
const std::vector<std::string> & CSpellHandler::getTypeNames() const
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2018-03-31 07:56:40 +02:00
|
|
|
static const std::vector<std::string> typeNames = { "spell" };
|
|
|
|
return typeNames;
|
2015-02-02 10:25:26 +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
|
|
|
CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
using namespace SpellConfig;
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
SpellID id(static_cast<si32>(index));
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
CSpell * spell = new CSpell();
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->id = id;
|
2016-02-13 18:41:28 +02:00
|
|
|
spell->identifier = identifier;
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
const auto type = json["type"].String();
|
|
|
|
|
|
|
|
if(type == "ability")
|
|
|
|
{
|
|
|
|
spell->creatureAbility = true;
|
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
|
|
|
spell->combat = true;
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spell->creatureAbility = false;
|
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
|
|
|
spell->combat = type == "combat";
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
spell->name = json["name"].String();
|
|
|
|
|
2017-08-30 23:23:19 +02:00
|
|
|
logMod->trace("%s: loading spell %s", __FUNCTION__, spell->name);
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
const auto schoolNames = json["school"];
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const spells::SchoolInfo & info : SpellConfig::SCHOOL)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
spell->school[info.id] = schoolNames[info.jsonName].Bool();
|
|
|
|
}
|
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
spell->level = static_cast<si32>(json["level"].Integer());
|
|
|
|
spell->power = static_cast<si32>(json["power"].Integer());
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
spell->defaultProbability = static_cast<si32>(json["defaultGainChance"].Integer());
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
for(const auto & node : json["gainChance"].Struct())
|
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
const int chance = static_cast<int>(node.second.Integer());
|
2015-02-02 10:25:26 +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
|
|
|
VLC->modh->identifiers.requestIdentifier(node.second.meta, "faction", node.first, [=](si32 factionID)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
spell->probabilities[factionID] = chance;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
auto targetType = json["targetType"].String();
|
|
|
|
|
|
|
|
if(targetType == "NO_TARGET")
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->targetType = spells::AimType::NO_TARGET;
|
2015-02-02 10:25:26 +02:00
|
|
|
else if(targetType == "CREATURE")
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->targetType = spells::AimType::CREATURE;
|
2015-02-02 10:25:26 +02:00
|
|
|
else if(targetType == "OBSTACLE")
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->targetType = spells::AimType::OBSTACLE;
|
2015-02-02 10:25:26 +02:00
|
|
|
else if(targetType == "LOCATION")
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->targetType = spells::AimType::LOCATION;
|
2015-02-26 19:59:18 +02:00
|
|
|
else
|
2017-08-30 23:23:19 +02:00
|
|
|
logMod->warn("Spell %s: target type %s - assumed NO_TARGET.", spell->name, (targetType.empty() ? "empty" : "unknown ("+targetType+")"));
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
for(const auto & counteredSpell: json["counters"].Struct())
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
if(counteredSpell.second.Bool())
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2022-12-21 12:58:40 +02:00
|
|
|
VLC->modh->identifiers.requestIdentifier(counteredSpell.second.meta, counteredSpell.first, [=](si32 id)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
spell->counteredSpells.push_back(SpellID(id));
|
|
|
|
});
|
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
//TODO: more error checking - f.e. conflicting flags
|
|
|
|
const auto flags = json["flags"];
|
|
|
|
|
|
|
|
//by default all flags are set to false in constructor
|
|
|
|
|
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
|
|
|
spell->damage = flags["damage"].Bool(); //do this before "offensive"
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
if(flags["offensive"].Bool())
|
|
|
|
{
|
|
|
|
spell->setIsOffensive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flags["rising"].Bool())
|
|
|
|
{
|
|
|
|
spell->setIsRising(true);
|
|
|
|
}
|
|
|
|
|
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 bool implicitPositiveness = spell->offensive || spell->rising; //(!) "damage" does not mean NEGATIVE --AVS
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
if(flags["indifferent"].Bool())
|
|
|
|
{
|
|
|
|
spell->positiveness = CSpell::NEUTRAL;
|
|
|
|
}
|
|
|
|
else if(flags["negative"].Bool())
|
|
|
|
{
|
|
|
|
spell->positiveness = CSpell::NEGATIVE;
|
|
|
|
}
|
|
|
|
else if(flags["positive"].Bool())
|
|
|
|
{
|
|
|
|
spell->positiveness = CSpell::POSITIVE;
|
|
|
|
}
|
|
|
|
else if(!implicitPositiveness)
|
|
|
|
{
|
|
|
|
spell->positiveness = CSpell::NEUTRAL; //duplicates constructor but, just in case
|
2017-08-30 23:23:19 +02:00
|
|
|
logMod->error("Spell %s: no positiveness specified, assumed NEUTRAL.", spell->name);
|
2015-02-02 10:25:26 +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
|
|
|
spell->special = flags["special"].Bool();
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
auto findBonus = [&](std::string name, std::vector<Bonus::BonusType> & vec)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
auto it = bonusNameMap.find(name);
|
|
|
|
if(it == bonusNameMap.end())
|
|
|
|
{
|
2017-08-30 23:23:19 +02:00
|
|
|
logMod->error("Spell %s: invalid bonus name %s", spell->name, name);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vec.push_back((Bonus::BonusType)it->second);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
auto readBonusStruct = [&](std::string name, std::vector<Bonus::BonusType> & vec)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
for(auto bonusData: json[name].Struct())
|
|
|
|
{
|
|
|
|
const std::string bonusId = bonusData.first;
|
|
|
|
const bool flag = bonusData.second.Bool();
|
|
|
|
|
|
|
|
if(flag)
|
|
|
|
findBonus(bonusId, vec);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
if(json["targetCondition"].isNull())
|
|
|
|
{
|
|
|
|
CSpell::BTVector immunities;
|
|
|
|
CSpell::BTVector absoluteImmunities;
|
|
|
|
CSpell::BTVector limiters;
|
|
|
|
CSpell::BTVector absoluteLimiters;
|
|
|
|
|
|
|
|
readBonusStruct("immunity", immunities);
|
|
|
|
readBonusStruct("absoluteImmunity", absoluteImmunities);
|
|
|
|
readBonusStruct("limit", limiters);
|
|
|
|
readBonusStruct("absoluteLimit", absoluteLimiters);
|
|
|
|
|
|
|
|
if(!(immunities.empty() && absoluteImmunities.empty() && limiters.empty() && absoluteLimiters.empty()))
|
|
|
|
{
|
|
|
|
logMod->warn("Spell %s has old target condition format. Expected configuration: ", spell->name);
|
|
|
|
spell->targetCondition = spell->convertTargetCondition(immunities, absoluteImmunities, limiters, absoluteLimiters);
|
|
|
|
logMod->warn("\n\"targetCondition\" : %s", spell->targetCondition.toJson());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spell->targetCondition = json["targetCondition"];
|
|
|
|
|
|
|
|
//TODO: could this be safely merged instead of discarding?
|
|
|
|
if(!json["immunity"].isNull())
|
|
|
|
logMod->warn("Spell %s 'immunity' field mixed with 'targetCondition' discarded", spell->name);
|
|
|
|
if(!json["absoluteImmunity"].isNull())
|
|
|
|
logMod->warn("Spell %s 'absoluteImmunity' field mixed with 'targetCondition' discarded", spell->name);
|
|
|
|
if(!json["limit"].isNull())
|
|
|
|
logMod->warn("Spell %s 'limit' field mixed with 'targetCondition' discarded", spell->name);
|
|
|
|
if(!json["absoluteLimit"].isNull())
|
|
|
|
logMod->warn("Spell %s 'absoluteLimit' field mixed with 'targetCondition' discarded", spell->name);
|
|
|
|
}
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
const JsonNode & graphicsNode = json["graphics"];
|
|
|
|
|
|
|
|
spell->iconImmune = graphicsNode["iconImmune"].String();
|
|
|
|
spell->iconBook = graphicsNode["iconBook"].String();
|
|
|
|
spell->iconEffect = graphicsNode["iconEffect"].String();
|
|
|
|
spell->iconScenarioBonus = graphicsNode["iconScenarioBonus"].String();
|
|
|
|
spell->iconScroll = graphicsNode["iconScroll"].String();
|
|
|
|
|
|
|
|
const JsonNode & animationNode = json["animation"];
|
2015-02-26 19:59:18 +02:00
|
|
|
|
|
|
|
auto loadAnimationQueue = [&](const std::string & jsonName, CSpell::TAnimationQueue & q)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2015-02-26 19:59:18 +02:00
|
|
|
auto queueNode = animationNode[jsonName].Vector();
|
2015-02-02 10:25:26 +02:00
|
|
|
for(const JsonNode & item : queueNode)
|
2015-02-26 19:59:18 +02:00
|
|
|
{
|
2015-02-02 10:25:26 +02:00
|
|
|
CSpell::TAnimation newItem;
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2017-11-26 23:18:18 +02:00
|
|
|
if(item.getType() == JsonNode::JsonType::DATA_STRING)
|
2015-02-02 10:25:26 +02:00
|
|
|
newItem.resourceName = item.String();
|
2017-11-26 23:18:18 +02:00
|
|
|
else if(item.getType() == JsonNode::JsonType::DATA_STRUCT)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
|
|
|
newItem.resourceName = item["defName"].String();
|
2022-12-22 00:25:35 +02:00
|
|
|
newItem.effectName = item["effectName"].String();
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
auto vPosStr = item["verticalPosition"].String();
|
|
|
|
if("bottom" == vPosStr)
|
|
|
|
newItem.verticalPosition = VerticalPosition::BOTTOM;
|
2015-02-26 19:59:18 +02:00
|
|
|
}
|
2016-11-13 12:38:42 +02:00
|
|
|
else if(item.isNumber())
|
2015-03-22 12:49:14 +02:00
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
newItem.pause = static_cast<int>(item.Float());
|
2015-03-22 12:49:14 +02:00
|
|
|
}
|
2016-02-13 18:41:28 +02:00
|
|
|
|
2015-02-26 19:59:18 +02:00
|
|
|
q.push_back(newItem);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
};
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
loadAnimationQueue("affect", spell->animationInfo.affect);
|
|
|
|
loadAnimationQueue("cast", spell->animationInfo.cast);
|
2015-02-26 19:59:18 +02:00
|
|
|
loadAnimationQueue("hit", spell->animationInfo.hit);
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
const JsonVector & projectile = animationNode["projectile"].Vector();
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
for(const JsonNode & item : projectile)
|
|
|
|
{
|
|
|
|
CSpell::ProjectileInfo info;
|
|
|
|
info.resourceName = item["defName"].String();
|
|
|
|
info.minimumAngle = item["minimumAngle"].Float();
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
spell->animationInfo.projectile.push_back(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
const JsonNode & soundsNode = json["sounds"];
|
|
|
|
spell->castSound = soundsNode["cast"].String();
|
|
|
|
|
|
|
|
//load level attributes
|
|
|
|
const int levelsCount = GameConstants::SPELL_SCHOOL_LEVELS;
|
|
|
|
|
|
|
|
for(int levelIndex = 0; levelIndex < levelsCount; levelIndex++)
|
|
|
|
{
|
|
|
|
const JsonNode & levelNode = json["levels"][LEVEL_NAMES[levelIndex]];
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
CSpell::LevelInfo & levelObject = spell->levels[levelIndex];
|
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
const si32 levelPower = levelObject.power = static_cast<si32>(levelNode["power"].Integer());
|
2015-02-02 10:25:26 +02:00
|
|
|
|
|
|
|
levelObject.description = levelNode["description"].String();
|
2020-10-01 10:38:06 +02:00
|
|
|
levelObject.cost = static_cast<si32>(levelNode["cost"].Integer());
|
|
|
|
levelObject.AIValue = static_cast<si32>(levelNode["aiValue"].Integer());
|
2015-02-02 10:25:26 +02:00
|
|
|
levelObject.smartTarget = levelNode["targetModifier"]["smart"].Bool();
|
|
|
|
levelObject.clearTarget = levelNode["targetModifier"]["clearTarget"].Bool();
|
2015-02-26 19:59:18 +02:00
|
|
|
levelObject.clearAffected = levelNode["targetModifier"]["clearAffected"].Bool();
|
2015-02-02 10:25:26 +02:00
|
|
|
levelObject.range = levelNode["range"].String();
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
for(const auto & elem : levelNode["effects"].Struct())
|
|
|
|
{
|
|
|
|
const JsonNode & bonusNode = elem.second;
|
2016-09-19 23:36:35 +02:00
|
|
|
auto b = JsonUtils::parseBonus(bonusNode);
|
2015-02-02 10:25:26 +02:00
|
|
|
const bool usePowerAsValue = bonusNode["val"].isNull();
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
b->sid = spell->id; //for all
|
2015-02-02 10:25:26 +02:00
|
|
|
b->source = Bonus::SPELL_EFFECT;//for all
|
|
|
|
|
|
|
|
if(usePowerAsValue)
|
|
|
|
b->val = levelPower;
|
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
levelObject.effects.push_back(b);
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
for(const auto & elem : levelNode["cumulativeEffects"].Struct())
|
|
|
|
{
|
|
|
|
const JsonNode & bonusNode = elem.second;
|
|
|
|
auto b = JsonUtils::parseBonus(bonusNode);
|
|
|
|
const bool usePowerAsValue = bonusNode["val"].isNull();
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
b->sid = spell->id; //for all
|
2016-11-02 19:11:01 +02:00
|
|
|
b->source = Bonus::SPELL_EFFECT;//for all
|
|
|
|
|
|
|
|
if(usePowerAsValue)
|
|
|
|
b->val = levelPower;
|
|
|
|
|
|
|
|
levelObject.cumulativeEffects.push_back(b);
|
|
|
|
}
|
2015-02-02 10:25:26 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
if(levelNode["battleEffects"].getType() == JsonNode::JsonType::DATA_STRUCT && !levelNode["battleEffects"].Struct().empty())
|
|
|
|
{
|
|
|
|
levelObject.battleEffects = levelNode["battleEffects"];
|
|
|
|
|
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(!levelObject.cumulativeEffects.empty() || !levelObject.effects.empty() || spell->isOffensive())
|
2017-07-20 06:08:49 +02:00
|
|
|
logGlobal->error("Mixing %s special effects with old format effects gives unpredictable result", spell->name);
|
|
|
|
}
|
|
|
|
}
|
2015-02-02 10:25:26 +02:00
|
|
|
return spell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSpellHandler::afterLoadFinalization()
|
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
for(auto spell : objects)
|
2015-02-02 10:25:26 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
spell->setupMechanics();
|
2015-02-02 10:25:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSpellHandler::beforeValidate(JsonNode & object)
|
|
|
|
{
|
|
|
|
//handle "base" level info
|
2015-02-26 19:59:18 +02:00
|
|
|
|
|
|
|
JsonNode & levels = object["levels"];
|
|
|
|
JsonNode & base = levels["base"];
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
auto inheritNode = [&](const std::string & name)
|
|
|
|
{
|
2015-02-02 10:25:26 +02:00
|
|
|
JsonUtils::inherit(levels[name],base);
|
|
|
|
};
|
2015-02-26 19:59:18 +02:00
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
inheritNode("none");
|
|
|
|
inheritNode("basic");
|
|
|
|
inheritNode("advanced");
|
|
|
|
inheritNode("expert");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<bool> CSpellHandler::getDefaultAllowed() const
|
|
|
|
{
|
|
|
|
std::vector<bool> allowedSpells;
|
2016-02-21 19:58:09 +02:00
|
|
|
allowedSpells.reserve(objects.size());
|
|
|
|
|
|
|
|
for(const CSpell * s : objects)
|
|
|
|
{
|
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
|
|
|
allowedSpells.push_back( !(s->isSpecial() || s->isCreatureAbility()));
|
2016-02-21 19:58:09 +02:00
|
|
|
}
|
|
|
|
|
2015-02-02 10:25:26 +02:00
|
|
|
return allowedSpells;
|
2022-07-26 15:07:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|