mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Treasure pile entrance/guard will always be aimed at the center of the zone.
This commit is contained in:
parent
2c1001f8e0
commit
edd46d87c1
@ -555,7 +555,6 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
|
||||
bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
|
||||
{
|
||||
|
||||
std::map<int3, CGObjectInstance *> treasures;
|
||||
std::set<int3> boundary;
|
||||
int3 guardPos;
|
||||
@ -652,7 +651,21 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
|
||||
placeObject(gen, treasure.second, treasure.first - treasure.second->getVisitableOffset());
|
||||
}
|
||||
|
||||
crunchPath (gen, pos, getPos(), id); //make sure pile is connected to the middle of zone
|
||||
//find object closest to zone center, then con nect it to the middle of the zone
|
||||
int3 zoneCenter = getPos();
|
||||
int3 closestTile = int3(-1,-1,-1);
|
||||
float minDistance = 1e10;
|
||||
for (auto treasure : treasures)
|
||||
{
|
||||
if (zoneCenter.dist2d(treasure.first) < minDistance)
|
||||
{
|
||||
closestTile = treasure.first;
|
||||
minDistance = zoneCenter.dist2d(treasure.first);
|
||||
}
|
||||
}
|
||||
assert (closestTile.valid());
|
||||
crunchPath (gen, closestTile, getPos(), id); //make sure pile is connected to the middle of zone
|
||||
|
||||
for (auto tile : boundary) //guard must be standing there
|
||||
{
|
||||
if (gen->isFree(tile)) //this tile could be already blocked, don't place a monster here
|
||||
|
Loading…
Reference in New Issue
Block a user