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>
|
2023-10-09 04:26:08 +02:00
|
|
|
#include <vcmi/HeroClass.h>
|
|
|
|
#include <vcmi/HeroClassService.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 <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-09-28 18:43:04 +02:00
|
|
|
const BattleID BattleID::NONE(-1);
|
|
|
|
const QueryID QueryID::NONE(-1);
|
2023-10-07 01:44:37 +02:00
|
|
|
const QueryID QueryID::CLIENT(-2);
|
2023-09-28 18:43:04 +02:00
|
|
|
const HeroTypeID HeroTypeID::NONE(-1);
|
|
|
|
const HeroTypeID HeroTypeID::RANDOM(-2);
|
|
|
|
const ObjectInstanceID ObjectInstanceID::NONE(-1);
|
|
|
|
|
|
|
|
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER(-2);
|
|
|
|
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER(-3);
|
|
|
|
const SlotID SlotID::WAR_MACHINES_SLOT(-4);
|
|
|
|
const SlotID SlotID::ARROW_TOWERS_SLOT(-5);
|
|
|
|
|
|
|
|
const PlayerColor PlayerColor::SPECTATOR(-4);
|
|
|
|
const PlayerColor PlayerColor::CANNOT_DETERMINE(-3);
|
|
|
|
const PlayerColor PlayerColor::UNFLAGGABLE(-2);
|
|
|
|
const PlayerColor PlayerColor::NEUTRAL(-1);
|
|
|
|
const PlayerColor PlayerColor::PLAYER_LIMIT(PLAYER_LIMIT_I);
|
|
|
|
const TeamID TeamID::NO_TEAM(-1);
|
|
|
|
|
|
|
|
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);
|
2023-08-20 17:16:00 +02: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
|
|
|
|
}
|
|
|
|
|
2023-10-09 04:26:08 +02:00
|
|
|
si32 HeroClassID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "heroClass", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.value();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HeroClassID::encode(const si32 index)
|
|
|
|
{
|
|
|
|
return VLC->heroClasses()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HeroClassID::entityType()
|
|
|
|
{
|
|
|
|
return "heroClass";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
std::string HeroTypeID::entityType()
|
|
|
|
{
|
|
|
|
return "hero";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
si32 ArtifactID::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-09-04 21:23:20 +02:00
|
|
|
std::string ArtifactID::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-09-04 21:23:20 +02:00
|
|
|
std::string ArtifactID::entityType()
|
|
|
|
{
|
|
|
|
return "artifact";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
si32 CreatureID::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-09-04 21:23:20 +02:00
|
|
|
std::string CreatureID::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-09-04 21:23:20 +02:00
|
|
|
std::string CreatureID::entityType()
|
|
|
|
{
|
|
|
|
return "creature";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
si32 SpellID::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-09-04 21:23:20 +02:00
|
|
|
std::string SpellID::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
|
|
|
}
|
|
|
|
|
2023-09-04 21:23:20 +02:00
|
|
|
std::string SpellID::entityType()
|
|
|
|
{
|
|
|
|
return "spell";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
return num == SPECTATOR.num;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string PlayerColor::toString() const
|
|
|
|
{
|
2023-09-04 23:58:08 +02:00
|
|
|
if (num == -1)
|
|
|
|
return "neutral";
|
2023-09-04 21:23:20 +02:00
|
|
|
return encode(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
si32 PlayerColor::decode(const std::string & identifier)
|
2023-08-25 20:40:19 +02:00
|
|
|
{
|
|
|
|
return vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string PlayerColor::encode(const si32 index)
|
|
|
|
{
|
2023-09-04 21:43:16 +02:00
|
|
|
if (index < 0 || index >= std::size(GameConstants::PLAYER_COLOR_NAMES))
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
return "invalid";
|
|
|
|
}
|
|
|
|
|
2023-08-25 20:40:19 +02:00
|
|
|
return GameConstants::PLAYER_COLOR_NAMES[index];
|
|
|
|
}
|
|
|
|
|
2023-09-04 21:23:20 +02:00
|
|
|
std::string PlayerColor::entityType()
|
|
|
|
{
|
|
|
|
return "playerColor";
|
|
|
|
}
|
|
|
|
|
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-09-04 21:23:20 +02:00
|
|
|
si32 TerrainId::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-09-04 21:23:20 +02:00
|
|
|
std::string TerrainId::encode(const si32 index)
|
2023-07-05 20:53:00 +02:00
|
|
|
{
|
|
|
|
return VLC->terrainTypeHandler->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2023-09-04 21:23:20 +02:00
|
|
|
std::string TerrainId::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
|