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
|
|
|
|
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 "mapObjects/CObjectClassesHandler.h"//todo: remove
|
|
|
|
#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"
|
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 "CModHandler.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
|
|
|
|
|
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)
|
|
|
|
{
|
2022-12-21 12:58:40 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::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)
|
|
|
|
return rawId.get();
|
|
|
|
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
|
|
|
{
|
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->arth->objects.at(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "artifact", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
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)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "creature", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
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
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("Unable to get spell of invalid ID %d", 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)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "spell", identifier);
|
2017-07-20 06:08:49 +02:00
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 FactionID FactionID::ANY = FactionID(-1);
|
|
|
|
const FactionID FactionID::CASTLE = FactionID(0);
|
|
|
|
const FactionID FactionID::RAMPART = FactionID(1);
|
|
|
|
const FactionID FactionID::TOWER = FactionID(2);
|
|
|
|
const FactionID FactionID::INFERNO = FactionID(3);
|
|
|
|
const FactionID FactionID::NECROPOLIS = FactionID(4);
|
|
|
|
const FactionID FactionID::DUNGEON = FactionID(5);
|
|
|
|
const FactionID FactionID::STRONGHOLD = FactionID(6);
|
|
|
|
const FactionID FactionID::FORTRESS = FactionID(7);
|
|
|
|
const FactionID FactionID::CONFLUX = FactionID(8);
|
|
|
|
const FactionID FactionID::NEUTRAL = FactionID(9);
|
|
|
|
|
|
|
|
si32 FactionID::decode(const std::string & identifier)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "faction", 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)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string FactionID::encode(const si32 index)
|
|
|
|
{
|
|
|
|
return VLC->factions()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
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::INVALID, "Invalid"},
|
|
|
|
{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
|
|
|
|
2015-11-05 11:46: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
BattleField::operator std::string() const
|
|
|
|
{
|
|
|
|
return getInfo()->identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BattleFieldInfo * BattleField::getInfo() const
|
|
|
|
{
|
|
|
|
return VLC->battlefields()->getById(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
BattleField BattleField::fromString(std::string identifier)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeBuiltin(), "battlefield", identifier);
|
2022-06-28 10:05:30 +02:00
|
|
|
|
|
|
|
if(rawId)
|
|
|
|
return BattleField(rawId.get());
|
|
|
|
else
|
|
|
|
return BattleField::NONE;
|
2022-09-15 10:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ObstacleInfo * Obstacle::getInfo() const
|
|
|
|
{
|
|
|
|
return VLC->obstacles()->getById(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Obstacle::operator std::string() const
|
|
|
|
{
|
|
|
|
return getInfo()->identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
Obstacle Obstacle::fromString(std::string identifier)
|
|
|
|
{
|
2022-12-07 15:18:19 +02:00
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier(CModHandler::scopeBuiltin(), "obstacle", identifier);
|
2022-09-15 10:06:54 +02:00
|
|
|
|
|
|
|
if(rawId)
|
|
|
|
return Obstacle(rawId.get());
|
|
|
|
else
|
|
|
|
return Obstacle(-1);
|
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|