diff --git a/lib/rmg/ObjectManager.cpp b/lib/rmg/ObjectManager.cpp index ac90cf4fa..6a1badedd 100644 --- a/lib/rmg/ObjectManager.cpp +++ b/lib/rmg/ObjectManager.cpp @@ -135,6 +135,7 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg { auto & guardedArea = obj.instances().back()->getAccessibleArea(); accessibleArea.intersect(guardedArea); + accessibleArea.add(obj.instances().back()->getPosition(true)); } auto path = zone.searchPath(accessibleArea, onlyStraight, [&obj, isGuarded](const int3 & t) @@ -145,6 +146,10 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg auto & unguardedArea = obj.getAccessibleArea(isGuarded); if(unguardedArea.contains(t) && !guardedArea.contains(t)) return false; + + //guard position is always target + if(obj.instances().back()->getPosition(true) == t) + return true; } return !obj.getArea().contains(t); }); diff --git a/lib/rmg/ObstaclePlacer.cpp b/lib/rmg/ObstaclePlacer.cpp index 74e158889..9baa60917 100644 --- a/lib/rmg/ObstaclePlacer.cpp +++ b/lib/rmg/ObstaclePlacer.cpp @@ -88,7 +88,10 @@ void ObstaclePlacer::process() if(!possibleObstacles[i].first) continue; - for(auto & temp : possibleObstacles[i].second) + auto shuffledObstacles = possibleObstacles[i].second; + RandomGeneratorUtil::randomShuffle(shuffledObstacles, generator.rand); + + for(auto & temp : shuffledObstacles) { auto handler = VLC->objtypeh->getHandlerFor(temp.id, temp.subid); auto obj = handler->create(temp); diff --git a/lib/rmg/TreasurePlacer.cpp b/lib/rmg/TreasurePlacer.cpp index 22b8fe0ee..8a6d1df3e 100644 --- a/lib/rmg/TreasurePlacer.cpp +++ b/lib/rmg/TreasurePlacer.cpp @@ -722,7 +722,7 @@ void TreasurePlacer::createTreasures(ObjectManager & manager) if(areaToBlock.overlap(zone.freePaths()) || areaToBlock.overlap(manager.getVisitableArea())) return -1.f; - return 1.f; + return ti.getNearestObjectDistance(); }, guarded, false, false); } else