2013-02-11 22:27:37 +03:00
|
|
|
/*
|
2023-08-20 17:16:00 +02:00
|
|
|
* EntityIdentifiers.cpp, part of VCMI engine
|
2013-02-11 22:27:37 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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
|
2023-08-19 23:22:31 +02:00
|
|
|
#include "constants/StringConstants.h"
|
2016-09-15 17:22:54 +02:00
|
|
|
#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-08-19 23:22:31 +02:00
|
|
|
const QueryID QueryID::NONE = QueryID(-1);
|
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);
|
|
|
|
|
2023-08-27 00:35:38 +02:00
|
|
|
const PlayerColor PlayerColor::SPECTATOR = PlayerColor(-4);
|
|
|
|
const PlayerColor PlayerColor::CANNOT_DETERMINE = PlayerColor(-3);
|
|
|
|
const PlayerColor PlayerColor::UNFLAGGABLE = PlayerColor(-2);
|
|
|
|
const PlayerColor PlayerColor::NEUTRAL = PlayerColor(-1);
|
2013-03-03 20:06:03 +03:00
|
|
|
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
2023-08-27 00:35:38 +02:00
|
|
|
const TeamID TeamID::NO_TEAM = TeamID(-1);
|
2013-02-16 17:03:47 +03:00
|
|
|
|
2023-08-20 17:16:00 +02:00
|
|
|
const SpellSchool SpellSchool::ANY = -1;
|
|
|
|
const SpellSchool SpellSchool::AIR = 0;
|
|
|
|
const SpellSchool SpellSchool::FIRE = 1;
|
|
|
|
const SpellSchool SpellSchool::WATER = 2;
|
|
|
|
const SpellSchool SpellSchool::EARTH = 3;
|
|
|
|
|
|
|
|
const FactionID FactionID::NONE = -2;
|
|
|
|
const FactionID FactionID::DEFAULT = -1;
|
|
|
|
const FactionID FactionID::RANDOM = -1;
|
|
|
|
const FactionID FactionID::ANY = -1;
|
|
|
|
const FactionID FactionID::CASTLE = 0;
|
|
|
|
const FactionID FactionID::RAMPART = 1;
|
|
|
|
const FactionID FactionID::TOWER = 2;
|
|
|
|
const FactionID FactionID::INFERNO = 3;
|
|
|
|
const FactionID FactionID::NECROPOLIS = 4;
|
|
|
|
const FactionID FactionID::DUNGEON = 5;
|
|
|
|
const FactionID FactionID::STRONGHOLD = 6;
|
|
|
|
const FactionID FactionID::FORTRESS = 7;
|
|
|
|
const FactionID FactionID::CONFLUX = 8;
|
|
|
|
const FactionID FactionID::NEUTRAL = 9;
|
|
|
|
|
|
|
|
const BoatId BoatId::NONE = -1;
|
|
|
|
const BoatId BoatId::NECROPOLIS = 0;
|
|
|
|
const BoatId BoatId::CASTLE = 1;
|
|
|
|
const BoatId BoatId::FORTRESS = 2;
|
|
|
|
|
|
|
|
const RiverId RiverId::NO_RIVER = 0;
|
|
|
|
const RiverId RiverId::WATER_RIVER = 1;
|
|
|
|
const RiverId RiverId::ICY_RIVER = 2;
|
|
|
|
const RiverId RiverId::MUD_RIVER = 3;
|
|
|
|
const RiverId RiverId::LAVA_RIVER = 4;
|
|
|
|
|
|
|
|
const RoadId RoadId::NO_ROAD = 0;
|
|
|
|
const RoadId RoadId::DIRT_ROAD = 1;
|
|
|
|
const RoadId RoadId::GRAVEL_ROAD = 2;
|
|
|
|
const RoadId RoadId::COBBLESTONE_ROAD = 3;
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
const CArtifact * ArtifactIDBase::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
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
const Artifact * ArtifactIDBase::toArtifact(const ArtifactService * service) const
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
2023-08-19 19:48:28 +02:00
|
|
|
return service->getByIndex(num);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
si32 ArtifactIDBase::decode(const std::string & identifier)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
std::string ArtifactIDBase::encode(const si32 index)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->artifacts()->getByIndex(index)->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
const CCreature * CreatureIDBase::toCreature() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
2023-08-19 19:48:28 +02:00
|
|
|
return VLC->creh->objects.at(num);
|
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-19 19:48:28 +02:00
|
|
|
const Creature * CreatureIDBase::toCreature(const CreatureService * creatures) const
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
2023-08-19 19:48:28 +02:00
|
|
|
return creatures->getByIndex(num);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
si32 CreatureIDBase::decode(const std::string & identifier)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
std::string CreatureIDBase::encode(const si32 index)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->creatures()->getById(CreatureID(index))->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
const CSpell * SpellIDBase::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
|
|
|
}
|
2023-08-19 19:48:28 +02:00
|
|
|
return VLC->spellh->objects[num];
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
2013-02-14 02:55:42 +03:00
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
const spells::Spell * SpellIDBase::toSpell(const spells::Service * service) const
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
2023-08-19 19:48:28 +02:00
|
|
|
return service->getByIndex(num);
|
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-19 19:48:28 +02:00
|
|
|
si32 SpellIDBase::decode(const std::string & identifier)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-19 19:48:28 +02:00
|
|
|
std::string SpellIDBase::encode(const si32 index)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
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
|
|
|
|
{
|
2023-08-27 00:35:38 +02:00
|
|
|
return num >= 0 && num < PLAYER_LIMIT_I;
|
2013-04-20 14:34:01 +03:00
|
|
|
}
|
2013-11-09 19:25:20 +03:00
|
|
|
|
2017-06-03 07:25:10 +02:00
|
|
|
bool PlayerColor::isSpectator() const
|
|
|
|
{
|
2023-08-27 00:35:38 +02:00
|
|
|
return num == SPECTATOR.num;
|
2017-06-03 07:25:10 +02:00
|
|
|
}
|
|
|
|
|
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-20 17:16:00 +02:00
|
|
|
si32 FactionID::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-20 17:16:00 +02:00
|
|
|
std::string FactionID::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-20 17:16:00 +02:00
|
|
|
std::string FactionID::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";
|
|
|
|
}
|
|
|
|
|
2022-06-28 10:05:30 +02:00
|
|
|
const BattleField BattleField::NONE;
|
|
|
|
|
|
|
|
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
|