2023-10-19 16:19:09 +02:00
|
|
|
/*
|
|
|
|
* EntityIdentifiers.h, 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "NumericConstants.h"
|
2023-10-22 17:36:41 +02:00
|
|
|
#include "IdentifierBase.h"
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-11-04 17:04:53 +02:00
|
|
|
class Services;
|
2023-10-19 16:19:09 +02:00
|
|
|
class Artifact;
|
|
|
|
class ArtifactService;
|
|
|
|
class Creature;
|
|
|
|
class CreatureService;
|
2023-11-02 18:45:46 +02:00
|
|
|
class HeroType;
|
|
|
|
class CHero;
|
2023-12-31 23:43:35 +02:00
|
|
|
class CHeroClass;
|
|
|
|
class HeroClass;
|
2023-11-02 18:45:46 +02:00
|
|
|
class HeroTypeService;
|
2024-02-19 00:36:08 +02:00
|
|
|
class CFaction;
|
2023-11-04 18:22:27 +02:00
|
|
|
class Faction;
|
2023-11-05 15:24:26 +02:00
|
|
|
class Skill;
|
2023-11-04 18:22:27 +02:00
|
|
|
class RoadType;
|
|
|
|
class RiverType;
|
|
|
|
class TerrainType;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
namespace spells
|
|
|
|
{
|
|
|
|
class Spell;
|
|
|
|
class Service;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CArtifact;
|
|
|
|
class CArtifactInstance;
|
|
|
|
class CCreature;
|
|
|
|
class CHero;
|
|
|
|
class CSpell;
|
|
|
|
class CSkill;
|
|
|
|
class CGameInfoCallback;
|
|
|
|
class CNonConstInfoCallback;
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class ArtifactInstanceID : public StaticIdentifier<ArtifactInstanceID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<ArtifactInstanceID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class QueryID : public StaticIdentifier<QueryID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<QueryID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
DLL_LINKAGE static const QueryID NONE;
|
|
|
|
DLL_LINKAGE static const QueryID CLIENT;
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class BattleID : public StaticIdentifier<BattleID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<BattleID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
DLL_LINKAGE static const BattleID NONE;
|
|
|
|
};
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE ObjectInstanceID : public StaticIdentifier<ObjectInstanceID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<ObjectInstanceID>::StaticIdentifier;
|
2023-10-22 17:36:41 +02:00
|
|
|
static const ObjectInstanceID NONE;
|
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class HeroClassID : public EntityIdentifier<HeroClassID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<HeroClassID>::EntityIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
///json serialization helpers
|
|
|
|
DLL_LINKAGE static si32 decode(const std::string & identifier);
|
|
|
|
DLL_LINKAGE static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-12-31 23:43:35 +02:00
|
|
|
|
|
|
|
const CHeroClass * toHeroClass() const;
|
|
|
|
const HeroClass * toEntity(const Services * services) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE HeroTypeID : public EntityIdentifier<HeroTypeID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<HeroTypeID>::EntityIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
///json serialization helpers
|
2023-11-04 18:22:27 +02:00
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
static std::string entityType();
|
|
|
|
|
2023-11-02 18:45:46 +02:00
|
|
|
const CHero * toHeroType() const;
|
2023-11-04 17:04:53 +02:00
|
|
|
const HeroType * toEntity(const Services * services) const;
|
2023-11-02 18:45:46 +02:00
|
|
|
|
2023-11-04 18:22:27 +02:00
|
|
|
static const HeroTypeID NONE;
|
|
|
|
static const HeroTypeID RANDOM;
|
2024-01-30 23:33:58 +02:00
|
|
|
static const HeroTypeID GEM; // aka Gem, Sorceress in campaign
|
|
|
|
static const HeroTypeID SOLMYR; // aka Young Yog in campaigns
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return getNum() >= 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class SlotID : public StaticIdentifier<SlotID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<SlotID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
DLL_LINKAGE static const SlotID COMMANDER_SLOT_PLACEHOLDER;
|
|
|
|
DLL_LINKAGE static const SlotID SUMMONED_SLOT_PLACEHOLDER; ///<for all summoned creatures, only during battle
|
|
|
|
DLL_LINKAGE static const SlotID WAR_MACHINES_SLOT; ///<for all war machines during battle
|
|
|
|
DLL_LINKAGE static const SlotID ARROW_TOWERS_SLOT; ///<for all arrow towers during battle
|
|
|
|
|
|
|
|
bool validSlot() const
|
|
|
|
{
|
|
|
|
return getNum() >= 0 && getNum() < GameConstants::ARMY_SIZE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE PlayerColor : public StaticIdentifier<PlayerColor>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<PlayerColor>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
enum EPlayerColor
|
|
|
|
{
|
|
|
|
PLAYER_LIMIT_I = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const PlayerColor SPECTATOR; //252
|
|
|
|
static const PlayerColor CANNOT_DETERMINE; //253
|
|
|
|
static const PlayerColor UNFLAGGABLE; //254 - neutral objects (pandora, banks)
|
|
|
|
static const PlayerColor NEUTRAL; //255
|
|
|
|
static const PlayerColor PLAYER_LIMIT; //player limit per map
|
|
|
|
|
|
|
|
bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
|
|
|
|
bool isSpectator() const;
|
|
|
|
|
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
static si32 decode(const std::string& identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class TeamID : public StaticIdentifier<TeamID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<TeamID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
DLL_LINKAGE static const TeamID NO_TEAM;
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class TeleportChannelID : public StaticIdentifier<TeleportChannelID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<TeleportChannelID>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SecondarySkillBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type : int32_t
|
|
|
|
{
|
2023-10-22 17:36:41 +02:00
|
|
|
NONE = -1,
|
2023-10-19 16:19:09 +02:00
|
|
|
PATHFINDING = 0,
|
|
|
|
ARCHERY,
|
|
|
|
LOGISTICS,
|
|
|
|
SCOUTING,
|
|
|
|
DIPLOMACY,
|
|
|
|
NAVIGATION,
|
|
|
|
LEADERSHIP,
|
|
|
|
WISDOM,
|
|
|
|
MYSTICISM,
|
|
|
|
LUCK,
|
|
|
|
BALLISTICS,
|
|
|
|
EAGLE_EYE,
|
|
|
|
NECROMANCY,
|
|
|
|
ESTATES,
|
|
|
|
FIRE_MAGIC,
|
|
|
|
AIR_MAGIC,
|
|
|
|
WATER_MAGIC,
|
|
|
|
EARTH_MAGIC,
|
|
|
|
SCHOLAR,
|
|
|
|
TACTICS,
|
|
|
|
ARTILLERY,
|
|
|
|
LEARNING,
|
|
|
|
OFFENCE,
|
|
|
|
ARMORER,
|
|
|
|
INTELLIGENCE,
|
|
|
|
SORCERY,
|
|
|
|
RESISTANCE,
|
|
|
|
FIRST_AID,
|
|
|
|
SKILL_SIZE
|
|
|
|
};
|
|
|
|
static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE SecondarySkill : public EntityIdentifierWithEnum<SecondarySkill, SecondarySkillBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<SecondarySkill, SecondarySkillBase>::EntityIdentifierWithEnum;
|
2023-10-22 17:36:41 +02:00
|
|
|
static std::string entityType();
|
|
|
|
static si32 decode(const std::string& identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-11-05 15:24:26 +02:00
|
|
|
|
|
|
|
const CSkill * toSkill() const;
|
|
|
|
const Skill * toEntity(const Services * services) const;
|
2023-10-22 17:36:41 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE PrimarySkill : public StaticIdentifier<PrimarySkill>
|
2023-10-22 17:36:41 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<PrimarySkill>::StaticIdentifier;
|
2023-10-22 17:36:41 +02:00
|
|
|
|
|
|
|
static const PrimarySkill NONE;
|
|
|
|
static const PrimarySkill ATTACK;
|
|
|
|
static const PrimarySkill DEFENSE;
|
|
|
|
static const PrimarySkill SPELL_POWER;
|
|
|
|
static const PrimarySkill KNOWLEDGE;
|
|
|
|
|
|
|
|
static const PrimarySkill BEGIN;
|
|
|
|
static const PrimarySkill END;
|
|
|
|
|
|
|
|
static const PrimarySkill EXPERIENCE;
|
|
|
|
|
|
|
|
static si32 decode(const std::string& identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE FactionID : public EntityIdentifier<FactionID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<FactionID>::EntityIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
static const FactionID NONE;
|
|
|
|
static const FactionID DEFAULT;
|
|
|
|
static const FactionID RANDOM;
|
|
|
|
static const FactionID ANY;
|
|
|
|
static const FactionID CASTLE;
|
|
|
|
static const FactionID RAMPART;
|
|
|
|
static const FactionID TOWER;
|
|
|
|
static const FactionID INFERNO;
|
|
|
|
static const FactionID NECROPOLIS;
|
|
|
|
static const FactionID DUNGEON;
|
|
|
|
static const FactionID STRONGHOLD;
|
|
|
|
static const FactionID FORTRESS;
|
|
|
|
static const FactionID CONFLUX;
|
|
|
|
static const FactionID NEUTRAL;
|
|
|
|
|
|
|
|
static si32 decode(const std::string& identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2024-02-19 00:36:08 +02:00
|
|
|
const CFaction * toFaction() const;
|
2023-11-04 18:22:27 +02:00
|
|
|
const Faction * toEntity(const Services * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
static std::string entityType();
|
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return getNum() >= 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class BuildingIDBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//Quite useful as long as most of building mechanics hardcoded
|
|
|
|
// NOTE: all building with completely configurable mechanics will be removed from list
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
DEFAULT = -50,
|
2024-08-05 21:15:47 +02:00
|
|
|
HORDE_PLACEHOLDER8 = -37,
|
2023-10-19 16:19:09 +02:00
|
|
|
HORDE_PLACEHOLDER7 = -36,
|
|
|
|
HORDE_PLACEHOLDER6 = -35,
|
|
|
|
HORDE_PLACEHOLDER5 = -34,
|
|
|
|
HORDE_PLACEHOLDER4 = -33,
|
|
|
|
HORDE_PLACEHOLDER3 = -32,
|
|
|
|
HORDE_PLACEHOLDER2 = -31,
|
|
|
|
HORDE_PLACEHOLDER1 = -30,
|
|
|
|
NONE = -1,
|
|
|
|
FIRST_REGULAR_ID = 0,
|
|
|
|
MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
|
|
|
|
TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
|
|
|
|
VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
|
|
|
|
RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
|
|
|
|
SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
|
|
|
|
HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
|
2024-08-05 23:03:19 +02:00
|
|
|
DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
|
|
|
|
DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
|
2024-08-07 01:35:50 +02:00
|
|
|
DWELL_LVL_6_UP, DWELL_UP_LAST=43, DWELL_LVL_8=150, DWELL_LVL_8_UP=151,
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
DWELL_LVL_1 = DWELL_FIRST,
|
2024-08-05 23:03:19 +02:00
|
|
|
DWELL_LVL_7 = DWELL_LAST,
|
2023-10-19 16:19:09 +02:00
|
|
|
DWELL_LVL_1_UP = DWELL_UP_FIRST,
|
2024-08-05 23:03:19 +02:00
|
|
|
DWELL_LVL_7_UP = DWELL_UP_LAST,
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-08-05 23:03:19 +02:00
|
|
|
DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
// //Special buildings for towns.
|
|
|
|
CASTLE_GATE = SPECIAL_3, //Inferno
|
|
|
|
FREELANCERS_GUILD = SPECIAL_2, //Stronghold
|
|
|
|
ARTIFACT_MERCHANT = SPECIAL_1,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-08-06 23:28:45 +02:00
|
|
|
private:
|
|
|
|
static std::vector<std::vector<Type>> getDwellings()
|
2024-08-05 23:51:07 +02:00
|
|
|
{
|
2024-08-06 23:28:45 +02:00
|
|
|
std::vector<Type> dwellings = { DWELL_LVL_1, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LVL_7, DWELL_LVL_8 };
|
|
|
|
std::vector<Type> dwellingsUp = { DWELL_LVL_1_UP, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP, DWELL_LVL_6_UP, DWELL_LVL_7_UP, DWELL_LVL_8_UP };
|
|
|
|
return {dwellings, dwellingsUp};
|
2024-08-05 23:51:07 +02:00
|
|
|
}
|
|
|
|
|
2024-08-06 23:28:45 +02:00
|
|
|
public:
|
2024-08-10 00:29:30 +02:00
|
|
|
static Type getDwellingFromLevel(int level, int upgradeIndex)
|
2024-08-05 23:51:07 +02:00
|
|
|
{
|
2024-08-10 00:29:30 +02:00
|
|
|
return getDwellings()[upgradeIndex][level];
|
2024-08-06 23:28:45 +02:00
|
|
|
}
|
2024-08-05 23:51:07 +02:00
|
|
|
|
2024-08-06 23:28:45 +02:00
|
|
|
static int getLevelFromDwelling(BuildingIDBase dwelling)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
auto tmp = getDwellings()[i];
|
|
|
|
auto it = std::find(tmp.begin(), tmp.end(), dwelling);
|
|
|
|
if (it != tmp.end())
|
|
|
|
return std::distance(tmp.begin(), it);
|
|
|
|
}
|
2024-08-07 01:35:50 +02:00
|
|
|
return (dwelling - DWELL_FIRST) % (GameConstants::CREATURES_PER_TOWN - 1);
|
2024-08-06 23:28:45 +02:00
|
|
|
}
|
2024-08-05 23:51:07 +02:00
|
|
|
|
2024-08-06 23:28:45 +02:00
|
|
|
static int getUpgradedFromDwelling(BuildingIDBase dwelling)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
auto tmp = getDwellings()[i];
|
|
|
|
auto it = std::find(tmp.begin(), tmp.end(), dwelling);
|
|
|
|
if (it != tmp.end())
|
|
|
|
return i;
|
|
|
|
}
|
2024-08-07 01:35:50 +02:00
|
|
|
return (dwelling - DWELL_FIRST) / (GameConstants::CREATURES_PER_TOWN - 1);
|
2024-08-05 23:51:07 +02:00
|
|
|
}
|
2024-08-05 23:03:19 +02:00
|
|
|
|
2024-08-21 21:24:06 +02:00
|
|
|
static void advanceDwelling(BuildingIDBase & dwelling)
|
|
|
|
{
|
|
|
|
if(dwelling != BuildingIDBase::DWELL_LVL_8)
|
|
|
|
dwelling.advance(GameConstants::CREATURES_PER_TOWN - 1);
|
|
|
|
else
|
|
|
|
dwelling.advance(1);
|
|
|
|
}
|
|
|
|
|
2023-10-19 16:19:09 +02:00
|
|
|
bool IsSpecialOrGrail() const
|
|
|
|
{
|
|
|
|
return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE BuildingID : public StaticIdentifierWithEnum<BuildingID, BuildingIDBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifierWithEnum<BuildingID, BuildingIDBase>::StaticIdentifierWithEnum;
|
2023-11-08 17:35:17 +02:00
|
|
|
|
2023-11-08 19:49:42 +02:00
|
|
|
static BuildingID HALL_LEVEL(unsigned int level)
|
2023-11-08 17:35:17 +02:00
|
|
|
{
|
|
|
|
assert(level < 4);
|
2023-11-08 18:50:37 +02:00
|
|
|
return BuildingID(Type::VILLAGE_HALL + level);
|
2023-11-08 17:35:17 +02:00
|
|
|
}
|
2023-11-08 19:49:42 +02:00
|
|
|
static BuildingID FORT_LEVEL(unsigned int level)
|
2023-11-08 17:35:17 +02:00
|
|
|
{
|
|
|
|
assert(level < 3);
|
2024-02-05 21:07:50 +02:00
|
|
|
return BuildingID(Type::FORT + level);
|
2023-11-08 17:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string encode(int32_t index);
|
|
|
|
static si32 decode(const std::string & identifier);
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-10-24 16:11:25 +02:00
|
|
|
class MapObjectBaseID : public IdentifierBase
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
NO_OBJ = -1,
|
|
|
|
ALTAR_OF_SACRIFICE [[deprecated]] = 2,
|
|
|
|
ANCHOR_POINT = 3,
|
|
|
|
ARENA = 4,
|
|
|
|
ARTIFACT = 5,
|
|
|
|
PANDORAS_BOX = 6,
|
|
|
|
BLACK_MARKET [[deprecated]] = 7,
|
|
|
|
BOAT = 8,
|
|
|
|
BORDERGUARD = 9,
|
|
|
|
KEYMASTER = 10,
|
|
|
|
BUOY = 11,
|
|
|
|
CAMPFIRE = 12,
|
|
|
|
CARTOGRAPHER = 13,
|
|
|
|
SWAN_POND = 14,
|
|
|
|
COVER_OF_DARKNESS = 15,
|
|
|
|
CREATURE_BANK = 16,
|
|
|
|
CREATURE_GENERATOR1 = 17,
|
|
|
|
CREATURE_GENERATOR2 = 18,
|
|
|
|
CREATURE_GENERATOR3 = 19,
|
|
|
|
CREATURE_GENERATOR4 = 20,
|
|
|
|
CURSED_GROUND1 = 21,
|
|
|
|
CORPSE = 22,
|
|
|
|
MARLETTO_TOWER = 23,
|
|
|
|
DERELICT_SHIP = 24,
|
|
|
|
DRAGON_UTOPIA = 25,
|
|
|
|
EVENT = 26,
|
|
|
|
EYE_OF_MAGI = 27,
|
|
|
|
FAERIE_RING = 28,
|
|
|
|
FLOTSAM = 29,
|
|
|
|
FOUNTAIN_OF_FORTUNE = 30,
|
|
|
|
FOUNTAIN_OF_YOUTH = 31,
|
|
|
|
GARDEN_OF_REVELATION = 32,
|
|
|
|
GARRISON = 33,
|
|
|
|
HERO = 34,
|
|
|
|
HILL_FORT = 35,
|
|
|
|
GRAIL = 36,
|
|
|
|
HUT_OF_MAGI = 37,
|
|
|
|
IDOL_OF_FORTUNE = 38,
|
|
|
|
LEAN_TO = 39,
|
|
|
|
LIBRARY_OF_ENLIGHTENMENT = 41,
|
|
|
|
LIGHTHOUSE = 42,
|
|
|
|
MONOLITH_ONE_WAY_ENTRANCE = 43,
|
|
|
|
MONOLITH_ONE_WAY_EXIT = 44,
|
|
|
|
MONOLITH_TWO_WAY = 45,
|
|
|
|
MAGIC_PLAINS1 = 46,
|
|
|
|
SCHOOL_OF_MAGIC = 47,
|
|
|
|
MAGIC_SPRING = 48,
|
|
|
|
MAGIC_WELL = 49,
|
|
|
|
MARKET_OF_TIME = 50,
|
|
|
|
MERCENARY_CAMP = 51,
|
|
|
|
MERMAID = 52,
|
|
|
|
MINE = 53,
|
|
|
|
MONSTER = 54,
|
|
|
|
MYSTICAL_GARDEN = 55,
|
|
|
|
OASIS = 56,
|
|
|
|
OBELISK = 57,
|
|
|
|
REDWOOD_OBSERVATORY = 58,
|
|
|
|
OCEAN_BOTTLE = 59,
|
|
|
|
PILLAR_OF_FIRE = 60,
|
|
|
|
STAR_AXIS = 61,
|
|
|
|
PRISON = 62,
|
|
|
|
PYRAMID = 63,//subtype 0
|
|
|
|
WOG_OBJECT = 63,//subtype > 0
|
|
|
|
RALLY_FLAG = 64,
|
|
|
|
RANDOM_ART = 65,
|
|
|
|
RANDOM_TREASURE_ART = 66,
|
|
|
|
RANDOM_MINOR_ART = 67,
|
|
|
|
RANDOM_MAJOR_ART = 68,
|
|
|
|
RANDOM_RELIC_ART = 69,
|
|
|
|
RANDOM_HERO = 70,
|
|
|
|
RANDOM_MONSTER = 71,
|
|
|
|
RANDOM_MONSTER_L1 = 72,
|
|
|
|
RANDOM_MONSTER_L2 = 73,
|
|
|
|
RANDOM_MONSTER_L3 = 74,
|
|
|
|
RANDOM_MONSTER_L4 = 75,
|
|
|
|
RANDOM_RESOURCE = 76,
|
|
|
|
RANDOM_TOWN = 77,
|
|
|
|
REFUGEE_CAMP = 78,
|
|
|
|
RESOURCE = 79,
|
|
|
|
SANCTUARY = 80,
|
|
|
|
SCHOLAR = 81,
|
|
|
|
SEA_CHEST = 82,
|
|
|
|
SEER_HUT = 83,
|
|
|
|
CRYPT = 84,
|
|
|
|
SHIPWRECK = 85,
|
|
|
|
SHIPWRECK_SURVIVOR = 86,
|
|
|
|
SHIPYARD = 87,
|
|
|
|
SHRINE_OF_MAGIC_INCANTATION = 88,
|
|
|
|
SHRINE_OF_MAGIC_GESTURE = 89,
|
|
|
|
SHRINE_OF_MAGIC_THOUGHT = 90,
|
|
|
|
SIGN = 91,
|
|
|
|
SIRENS = 92,
|
|
|
|
SPELL_SCROLL = 93,
|
|
|
|
STABLES = 94,
|
|
|
|
TAVERN = 95,
|
|
|
|
TEMPLE = 96,
|
|
|
|
DEN_OF_THIEVES = 97,
|
|
|
|
TOWN = 98,
|
|
|
|
TRADING_POST [[deprecated]] = 99,
|
|
|
|
LEARNING_STONE = 100,
|
|
|
|
TREASURE_CHEST = 101,
|
|
|
|
TREE_OF_KNOWLEDGE = 102,
|
|
|
|
SUBTERRANEAN_GATE = 103,
|
|
|
|
UNIVERSITY [[deprecated]] = 104,
|
|
|
|
WAGON = 105,
|
|
|
|
WAR_MACHINE_FACTORY = 106,
|
|
|
|
SCHOOL_OF_WAR = 107,
|
|
|
|
WARRIORS_TOMB = 108,
|
|
|
|
WATER_WHEEL = 109,
|
|
|
|
WATERING_HOLE = 110,
|
|
|
|
WHIRLPOOL = 111,
|
|
|
|
WINDMILL = 112,
|
|
|
|
WITCH_HUT = 113,
|
2024-04-04 21:39:01 +02:00
|
|
|
BRUSH = 114, // TODO: How does it look like?
|
|
|
|
BUSH = 115,
|
|
|
|
CACTUS = 116,
|
|
|
|
CANYON = 117,
|
|
|
|
CRATER = 118,
|
|
|
|
DEAD_VEGETATION = 119,
|
|
|
|
FLOWERS = 120,
|
|
|
|
FROZEN_LAKE = 121,
|
|
|
|
HEDGE = 122,
|
|
|
|
HILL = 123,
|
2023-10-19 16:19:09 +02:00
|
|
|
HOLE = 124,
|
2024-04-04 21:39:01 +02:00
|
|
|
KELP = 125,
|
|
|
|
LAKE = 126,
|
|
|
|
LAVA_FLOW = 127,
|
|
|
|
LAVA_LAKE = 128,
|
|
|
|
MUSHROOMS = 129,
|
|
|
|
LOG = 130,
|
|
|
|
MANDRAKE = 131,
|
|
|
|
MOSS = 132,
|
|
|
|
MOUND = 133,
|
|
|
|
MOUNTAIN = 134,
|
|
|
|
OAK_TREES = 135,
|
|
|
|
OUTCROPPING = 136,
|
|
|
|
PINE_TREES = 137,
|
|
|
|
PLANT = 138,
|
2024-04-08 12:50:41 +02:00
|
|
|
RIVER_DELTA = 143,
|
2024-04-04 21:39:01 +02:00
|
|
|
ROCK = 147,
|
|
|
|
SAND_DUNE = 148,
|
|
|
|
SAND_PIT = 149,
|
|
|
|
SHRUB = 150,
|
|
|
|
SKULL = 151,
|
|
|
|
STALAGMITE = 152,
|
|
|
|
STUMP = 153,
|
|
|
|
TAR_PIT = 154,
|
|
|
|
TREES = 155,
|
|
|
|
VINE = 156,
|
|
|
|
VOLCANIC_VENT = 157,
|
|
|
|
VOLCANO = 158,
|
|
|
|
WILLOW_TREES = 159,
|
|
|
|
YUCCA_TREES = 160,
|
|
|
|
REEF = 161,
|
2023-10-19 16:19:09 +02:00
|
|
|
RANDOM_MONSTER_L5 = 162,
|
|
|
|
RANDOM_MONSTER_L6 = 163,
|
|
|
|
RANDOM_MONSTER_L7 = 164,
|
|
|
|
BORDER_GATE = 212,
|
|
|
|
FREELANCERS_GUILD [[deprecated]] = 213,
|
|
|
|
HERO_PLACEHOLDER = 214,
|
|
|
|
QUEST_GUARD = 215,
|
|
|
|
RANDOM_DWELLING = 216,
|
|
|
|
RANDOM_DWELLING_LVL = 217, //subtype = creature level
|
|
|
|
RANDOM_DWELLING_FACTION = 218, //subtype = faction
|
|
|
|
GARRISON2 = 219,
|
|
|
|
ABANDONED_MINE = 220,
|
|
|
|
TRADING_POST_SNOW [[deprecated]] = 221,
|
|
|
|
CLOVER_FIELD = 222,
|
|
|
|
CURSED_GROUND2 = 223,
|
|
|
|
EVIL_FOG = 224,
|
|
|
|
FAVORABLE_WINDS = 225,
|
|
|
|
FIERY_FIELDS = 226,
|
|
|
|
HOLY_GROUNDS = 227,
|
|
|
|
LUCID_POOLS = 228,
|
|
|
|
MAGIC_CLOUDS = 229,
|
|
|
|
MAGIC_PLAINS2 = 230,
|
|
|
|
ROCKLANDS = 231,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE MapObjectID : public EntityIdentifierWithEnum<MapObjectID, MapObjectBaseID>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<MapObjectID, MapObjectBaseID>::EntityIdentifierWithEnum;
|
2023-10-22 17:36:41 +02:00
|
|
|
|
|
|
|
static std::string encode(int32_t index);
|
|
|
|
static si32 decode(const std::string & identifier);
|
2023-11-05 19:13:18 +02:00
|
|
|
|
|
|
|
// TODO: Remove
|
|
|
|
constexpr operator int32_t () const
|
|
|
|
{
|
|
|
|
return num;
|
|
|
|
}
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 21:18:34 +02:00
|
|
|
class DLL_LINKAGE MapObjectSubID : public Identifier<MapObjectSubID>
|
2023-10-24 16:11:25 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
constexpr MapObjectSubID(const IdentifierBase & value):
|
2023-11-17 21:18:34 +02:00
|
|
|
Identifier<MapObjectSubID>(value.getNum())
|
2023-10-24 16:11:25 +02:00
|
|
|
{}
|
2023-10-25 12:50:11 +02:00
|
|
|
constexpr MapObjectSubID(int32_t value = -1):
|
2023-11-17 21:18:34 +02:00
|
|
|
Identifier<MapObjectSubID>(value)
|
2023-10-24 16:11:25 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
MapObjectSubID & operator =(int32_t value)
|
|
|
|
{
|
|
|
|
this->num = value;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
MapObjectSubID & operator =(const IdentifierBase & value)
|
|
|
|
{
|
|
|
|
this->num = value.getNum();
|
|
|
|
return *this;
|
|
|
|
}
|
2023-11-05 19:13:18 +02:00
|
|
|
|
2023-11-17 21:18:34 +02:00
|
|
|
static si32 decode(MapObjectID primaryID, const std::string & identifier);
|
|
|
|
static std::string encode(MapObjectID primaryID, si32 index);
|
2023-11-17 00:48:55 +02:00
|
|
|
|
2023-11-05 19:13:18 +02:00
|
|
|
// TODO: Remove
|
|
|
|
constexpr operator int32_t () const
|
|
|
|
{
|
|
|
|
return num;
|
|
|
|
}
|
2023-11-17 21:18:34 +02:00
|
|
|
|
|
|
|
template <typename Handler>
|
2024-01-20 20:34:51 +02:00
|
|
|
void serializeIdentifier(Handler &h, const MapObjectID & primaryID)
|
2023-11-17 21:18:34 +02:00
|
|
|
{
|
|
|
|
std::string secondaryStringID;
|
|
|
|
|
|
|
|
if (h.saving)
|
|
|
|
secondaryStringID = encode(primaryID, num);
|
|
|
|
|
|
|
|
h & secondaryStringID;
|
|
|
|
|
|
|
|
if (!h.saving)
|
|
|
|
num = decode(primaryID, secondaryStringID);
|
|
|
|
}
|
2023-10-24 16:11:25 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE RoadId : public EntityIdentifier<RoadId>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<RoadId>::EntityIdentifier;
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
static const RoadId NO_ROAD;
|
|
|
|
static const RoadId DIRT_ROAD;
|
|
|
|
static const RoadId GRAVEL_ROAD;
|
|
|
|
static const RoadId COBBLESTONE_ROAD;
|
2023-11-04 18:22:27 +02:00
|
|
|
|
|
|
|
const RoadType * toEntity(const Services * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE RiverId : public EntityIdentifier<RiverId>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<RiverId>::EntityIdentifier;
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
static const RiverId NO_RIVER;
|
|
|
|
static const RiverId WATER_RIVER;
|
|
|
|
static const RiverId ICY_RIVER;
|
|
|
|
static const RiverId MUD_RIVER;
|
|
|
|
static const RiverId LAVA_RIVER;
|
2023-11-04 18:22:27 +02:00
|
|
|
|
|
|
|
const RiverType * toEntity(const Services * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE EPathfindingLayerBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type : int32_t
|
|
|
|
{
|
|
|
|
LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS, WRONG, AUTO
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class EPathfindingLayer : public StaticIdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>::StaticIdentifierWithEnum;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ArtifactPositionBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TRANSITION_POS = -3,
|
|
|
|
FIRST_AVAILABLE = -2,
|
|
|
|
PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
|
2023-07-24 18:09:17 +02:00
|
|
|
|
|
|
|
// Hero
|
2023-10-19 16:19:09 +02:00
|
|
|
HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
|
|
|
|
RIGHT_RING, LEFT_RING, FEET, //8
|
|
|
|
MISC1, MISC2, MISC3, MISC4, //12
|
|
|
|
MACH1, MACH2, MACH3, MACH4, //16
|
|
|
|
SPELLBOOK, MISC5, //18
|
2023-07-24 18:09:17 +02:00
|
|
|
BACKPACK_START = 19,
|
|
|
|
|
|
|
|
// Creatures
|
2023-10-19 16:19:09 +02:00
|
|
|
CREATURE_SLOT = 0,
|
2023-07-24 18:09:17 +02:00
|
|
|
|
|
|
|
// Commander
|
2024-01-12 23:57:19 +02:00
|
|
|
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6,
|
|
|
|
|
|
|
|
// Altar
|
|
|
|
ALTAR = BACKPACK_START
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-07-24 18:09:17 +02:00
|
|
|
static_assert(MISC5 < BACKPACK_START, "incorrect number of artifact slots");
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
DLL_LINKAGE static si32 decode(const std::string & identifier);
|
|
|
|
DLL_LINKAGE static std::string encode(const si32 index);
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class ArtifactPosition : public StaticIdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::StaticIdentifierWithEnum;
|
2023-11-05 18:58:07 +02:00
|
|
|
|
|
|
|
// TODO: Remove
|
|
|
|
constexpr operator int32_t () const
|
|
|
|
{
|
|
|
|
return num;
|
|
|
|
}
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ArtifactIDBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
NONE = -1,
|
|
|
|
SPELLBOOK = 0,
|
|
|
|
SPELL_SCROLL = 1,
|
|
|
|
GRAIL = 2,
|
|
|
|
CATAPULT = 3,
|
|
|
|
BALLISTA = 4,
|
|
|
|
AMMO_CART = 5,
|
|
|
|
FIRST_AID_TENT = 6,
|
|
|
|
VIAL_OF_DRAGON_BLOOD = 127,
|
|
|
|
ARMAGEDDONS_BLADE = 128,
|
2024-01-31 12:42:02 +02:00
|
|
|
ANGELIC_ALLIANCE = 129,
|
2023-10-19 16:19:09 +02:00
|
|
|
TITANS_THUNDER = 135,
|
|
|
|
ART_SELECTION = 144,
|
|
|
|
ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
|
|
|
|
};
|
|
|
|
|
|
|
|
DLL_LINKAGE const CArtifact * toArtifact() const;
|
2023-11-04 17:04:53 +02:00
|
|
|
DLL_LINKAGE const Artifact * toEntity(const Services * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class ArtifactID : public EntityIdentifierWithEnum<ArtifactID, ArtifactIDBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<ArtifactID, ArtifactIDBase>::EntityIdentifierWithEnum;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
///json serialization helpers
|
|
|
|
DLL_LINKAGE static si32 decode(const std::string & identifier);
|
|
|
|
DLL_LINKAGE static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
|
|
|
};
|
|
|
|
|
|
|
|
class CreatureIDBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
NONE = -1,
|
|
|
|
ARCHER = 2, // for debug / fallback
|
|
|
|
IMP = 42, // for Deity of Fire
|
2023-11-02 22:01:49 +02:00
|
|
|
FAMILIAR = 43, // for Deity of Fire
|
2023-10-19 16:19:09 +02:00
|
|
|
SKELETON = 56, // for Skeleton Transformer
|
|
|
|
BONE_DRAGON = 68, // for Skeleton Transformer
|
|
|
|
TROGLODYTES = 70, // for Abandoned Mine
|
|
|
|
MEDUSA = 76, // for Siege UI workaround
|
|
|
|
HYDRA = 110, // for Skeleton Transformer
|
|
|
|
CHAOS_HYDRA = 111, // for Skeleton Transformer
|
|
|
|
AIR_ELEMENTAL = 112, // for tests
|
|
|
|
FIRE_ELEMENTAL = 114, // for tests
|
|
|
|
PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
|
|
|
|
MAGIC_ELEMENTAL = 121, // for hardcoded ability
|
2023-11-05 18:58:07 +02:00
|
|
|
AZURE_DRAGON = 132,
|
2023-10-19 16:19:09 +02:00
|
|
|
CATAPULT = 145,
|
|
|
|
BALLISTA = 146,
|
|
|
|
FIRST_AID_TENT = 147,
|
|
|
|
AMMO_CART = 148,
|
|
|
|
ARROW_TOWERS = 149
|
|
|
|
};
|
|
|
|
|
|
|
|
DLL_LINKAGE const CCreature * toCreature() const;
|
2023-11-04 17:04:53 +02:00
|
|
|
DLL_LINKAGE const Creature * toEntity(const Services * services) const;
|
2023-11-02 18:45:46 +02:00
|
|
|
DLL_LINKAGE const Creature * toEntity(const CreatureService * creatures) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE CreatureID : public EntityIdentifierWithEnum<CreatureID, CreatureIDBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<CreatureID, CreatureIDBase>::EntityIdentifierWithEnum;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
///json serialization helpers
|
2023-10-22 17:36:41 +02:00
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
static std::string entityType();
|
|
|
|
};
|
|
|
|
|
2023-10-22 17:36:41 +02:00
|
|
|
class DLL_LINKAGE SpellIDBase : public IdentifierBase
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
// Special ID's
|
|
|
|
SPELLBOOK_PRESET = -3,
|
|
|
|
PRESET = -2,
|
|
|
|
NONE = -1,
|
|
|
|
|
|
|
|
// Adventure map spells
|
|
|
|
SUMMON_BOAT = 0,
|
|
|
|
SCUTTLE_BOAT = 1,
|
|
|
|
VISIONS = 2,
|
|
|
|
VIEW_EARTH = 3,
|
|
|
|
DISGUISE = 4,
|
|
|
|
VIEW_AIR = 5,
|
|
|
|
FLY = 6,
|
|
|
|
WATER_WALK = 7,
|
|
|
|
DIMENSION_DOOR = 8,
|
|
|
|
TOWN_PORTAL = 9,
|
|
|
|
|
2023-11-10 16:11:35 +02:00
|
|
|
// Combat spells
|
2023-10-19 16:19:09 +02:00
|
|
|
QUICKSAND = 10,
|
|
|
|
LAND_MINE = 11,
|
|
|
|
FORCE_FIELD = 12,
|
|
|
|
FIRE_WALL = 13,
|
|
|
|
EARTHQUAKE = 14,
|
|
|
|
MAGIC_ARROW = 15,
|
|
|
|
ICE_BOLT = 16,
|
|
|
|
LIGHTNING_BOLT = 17,
|
|
|
|
IMPLOSION = 18,
|
|
|
|
CHAIN_LIGHTNING = 19,
|
|
|
|
FROST_RING = 20,
|
|
|
|
FIREBALL = 21,
|
|
|
|
INFERNO = 22,
|
|
|
|
METEOR_SHOWER = 23,
|
|
|
|
DEATH_RIPPLE = 24,
|
|
|
|
DESTROY_UNDEAD = 25,
|
|
|
|
ARMAGEDDON = 26,
|
|
|
|
SHIELD = 27,
|
|
|
|
AIR_SHIELD = 28,
|
|
|
|
FIRE_SHIELD = 29,
|
|
|
|
PROTECTION_FROM_AIR = 30,
|
|
|
|
PROTECTION_FROM_FIRE = 31,
|
|
|
|
PROTECTION_FROM_WATER = 32,
|
|
|
|
PROTECTION_FROM_EARTH = 33,
|
|
|
|
ANTI_MAGIC = 34,
|
|
|
|
DISPEL = 35,
|
|
|
|
MAGIC_MIRROR = 36,
|
|
|
|
CURE = 37,
|
|
|
|
RESURRECTION = 38,
|
|
|
|
ANIMATE_DEAD = 39,
|
|
|
|
SACRIFICE = 40,
|
|
|
|
BLESS = 41,
|
|
|
|
CURSE = 42,
|
|
|
|
BLOODLUST = 43,
|
|
|
|
PRECISION = 44,
|
|
|
|
WEAKNESS = 45,
|
|
|
|
STONE_SKIN = 46,
|
|
|
|
DISRUPTING_RAY = 47,
|
|
|
|
PRAYER = 48,
|
|
|
|
MIRTH = 49,
|
|
|
|
SORROW = 50,
|
|
|
|
FORTUNE = 51,
|
|
|
|
MISFORTUNE = 52,
|
|
|
|
HASTE = 53,
|
|
|
|
SLOW = 54,
|
|
|
|
SLAYER = 55,
|
|
|
|
FRENZY = 56,
|
|
|
|
TITANS_LIGHTNING_BOLT = 57,
|
|
|
|
COUNTERSTRIKE = 58,
|
|
|
|
BERSERK = 59,
|
|
|
|
HYPNOTIZE = 60,
|
|
|
|
FORGETFULNESS = 61,
|
|
|
|
BLIND = 62,
|
|
|
|
TELEPORT = 63,
|
|
|
|
REMOVE_OBSTACLE = 64,
|
|
|
|
CLONE = 65,
|
|
|
|
SUMMON_FIRE_ELEMENTAL = 66,
|
|
|
|
SUMMON_EARTH_ELEMENTAL = 67,
|
|
|
|
SUMMON_WATER_ELEMENTAL = 68,
|
|
|
|
SUMMON_AIR_ELEMENTAL = 69,
|
|
|
|
|
|
|
|
// Creature abilities
|
|
|
|
STONE_GAZE = 70,
|
|
|
|
POISON = 71,
|
|
|
|
BIND = 72,
|
|
|
|
DISEASE = 73,
|
|
|
|
PARALYZE = 74,
|
|
|
|
AGE = 75,
|
|
|
|
DEATH_CLOUD = 76,
|
|
|
|
THUNDERBOLT = 77,
|
|
|
|
DISPEL_HELPFUL_SPELLS = 78,
|
|
|
|
DEATH_STARE = 79,
|
|
|
|
ACID_BREATH_DEFENSE = 80,
|
|
|
|
ACID_BREATH_DAMAGE = 81,
|
|
|
|
|
|
|
|
// Special ID's
|
|
|
|
FIRST_NON_SPELL = 70,
|
|
|
|
AFTER_LAST = 82
|
|
|
|
};
|
|
|
|
|
2023-10-22 17:36:41 +02:00
|
|
|
const CSpell * toSpell() const; //deprecated
|
2023-11-04 17:04:53 +02:00
|
|
|
const spells::Spell * toEntity(const Services * service) const;
|
2023-11-02 18:45:46 +02:00
|
|
|
const spells::Spell * toEntity(const spells::Service * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE SpellID : public EntityIdentifierWithEnum<SpellID, SpellIDBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<SpellID, SpellIDBase>::EntityIdentifierWithEnum;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
///json serialization helpers
|
2023-10-22 17:36:41 +02:00
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
static std::string entityType();
|
|
|
|
};
|
|
|
|
|
|
|
|
class BattleFieldInfo;
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE BattleField : public EntityIdentifier<BattleField>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<BattleField>::EntityIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2023-10-22 17:36:41 +02:00
|
|
|
static const BattleField NONE;
|
|
|
|
const BattleFieldInfo * getInfo() const;
|
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE BoatId : public EntityIdentifier<BoatId>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<BoatId>::EntityIdentifier;
|
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
static const BoatId NONE;
|
|
|
|
static const BoatId NECROPOLIS;
|
|
|
|
static const BoatId CASTLE;
|
|
|
|
static const BoatId FORTRESS;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TerrainIdBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type : int32_t
|
|
|
|
{
|
|
|
|
NATIVE_TERRAIN = -4,
|
|
|
|
ANY_TERRAIN = -3,
|
|
|
|
NONE = -1,
|
|
|
|
FIRST_REGULAR_TERRAIN = 0,
|
|
|
|
DIRT = 0,
|
|
|
|
SAND,
|
|
|
|
GRASS,
|
|
|
|
SNOW,
|
|
|
|
SWAMP,
|
|
|
|
ROUGH,
|
|
|
|
SUBTERRANEAN,
|
|
|
|
LAVA,
|
|
|
|
WATER,
|
|
|
|
ROCK,
|
|
|
|
ORIGINAL_REGULAR_TERRAIN_COUNT = ROCK
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE TerrainId : public EntityIdentifierWithEnum<TerrainId, TerrainIdBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifierWithEnum<TerrainId, TerrainIdBase>::EntityIdentifierWithEnum;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
2023-10-19 16:19:09 +02:00
|
|
|
static std::string entityType();
|
2023-11-04 18:22:27 +02:00
|
|
|
const TerrainType * toEntity(const Services * service) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ObstacleInfo;
|
2023-11-17 00:48:55 +02:00
|
|
|
class Obstacle : public EntityIdentifier<Obstacle>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using EntityIdentifier<Obstacle>::EntityIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
DLL_LINKAGE const ObstacleInfo * getInfo() const;
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE SpellSchool : public StaticIdentifier<SpellSchool>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<SpellSchool>::StaticIdentifier;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
static const SpellSchool ANY;
|
|
|
|
static const SpellSchool AIR;
|
|
|
|
static const SpellSchool FIRE;
|
|
|
|
static const SpellSchool WATER;
|
|
|
|
static const SpellSchool EARTH;
|
2023-10-22 17:36:41 +02:00
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class GameResIDBase : public IdentifierBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type : int32_t
|
|
|
|
{
|
|
|
|
WOOD = 0,
|
|
|
|
MERCURY,
|
|
|
|
ORE,
|
|
|
|
SULFUR,
|
|
|
|
CRYSTAL,
|
|
|
|
GEMS,
|
|
|
|
GOLD,
|
|
|
|
MITHRIL,
|
|
|
|
COUNT,
|
|
|
|
|
|
|
|
WOOD_AND_ORE = 127, // special case for town bonus resource
|
2023-10-22 17:36:41 +02:00
|
|
|
NONE = -1
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE GameResID : public StaticIdentifierWithEnum<GameResID, GameResIDBase>
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifierWithEnum<GameResID, GameResIDBase>::StaticIdentifierWithEnum;
|
2023-10-22 17:36:41 +02:00
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
static std::string entityType();
|
2023-10-31 11:09:56 +02:00
|
|
|
|
|
|
|
static const std::array<GameResID, 7> & ALL_RESOURCES();
|
2023-10-22 17:36:41 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 22:12:11 +02:00
|
|
|
class DLL_LINKAGE BuildingTypeUniqueID : public Identifier<BuildingTypeUniqueID>
|
2023-10-22 17:36:41 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
BuildingTypeUniqueID(FactionID faction, BuildingID building );
|
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(const si32 index);
|
|
|
|
|
|
|
|
BuildingID getBuilding() const;
|
|
|
|
FactionID getFaction() const;
|
|
|
|
|
2023-11-17 22:12:11 +02:00
|
|
|
using Identifier<BuildingTypeUniqueID>::Identifier;
|
|
|
|
|
|
|
|
template <typename Handler>
|
2024-01-20 20:34:51 +02:00
|
|
|
void serialize(Handler & h)
|
2023-11-17 22:12:11 +02:00
|
|
|
{
|
|
|
|
FactionID faction = getFaction();
|
|
|
|
BuildingID building = getBuilding();
|
|
|
|
|
|
|
|
h & faction;
|
|
|
|
h & building;
|
|
|
|
|
|
|
|
if (!h.saving)
|
|
|
|
*this = BuildingTypeUniqueID(faction, building);
|
|
|
|
}
|
2023-10-22 17:36:41 +02:00
|
|
|
};
|
|
|
|
|
2023-11-17 00:48:55 +02:00
|
|
|
class DLL_LINKAGE CampaignScenarioID : public StaticIdentifier<CampaignScenarioID>
|
2023-10-22 17:36:41 +02:00
|
|
|
{
|
|
|
|
public:
|
2023-11-17 00:48:55 +02:00
|
|
|
using StaticIdentifier<CampaignScenarioID>::StaticIdentifier;
|
2023-10-22 17:36:41 +02:00
|
|
|
|
|
|
|
static si32 decode(const std::string & identifier);
|
|
|
|
static std::string encode(int32_t index);
|
|
|
|
|
|
|
|
static const CampaignScenarioID NONE;
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Deprecated
|
|
|
|
// TODO: remove
|
2023-10-24 16:11:25 +02:00
|
|
|
using Obj = MapObjectID;
|
2023-10-19 16:19:09 +02:00
|
|
|
using ETownType = FactionID;
|
|
|
|
using EGameResID = GameResID;
|
|
|
|
using River = RiverId;
|
|
|
|
using Road = RoadId;
|
|
|
|
using ETerrainId = TerrainId;
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|