mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Merge pull request #152 from vcmi/feature/moatHexesConfig
Configurable moat hexes positions
This commit is contained in:
@@ -146,6 +146,8 @@
|
|||||||
"mageGuild" : 4,
|
"mageGuild" : 4,
|
||||||
"warMachine" : "ballista",
|
"warMachine" : "ballista",
|
||||||
"moatDamage" : 70,
|
"moatDamage" : 70,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"primaryResource": "ore",
|
"primaryResource": "ore",
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -151,6 +151,7 @@
|
|||||||
"primaryResource" : "mercury",
|
"primaryResource" : "mercury",
|
||||||
"warMachine" : "ballista",
|
"warMachine" : "ballista",
|
||||||
"moatDamage" : 70,
|
"moatDamage" : 70,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -146,6 +146,7 @@
|
|||||||
"primaryResource" : "sulfur",
|
"primaryResource" : "sulfur",
|
||||||
"warMachine" : "ballista",
|
"warMachine" : "ballista",
|
||||||
"moatDamage" : 90,
|
"moatDamage" : 90,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -144,9 +144,11 @@
|
|||||||
],
|
],
|
||||||
"horde" : [ 0, -1 ],
|
"horde" : [ 0, -1 ],
|
||||||
"mageGuild" : 3,
|
"mageGuild" : 3,
|
||||||
|
"primaryResource":"ore",
|
||||||
"warMachine" : "firstAidTent",
|
"warMachine" : "firstAidTent",
|
||||||
"moatDamage" : 90,
|
"moatDamage" : 90,
|
||||||
"primaryResource":"ore",
|
"moatHexes" : [ 10, 11, 27, 28, 43, 44, 60, 61, 76, 77, 94, 110, 111, 128, 129, 145, 146, 163, 164, 180, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
"mageGuild1": { "id" : 0 },
|
"mageGuild1": { "id" : 0 },
|
||||||
|
@@ -147,6 +147,7 @@
|
|||||||
"primaryResource" : "mercury",
|
"primaryResource" : "mercury",
|
||||||
"warMachine" : "ammoCart",
|
"warMachine" : "ammoCart",
|
||||||
"moatDamage" : 90,
|
"moatDamage" : 90,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -148,9 +148,10 @@
|
|||||||
],
|
],
|
||||||
"horde" : [ 0, -1 ],
|
"horde" : [ 0, -1 ],
|
||||||
"mageGuild" : 5,
|
"mageGuild" : 5,
|
||||||
|
"primaryResource": "ore",
|
||||||
"warMachine" : "firstAidTent",
|
"warMachine" : "firstAidTent",
|
||||||
"moatDamage" : 70,
|
"moatDamage" : 70,
|
||||||
"primaryResource": "ore",
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -151,6 +151,7 @@
|
|||||||
"primaryResource" : "crystal",
|
"primaryResource" : "crystal",
|
||||||
"warMachine" : "firstAidTent",
|
"warMachine" : "firstAidTent",
|
||||||
"moatDamage" : 70,
|
"moatDamage" : 70,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -145,6 +145,7 @@
|
|||||||
"mageGuild" : 3,
|
"mageGuild" : 3,
|
||||||
"warMachine" : "ammoCart",
|
"warMachine" : "ammoCart",
|
||||||
"moatDamage" : 70,
|
"moatDamage" : 70,
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -146,6 +146,7 @@
|
|||||||
"mageGuild" : 5,
|
"mageGuild" : 5,
|
||||||
"warMachine" : "ammoCart",
|
"warMachine" : "ammoCart",
|
||||||
"moatDamage" : 0, //TODO: minefield
|
"moatDamage" : 0, //TODO: minefield
|
||||||
|
"moatHexes" : [ 11, 28, 44, 61, 77, 111, 129, 146, 164, 181 ],
|
||||||
|
|
||||||
"buildings" :
|
"buildings" :
|
||||||
{
|
{
|
||||||
|
@@ -230,6 +230,11 @@
|
|||||||
"type":"number",
|
"type":"number",
|
||||||
"description": "Damage dealt to creature that entered town moat during siege"
|
"description": "Damage dealt to creature that entered town moat during siege"
|
||||||
},
|
},
|
||||||
|
"moatHexes": {
|
||||||
|
"type" : "array",
|
||||||
|
"description" : "Numbers of battlefield hexes affected by moat during siege",
|
||||||
|
"items" : { "type" : "number" }
|
||||||
|
},
|
||||||
"musicTheme": {
|
"musicTheme": {
|
||||||
"type":"string",
|
"type":"string",
|
||||||
"description": "Path to town music theme",
|
"description": "Path to town music theme",
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CObstacleInstance.h"
|
#include "CObstacleInstance.h"
|
||||||
#include "CHeroHandler.h"
|
#include "CHeroHandler.h"
|
||||||
|
#include "CTownHandler.h"
|
||||||
#include "VCMI_Lib.h"
|
#include "VCMI_Lib.h"
|
||||||
#include "spells/CSpellHandler.h"
|
#include "spells/CSpellHandler.h"
|
||||||
|
|
||||||
@@ -145,7 +146,5 @@ void SpellCreatedObstacle::battleTurnPassed()
|
|||||||
|
|
||||||
std::vector<BattleHex> MoatObstacle::getAffectedTiles() const
|
std::vector<BattleHex> MoatObstacle::getAffectedTiles() const
|
||||||
{
|
{
|
||||||
//rrr... need initializer lists
|
return VLC->townh->factions[ID]->town->moatHexes;
|
||||||
static const BattleHex moatHexes[] = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
|
|
||||||
return std::vector<BattleHex>(moatHexes, moatHexes + ARRAY_COUNT(moatHexes));
|
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "filesystem/Filesystem.h"
|
#include "filesystem/Filesystem.h"
|
||||||
#include "mapObjects/CObjectClassesHandler.h"
|
#include "mapObjects/CObjectClassesHandler.h"
|
||||||
#include "mapObjects/CObjectHandler.h"
|
#include "mapObjects/CObjectHandler.h"
|
||||||
|
#include "BattleHex.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CTownHandler.cpp, part of VCMI engine
|
* CTownHandler.cpp, part of VCMI engine
|
||||||
@@ -85,6 +86,12 @@ CTown::~CTown()
|
|||||||
str.dellNull();
|
str.dellNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<BattleHex> CTown::defaultMoatHexes()
|
||||||
|
{
|
||||||
|
static const std::vector<BattleHex> moatHexes = {11, 28, 44, 61, 77, 111, 129, 146, 164, 181};
|
||||||
|
return moatHexes;
|
||||||
|
}
|
||||||
|
|
||||||
CTownHandler::CTownHandler()
|
CTownHandler::CTownHandler()
|
||||||
{
|
{
|
||||||
VLC->townh = this;
|
VLC->townh = this;
|
||||||
@@ -542,7 +549,13 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
|
|||||||
|
|
||||||
town.moatDamage = source["moatDamage"].Float();
|
town.moatDamage = source["moatDamage"].Float();
|
||||||
|
|
||||||
|
// Compatability for <= 0.98f mods
|
||||||
|
if(source["moatHexes"].isNull())
|
||||||
|
{
|
||||||
|
town.moatHexes = CTown::defaultMoatHexes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
town.moatHexes = source["moatHexes"].convertTo<std::vector<BattleHex> >();
|
||||||
|
|
||||||
town.mageLevel = source["mageGuild"].Float();
|
town.mageLevel = source["mageGuild"].Float();
|
||||||
town.names = source["names"].convertTo<std::vector<std::string> >();
|
town.names = source["names"].convertTo<std::vector<std::string> >();
|
||||||
|
@@ -21,6 +21,7 @@ class CLegacyConfigParser;
|
|||||||
class JsonNode;
|
class JsonNode;
|
||||||
class CTown;
|
class CTown;
|
||||||
class CFaction;
|
class CFaction;
|
||||||
|
struct BattleHex;
|
||||||
|
|
||||||
/// a typical building encountered in every castle ;]
|
/// a typical building encountered in every castle ;]
|
||||||
/// this is structure available to both client and server
|
/// this is structure available to both client and server
|
||||||
@@ -136,6 +137,8 @@ class DLL_LINKAGE CTown
|
|||||||
public:
|
public:
|
||||||
CTown();
|
CTown();
|
||||||
~CTown();
|
~CTown();
|
||||||
|
// TODO: remove once save and mod compatability not needed
|
||||||
|
static std::vector<BattleHex> defaultMoatHexes();
|
||||||
|
|
||||||
CFaction * faction;
|
CFaction * faction;
|
||||||
|
|
||||||
@@ -156,6 +159,7 @@ public:
|
|||||||
ui16 primaryRes;
|
ui16 primaryRes;
|
||||||
ArtifactID warMachine;
|
ArtifactID warMachine;
|
||||||
si32 moatDamage;
|
si32 moatDamage;
|
||||||
|
std::vector<BattleHex> moatHexes;
|
||||||
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
|
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
|
||||||
// resulting chance = sqrt(town.chance * heroClass.chance)
|
// resulting chance = sqrt(town.chance * heroClass.chance)
|
||||||
ui32 defaultTavernChance;
|
ui32 defaultTavernChance;
|
||||||
@@ -205,7 +209,16 @@ public:
|
|||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel
|
h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel
|
||||||
& primaryRes & warMachine & clientInfo & moatDamage & defaultTavernChance;
|
& primaryRes & warMachine & clientInfo & moatDamage;
|
||||||
|
if(version >= 758)
|
||||||
|
{
|
||||||
|
h & moatHexes;
|
||||||
|
}
|
||||||
|
else if(!h.saving)
|
||||||
|
{
|
||||||
|
moatHexes = defaultMoatHexes();
|
||||||
|
}
|
||||||
|
h & defaultTavernChance;
|
||||||
|
|
||||||
auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building)
|
auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building)
|
||||||
{ return building.second == nullptr; };
|
{ return building.second == nullptr; };
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include "mapping/CCampaignHandler.h" //for CCampaignState
|
#include "mapping/CCampaignHandler.h" //for CCampaignState
|
||||||
#include "rmg/CMapGenerator.h" // for CMapGenOptions
|
#include "rmg/CMapGenerator.h" // for CMapGenOptions
|
||||||
|
|
||||||
const ui32 version = 757;
|
const ui32 version = 758;
|
||||||
const ui32 minSupportedVersion = 753;
|
const ui32 minSupportedVersion = 753;
|
||||||
|
|
||||||
class CISer;
|
class CISer;
|
||||||
|
Reference in New Issue
Block a user