diff --git a/config/rmg.json b/config/rmg.json index c992a7241..4e87de4be 100644 --- a/config/rmg.json +++ b/config/rmg.json @@ -104,13 +104,13 @@ { "type" : "playerStart", "size" : 3, "owner" : 2, "playerTowns" : { "castles" : 1 }, - "treaureLikeZone" : 1 + "treasureLikeZone" : 1 }, "3" : { "type" : "playerStart", "size" : 3, "owner" : 3, "playerTowns" : { "castles" : 1 }, - "treaureLikeZone" : 1 + "treasureLikeZone" : 1 }, "4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasure" : {"min" : 3000, "max": 10000} }, "5" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasureLikeZone" : 4}, diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 4f62b2d5f..e66601300 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -412,7 +412,7 @@ void CRmgTemplateZone::addRequiredObject(CGObjectInstance * obj, si32 strength) requiredObjects.push_back(std::make_pair(obj, strength)); } -void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength) +bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength) { //precalculate actual (randomized) monster strength based on this post //http://forum.vcmi.eu/viewtopic.php?p=12426#12426 @@ -430,7 +430,7 @@ void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength) strength = strength1 + strength2; if (strength < 2000) - return; //no guard at all + return false; //no guard at all CreatureID creId = CreatureID::NONE; int amount = 0; @@ -455,6 +455,7 @@ void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength) guard->putStack(SlotID(0), hlp); placeObject(gen, guard, pos); + return true; } bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos) @@ -903,7 +904,6 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object, if (gen->isPossible(pos)) { tiles.push_back(pos); - gen->setOccupied(pos, ETileType::BLOCKED); }; }); if ( ! tiles.size()) @@ -912,9 +912,16 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object, return false; } auto guard_tile = *RandomGeneratorUtil::nextItem(tiles, gen->rand); - gen->setOccupied (guard_tile, ETileType::USED); - addMonster (gen, guard_tile, str); + if (addMonster (gen, guard_tile, str)) //do not lace obstacles aroudn unguarded object + { + for (auto pos : tiles) + gen->setOccupied(pos, ETileType::BLOCKED); + + gen->setOccupied (guard_tile, ETileType::USED); + } + else + gen->setOccupied (guard_tile, ETileType::FREE); return true; } diff --git a/lib/rmg/CRmgTemplateZone.h b/lib/rmg/CRmgTemplateZone.h index d5217f78e..cea36608e 100644 --- a/lib/rmg/CRmgTemplateZone.h +++ b/lib/rmg/CRmgTemplateZone.h @@ -128,7 +128,7 @@ public: std::set getTileInfo () const; void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0); - void addMonster(CMapGenerator* gen, int3 &pos, si32 strength); + bool addMonster(CMapGenerator* gen, int3 &pos, si32 strength); bool createTreasurePile (CMapGenerator* gen, int3 &pos); bool fill(CMapGenerator* gen); void createBorder(CMapGenerator* gen);