2013-02-11 22:27:37 +03:00
|
|
|
/*
|
|
|
|
* GameConstants.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-02-14 02:55:42 +03:00
|
|
|
#define INSTANTIATE_BASE_FOR_ID_HERE
|
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
|
2016-10-27 15:27:10 +02:00
|
|
|
#ifndef VCMI_NO_EXTRA_VERSION
|
|
|
|
#include "../Version.h"
|
|
|
|
#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
|
|
|
#include <vcmi/Artifact.h>
|
|
|
|
#include <vcmi/ArtifactService.h>
|
|
|
|
#include <vcmi/Faction.h>
|
|
|
|
#include <vcmi/FactionService.h>
|
|
|
|
#include <vcmi/HeroType.h>
|
|
|
|
#include <vcmi/HeroTypeService.h>
|
|
|
|
|
|
|
|
#include <vcmi/spells/Spell.h>
|
|
|
|
#include <vcmi/spells/Service.h>
|
2016-10-27 15:27:10 +02:00
|
|
|
|
2023-07-30 19:12:25 +02:00
|
|
|
#include "modding/IdentifierStorage.h"
|
|
|
|
#include "modding/ModScope.h"
|
2013-02-11 02:24:57 +03:00
|
|
|
#include "VCMI_Lib.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 "CArtHandler.h"//todo: remove
|
|
|
|
#include "CCreatureHandler.h"//todo: remove
|
|
|
|
#include "spells/CSpellHandler.h" //todo: remove
|
|
|
|
#include "CSkillHandler.h"//todo: remove
|
2016-09-15 17:22:54 +02:00
|
|
|
#include "StringConstants.h"
|
|
|
|
#include "CGeneralTextHandler.h"
|
2023-07-05 20:53:00 +02:00
|
|
|
#include "TerrainHandler.h" //TODO: remove
|
2022-06-28 10:05:30 +02:00
|
|
|
#include "BattleFieldHandler.h"
|
2022-09-15 10:06:54 +02:00
|
|
|
#include "ObstacleHandler.h"
|
2013-02-11 02:24:57 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-06-27 18:32:27 +02:00
|
|
|
const HeroTypeID HeroTypeID::NONE = HeroTypeID(-1);
|
2023-07-12 20:13:17 +02:00
|
|
|
const ObjectInstanceID ObjectInstanceID::NONE = ObjectInstanceID(-1);
|
2023-06-27 18:32:27 +02:00
|
|
|
|
2013-02-16 17:03:47 +03:00
|
|
|
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
|
2016-01-29 23:53:53 +02:00
|
|
|
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
|
|
|
|
const SlotID SlotID::WAR_MACHINES_SLOT = SlotID(-4);
|
|
|
|
const SlotID SlotID::ARROW_TOWERS_SLOT = SlotID(-5);
|
|
|
|
|
2017-06-03 07:25:10 +02:00
|
|
|
const PlayerColor PlayerColor::SPECTATOR = PlayerColor(252);
|
2013-03-03 20:06:03 +03:00
|
|
|
const PlayerColor PlayerColor::CANNOT_DETERMINE = PlayerColor(253);
|
|
|
|
const PlayerColor PlayerColor::UNFLAGGABLE = PlayerColor(254);
|
|
|
|
const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255);
|
|
|
|
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
|
|
|
const TeamID TeamID::NO_TEAM = TeamID(255);
|
2013-02-16 17:03:47 +03:00
|
|
|
|
2016-10-27 15:27:10 +02:00
|
|
|
namespace GameConstants
|
|
|
|
{
|
|
|
|
#ifdef VCMI_NO_EXTRA_VERSION
|
2022-10-04 11:29:38 +02:00
|
|
|
const std::string VCMI_VERSION = "VCMI " VCMI_VERSION_STRING;
|
2016-10-27 15:27:10 +02:00
|
|
|
#else
|
2022-10-04 11:29:38 +02:00
|
|
|
const std::string VCMI_VERSION = "VCMI " VCMI_VERSION_STRING "." + std::string{GIT_SHA1};
|
2016-10-27 15:27:10 +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
|
|
|
si32 HeroTypeID::decode(const std::string & identifier)
|
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "hero", identifier);
|
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(rawId)
|
2023-04-16 19:42:56 +02:00
|
|
|
return rawId.value();
|
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
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HeroTypeID::encode(const si32 index)
|
|
|
|
{
|
|
|
|
return VLC->heroTypes()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CArtifact * ArtifactID::toArtifact() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
2023-03-27 13:56:39 +02:00
|
|
|
return dynamic_cast<const CArtifact*>(toArtifact(VLC->artifacts()));
|
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 Artifact * ArtifactID::toArtifact(const ArtifactService * service) const
|
|
|
|
{
|
|
|
|
return service->getById(*this);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 ArtifactID::decode(const std::string & identifier)
|
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "artifact", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
2023-04-16 19:42:56 +02:00
|
|
|
return rawId.value();
|
2017-07-20 06:08:49 +02:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ArtifactID::encode(const si32 index)
|
|
|
|
{
|
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 VLC->artifacts()->getByIndex(index)->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CCreature * CreatureID::toCreature() const
|
2013-02-11 02:24:57 +03: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 VLC->creh->objects.at(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Creature * CreatureID::toCreature(const CreatureService * creatures) const
|
|
|
|
{
|
|
|
|
return creatures->getById(*this);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 CreatureID::decode(const std::string & identifier)
|
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "creature", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
2023-04-16 19:42:56 +02:00
|
|
|
return rawId.value();
|
2017-07-20 06:08:49 +02:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CreatureID::encode(const si32 index)
|
|
|
|
{
|
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 VLC->creatures()->getById(CreatureID(index))->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CSpell * SpellID::toSpell() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
2014-11-27 23:36:14 +02:00
|
|
|
if(num < 0 || num >= VLC->spellh->objects.size())
|
2015-03-22 21:32:22 +02:00
|
|
|
{
|
2023-03-13 23:26:44 +02:00
|
|
|
logGlobal->error("Unable to get spell of invalid ID %d", static_cast<int>(num));
|
2014-11-27 23:36:14 +02:00
|
|
|
return nullptr;
|
2015-03-22 21:32:22 +02:00
|
|
|
}
|
2014-03-07 16:21:09 +03:00
|
|
|
return VLC->spellh->objects[*this];
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
2013-02-14 02:55:42 +03: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 spells::Spell * SpellID::toSpell(const spells::Service * service) const
|
|
|
|
{
|
|
|
|
return service->getById(*this);
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 SpellID::decode(const std::string & identifier)
|
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "spell", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
2023-04-16 19:42:56 +02:00
|
|
|
return rawId.value();
|
2017-07-20 06:08:49 +02:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpellID::encode(const si32 index)
|
|
|
|
{
|
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 VLC->spells()->getByIndex(index)->getJsonKey();
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2013-04-20 14:34:01 +03:00
|
|
|
bool PlayerColor::isValidPlayer() const
|
|
|
|
{
|
|
|
|
return num < PLAYER_LIMIT_I;
|
|
|
|
}
|
2013-11-09 19:25:20 +03:00
|
|
|
|
2017-06-03 07:25:10 +02:00
|
|
|
bool PlayerColor::isSpectator() const
|
|
|
|
{
|
|
|
|
return num == 252;
|
|
|
|
}
|
|
|
|
|
2016-09-15 17:22:54 +02:00
|
|
|
std::string PlayerColor::getStr(bool L10n) const
|
|
|
|
{
|
|
|
|
std::string ret = "unnamed";
|
|
|
|
if(isValidPlayer())
|
|
|
|
{
|
|
|
|
if(L10n)
|
|
|
|
ret = VLC->generaltexth->colors[num];
|
|
|
|
else
|
|
|
|
ret = GameConstants::PLAYER_COLOR_NAMES[num];
|
|
|
|
}
|
|
|
|
else if(L10n)
|
|
|
|
{
|
|
|
|
ret = VLC->generaltexth->allTexts[508];
|
|
|
|
ret[0] = std::tolower(ret[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string PlayerColor::getStrCap(bool L10n) const
|
|
|
|
{
|
|
|
|
std::string ret = getStr(L10n);
|
|
|
|
ret[0] = std::toupper(ret[0]);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
si32 FactionIDBase::decode(const std::string & identifier)
|
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
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier);
|
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(rawId)
|
2023-04-16 19:42:56 +02:00
|
|
|
return rawId.value();
|
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
|
|
|
else
|
2023-04-09 03:36:16 +02:00
|
|
|
return FactionID::DEFAULT;
|
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
|
|
|
}
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
std::string FactionIDBase::encode(const si32 index)
|
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 VLC->factions()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
std::string FactionIDBase::entityType()
|
2023-07-05 20:53:00 +02:00
|
|
|
{
|
|
|
|
return "faction";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
si32 TerrainIdBase::decode(const std::string & identifier)
|
2023-07-05 20:53:00 +02:00
|
|
|
{
|
2023-07-30 19:12:25 +02:00
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), entityType(), identifier);
|
2023-07-05 20:53:00 +02:00
|
|
|
if(rawId)
|
|
|
|
return rawId.value();
|
|
|
|
else
|
2023-08-18 12:38:19 +02:00
|
|
|
return static_cast<si32>(TerrainId::NONE);
|
2023-07-05 20:53:00 +02:00
|
|
|
}
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
std::string TerrainIdBase::encode(const si32 index)
|
2023-07-05 20:53:00 +02:00
|
|
|
{
|
|
|
|
return VLC->terrainTypeHandler->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2023-08-18 12:38:19 +02:00
|
|
|
std::string TerrainIdBase::entityType()
|
2023-07-05 20:53:00 +02:00
|
|
|
{
|
|
|
|
return "terrain";
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os, const EActionType actionType)
|
2013-11-09 19:25:20 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
static const std::map<EActionType, std::string> actionTypeToString =
|
2014-10-02 18:43:46 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
{EActionType::END_TACTIC_PHASE, "End tactic phase"},
|
|
|
|
{EActionType::NO_ACTION, "No action"},
|
|
|
|
{EActionType::HERO_SPELL, "Hero spell"},
|
|
|
|
{EActionType::WALK, "Walk"},
|
|
|
|
{EActionType::DEFEND, "Defend"},
|
|
|
|
{EActionType::RETREAT, "Retreat"},
|
|
|
|
{EActionType::SURRENDER, "Surrender"},
|
|
|
|
{EActionType::WALK_AND_ATTACK, "Walk and attack"},
|
|
|
|
{EActionType::SHOOT, "Shoot"},
|
|
|
|
{EActionType::WAIT, "Wait"},
|
|
|
|
{EActionType::CATAPULT, "Catapult"},
|
|
|
|
{EActionType::MONSTER_SPELL, "Monster spell"},
|
|
|
|
{EActionType::BAD_MORALE, "Bad morale"},
|
|
|
|
{EActionType::STACK_HEAL, "Stack heal"},
|
2014-10-02 18:43:46 +03:00
|
|
|
};
|
2013-11-09 19:25:20 +03:00
|
|
|
|
|
|
|
auto it = actionTypeToString.find(actionType);
|
|
|
|
if (it == actionTypeToString.end()) return os << "<Unknown type>";
|
|
|
|
else return os << it->second;
|
|
|
|
}
|
2015-03-22 21:32:22 +02:00
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os, const EPathfindingLayer & pathfindingLayer)
|
2015-11-02 12:25:01 +02:00
|
|
|
{
|
2015-11-05 11:46:44 +02:00
|
|
|
static const std::map<EPathfindingLayer::EEPathfindingLayer, std::string> pathfinderLayerToString
|
2015-11-02 12:25:01 +02:00
|
|
|
{
|
|
|
|
#define DEFINE_ELEMENT(element) {EPathfindingLayer::element, #element}
|
|
|
|
DEFINE_ELEMENT(WRONG),
|
|
|
|
DEFINE_ELEMENT(AUTO),
|
|
|
|
DEFINE_ELEMENT(LAND),
|
|
|
|
DEFINE_ELEMENT(SAIL),
|
|
|
|
DEFINE_ELEMENT(WATER),
|
|
|
|
DEFINE_ELEMENT(AIR),
|
|
|
|
DEFINE_ELEMENT(NUM_LAYERS)
|
2015-11-05 11:46:44 +02:00
|
|
|
#undef DEFINE_ELEMENT
|
2015-11-02 12:25:01 +02:00
|
|
|
};
|
|
|
|
|
2015-11-05 11:46:44 +02:00
|
|
|
auto it = pathfinderLayerToString.find(pathfindingLayer.num);
|
2015-11-02 12:25:01 +02:00
|
|
|
if (it == pathfinderLayerToString.end()) return os << "<Unknown type>";
|
|
|
|
else return os << it->second;
|
|
|
|
}
|
2022-06-28 10:05:30 +02:00
|
|
|
|
|
|
|
const BattleField BattleField::NONE;
|
|
|
|
|
|
|
|
bool operator==(const BattleField & l, const BattleField & r)
|
|
|
|
{
|
|
|
|
return l.num == r.num;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const BattleField & l, const BattleField & r)
|
|
|
|
{
|
|
|
|
return l.num != r.num;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const BattleField & l, const BattleField & r)
|
|
|
|
{
|
|
|
|
return l.num < r.num;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BattleFieldInfo * BattleField::getInfo() const
|
|
|
|
{
|
|
|
|
return VLC->battlefields()->getById(*this);
|
|
|
|
}
|
|
|
|
|
2022-09-15 10:06:54 +02:00
|
|
|
const ObstacleInfo * Obstacle::getInfo() const
|
|
|
|
{
|
|
|
|
return VLC->obstacles()->getById(*this);
|
|
|
|
}
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|