mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Zone guard will cause object be placed as far away from it as possible in both zones.
This commit is contained in:
parent
6848a52ce1
commit
e37c35e439
@ -534,6 +534,7 @@ void CMapGenerator::createDirectConnections()
|
||||
{
|
||||
setOccupied(guardPos, ETileType::FREE); //just in case monster is too weak to spawn
|
||||
zoneA->addMonster(this, guardPos, connection.getGuardStrength(), false, true);
|
||||
zoneB->updateDistances(this, guardPos); //place next objects away from guard in both zones
|
||||
//zones can make paths only in their own area
|
||||
zoneA->crunchPath(this, guardPos, posA, true, zoneA->getFreePaths()); //make connection towards our zone center
|
||||
zoneB->crunchPath(this, guardPos, posB, true, zoneB->getFreePaths()); //make connection towards other zone center
|
||||
|
@ -2112,13 +2112,7 @@ void CRmgTemplateZone::placeObject(CMapGenerator* gen, CGObjectInstance* object,
|
||||
}
|
||||
}
|
||||
if (updateDistance)
|
||||
{
|
||||
for(auto tile : possibleTiles) //don't need to mark distance for not possible tiles
|
||||
{
|
||||
si32 d = pos.dist2dSQ(tile); //optimization, only relative distance is interesting
|
||||
gen->setNearestObjectDistance(tile, std::min<float>(d, gen->getNearestObjectDistance(tile)));
|
||||
}
|
||||
}
|
||||
updateDistances(gen, pos);
|
||||
|
||||
switch (object->ID)
|
||||
{
|
||||
@ -2138,6 +2132,15 @@ void CRmgTemplateZone::placeObject(CMapGenerator* gen, CGObjectInstance* object,
|
||||
}
|
||||
}
|
||||
|
||||
void CRmgTemplateZone::updateDistances(CMapGenerator* gen, const int3 & pos)
|
||||
{
|
||||
for (auto tile : possibleTiles) //don't need to mark distance for not possible tiles
|
||||
{
|
||||
ui32 d = pos.dist2dSQ(tile); //optimization, only relative distance is interesting
|
||||
gen->setNearestObjectDistance(tile, std::min<float>(d, gen->getNearestObjectDistance(tile)));
|
||||
}
|
||||
}
|
||||
|
||||
void CRmgTemplateZone::placeAndGuardObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos, si32 str, bool zoneGuard)
|
||||
{
|
||||
placeObject(gen, object, pos);
|
||||
|
@ -192,6 +192,7 @@ public:
|
||||
bool crunchPath(CMapGenerator* gen, const int3 &src, const int3 &dst, bool onlyStraight, std::set<int3>* clearedTiles = nullptr);
|
||||
bool connectPath(CMapGenerator* gen, const int3& src, bool onlyStraight);
|
||||
bool connectWithCenter(CMapGenerator* gen, const int3& src, bool onlyStraight);
|
||||
void updateDistances(CMapGenerator* gen, const int3 & pos);
|
||||
|
||||
std::vector<int3> getAccessibleOffsets (CMapGenerator* gen, CGObjectInstance* object);
|
||||
bool areAllTilesAvailable(CMapGenerator* gen, CGObjectInstance* obj, int3& tile, std::set<int3>& tilesBlockedByObject) const;
|
||||
|
Loading…
Reference in New Issue
Block a user