mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
@@ -239,7 +239,7 @@ void Zone::fractalize()
|
||||
|
||||
//Squared
|
||||
float minDistance = 9 * 9;
|
||||
float freeDistance = pos.z ? (10 * 10) : 6 * 6;
|
||||
float freeDistance = pos.z ? (10 * 10) : (9 * 9);
|
||||
float spanFactor = (pos.z ? 0.3f : 0.45f); //Narrower passages in the Underground
|
||||
float marginFactor = 1.0f;
|
||||
|
||||
@@ -258,15 +258,18 @@ void Zone::fractalize()
|
||||
}
|
||||
else //Scale with treasure density
|
||||
{
|
||||
if (treasureValue > 400)
|
||||
if (treasureValue > 250)
|
||||
{
|
||||
// A quater at max density
|
||||
marginFactor = (0.25f + ((std::max(0, (600 - treasureValue))) / (600.f - 400)) * 0.75f);
|
||||
// A quater at max density - means more free space
|
||||
marginFactor = (0.6f + ((std::max(0, (600 - treasureValue))) / (600.f - 250)) * 0.4f);
|
||||
|
||||
// Low value - dense obstacles
|
||||
spanFactor *= (0.6f + ((std::max(0, (600 - treasureValue))) / (600.f - 250)) * 0.4f);
|
||||
}
|
||||
else if (treasureValue < 100)
|
||||
{
|
||||
//Dense obstacles
|
||||
spanFactor *= (treasureValue / 100.f);
|
||||
spanFactor *= (0.5 + 0.5 * (treasureValue / 100.f));
|
||||
vstd::amax(spanFactor, 0.15f);
|
||||
}
|
||||
if (treasureDensity <= 10)
|
||||
@@ -334,8 +337,8 @@ void Zone::fractalize()
|
||||
}
|
||||
|
||||
Lock lock(areaMutex);
|
||||
//cut straight paths towards the center. A* is too slow for that.
|
||||
auto areas = connectedAreas(clearedTiles, false);
|
||||
//Connect with free areas
|
||||
auto areas = connectedAreas(clearedTiles, true);
|
||||
for(auto & area : areas)
|
||||
{
|
||||
if(dAreaFree.overlap(area))
|
||||
@@ -344,7 +347,7 @@ void Zone::fractalize()
|
||||
auto availableArea = dAreaPossible + dAreaFree;
|
||||
rmg::Path path(availableArea);
|
||||
path.connect(dAreaFree);
|
||||
auto res = path.search(area, false);
|
||||
auto res = path.search(area, true);
|
||||
if(res.getPathArea().empty())
|
||||
{
|
||||
dAreaPossible.subtract(area);
|
||||
|
@@ -872,22 +872,10 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
||||
|
||||
totalDensity += t->density;
|
||||
|
||||
const int DENSITY_CONSTANT = 300;
|
||||
const int DENSITY_CONSTANT = 400;
|
||||
size_t count = (size * t->density) / DENSITY_CONSTANT;
|
||||
|
||||
//Assure space for lesser treasures, if there are any left
|
||||
const int averageValue = (t->min + t->max) / 2;
|
||||
if (t != (treasureInfo.end() - 1))
|
||||
{
|
||||
if (averageValue > 10000)
|
||||
{
|
||||
//Will surely be guarded => larger piles => less space inbetween
|
||||
vstd::amin(count, size * (10.f / DENSITY_CONSTANT) / (std::sqrt((float)averageValue / 10000)));
|
||||
}
|
||||
}
|
||||
|
||||
//this is squared distance for optimization purposes
|
||||
const float minDistance = std::max<float>((125.f / totalDensity), 1.0f);
|
||||
const float minDistance = std::max<float>(std::sqrt(std::min<ui32>(t->min, 30000) / 10.0f / totalDensity), 1.0f);
|
||||
|
||||
size_t emergencyLoopFinish = 0;
|
||||
while(treasures.size() < count && emergencyLoopFinish < count)
|
||||
@@ -971,7 +959,7 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
||||
|
||||
if (path.valid())
|
||||
{
|
||||
//debug purposes
|
||||
#ifdef TREASURE_PLACER_LOG
|
||||
treasureArea.unite(rmgObject.getArea());
|
||||
if (guarded)
|
||||
{
|
||||
@@ -980,6 +968,7 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
||||
auto areaToBlock = rmgObject.getAccessibleArea(true) - guardedArea;
|
||||
treasureBlockArea.unite(areaToBlock);
|
||||
}
|
||||
#endif
|
||||
zone.connectPath(path);
|
||||
manager.placeObject(rmgObject, guarded, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user