2018-03-02 12:22:51 +02:00
|
|
|
/*
|
|
|
|
* ProxyCaster.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "ProxyCaster.h"
|
|
|
|
|
|
|
|
#include "../GameConstants.h"
|
|
|
|
|
2023-03-19 01:30:06 +02:00
|
|
|
#include <vcmi/spells/Spell.h>
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2018-03-02 12:22:51 +02:00
|
|
|
namespace spells
|
|
|
|
{
|
|
|
|
|
|
|
|
ProxyCaster::ProxyCaster(const Caster * actualCaster_)
|
|
|
|
: actualCaster(actualCaster_)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ProxyCaster::~ProxyCaster() = default;
|
|
|
|
|
2018-03-04 10:13:07 +02:00
|
|
|
int32_t ProxyCaster::getCasterUnitId() const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getCasterUnitId();
|
|
|
|
|
|
|
|
return -1;
|
2018-03-04 10:13:07 +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
|
|
|
int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getSpellSchoolLevel(spell, outSelectedSchool);
|
|
|
|
|
|
|
|
return 0;
|
2018-03-02 12:22:51 +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
|
|
|
int32_t ProxyCaster::getEffectLevel(const Spell * spell) const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getEffectLevel(spell);
|
|
|
|
|
|
|
|
return 0;
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t ProxyCaster::getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getSpellBonus(spell, base, affectedStack);
|
|
|
|
|
|
|
|
return base;
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t ProxyCaster::getSpecificSpellBonus(const Spell * spell, int64_t base) const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getSpecificSpellBonus(spell, base);
|
|
|
|
|
|
|
|
return base;
|
2018-03-02 12:22:51 +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
|
|
|
int32_t ProxyCaster::getEffectPower(const Spell * spell) const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getEffectPower(spell);
|
|
|
|
|
|
|
|
return spell->getLevelPower(getEffectLevel(spell));
|
2018-03-02 12:22:51 +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
|
|
|
int32_t ProxyCaster::getEnchantPower(const Spell * spell) const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getEnchantPower(spell);
|
|
|
|
|
|
|
|
return spell->getLevelPower(getEffectLevel(spell));
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int64_t ProxyCaster::getEffectValue(const Spell * spell) const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getEffectValue(spell);
|
|
|
|
|
|
|
|
return 0;
|
2018-03-02 12:22:51 +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
|
|
|
PlayerColor ProxyCaster::getCasterOwner() const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getCasterOwner();
|
|
|
|
|
|
|
|
return PlayerColor::CANNOT_DETERMINE;
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyCaster::getCasterName(MetaString & text) const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
actualCaster->getCasterName(text);
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProxyCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit*> & attacked, MetaString & text) const
|
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
actualCaster->getCastDescription(spell, attacked, text);
|
2018-03-02 12:22:51 +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 ProxyCaster::spendMana(ServerCallback * server, const int32_t spellCost) const
|
2018-03-02 12:22:51 +02:00
|
|
|
{
|
2023-03-19 01:30:06 +02:00
|
|
|
if(actualCaster)
|
|
|
|
actualCaster->spendMana(server, spellCost);
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
|
|
|
|
2023-04-09 23:31:41 +02:00
|
|
|
const CGHeroInstance * ProxyCaster::getHeroCaster() const
|
|
|
|
{
|
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->getHeroCaster();
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2023-04-10 13:40:08 +02:00
|
|
|
int32_t ProxyCaster::manaLimit() const
|
|
|
|
{
|
|
|
|
if(actualCaster)
|
|
|
|
return actualCaster->manaLimit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-02 12:22:51 +02:00
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|