1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-16 02:47:36 +02:00

Treasure piles should always be accessible.

Boosted treasure value for better overview.
This commit is contained in:
DjWarmonger 2014-06-05 21:37:39 +02:00
parent 1746ab8c12
commit e4ea6727b7
2 changed files with 22 additions and 7 deletions

View File

@ -10,7 +10,7 @@
{ {
"type" : "playerStart", "size" : 1, "owner" : 1, "type" : "playerStart", "size" : 1, "owner" : 1,
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true, "playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
"treasure" : {"min" : 1000, "max": 3000} "treasure" : {"min" : 1500, "max": 3000}
}, },
"2" : "2" :
{ {
@ -33,7 +33,7 @@
"5" : "5" :
{ {
"type" : "treasure", "size" : 2, "terrainTypes" : [ "sand" ], "neutralTowns" : { "castles" : 1 }, "type" : "treasure", "size" : 2, "terrainTypes" : [ "sand" ], "neutralTowns" : { "castles" : 1 },
"treasure" : {"min" : 5000, "max": 10000} "treasure" : {"min" : 9000, "max": 10000}
} }
}, },
"connections" : "connections" :
@ -65,7 +65,7 @@
"3" : "3" :
{ {
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "1", "type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "1",
"treasure" : {"min" : 1500, "max": 4000} "treasure" : {"min" : 2000, "max": 4000}
}, },
"4" : "4" :
{ {
@ -75,7 +75,7 @@
"5" : "5" :
{ {
"type" : "treasure", "size" : 3, "neutralTowns" : { "castles" : 1 }, "terrainTypes" : [ "sand" ], "type" : "treasure", "size" : 3, "neutralTowns" : { "castles" : 1 }, "terrainTypes" : [ "sand" ],
"treasure" : {"min" : 6000, "max": 12000} "treasure" : {"min" : 11000, "max": 12000}
} }
}, },
"connections" : "connections" :
@ -98,7 +98,7 @@
{ {
"type" : "playerStart", "size" : 3, "owner" : 1, "type" : "playerStart", "size" : 3, "owner" : 1,
"playerTowns" : { "castles" : 1 }, "playerTowns" : { "castles" : 1 },
"treasure" : {"min" : 300, "max": 3000} "treasure" : {"min" : 1000, "max": 2000}
}, },
"2" : "2" :
{ {
@ -118,7 +118,7 @@
"7" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treasureLikeZone" : 4 }, "7" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treasureLikeZone" : 4 },
"8" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 }, "8" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 },
"9" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 }, "9" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 },
"10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasure" : {"min" : 10000, "max": 25000} }, "10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasure" : {"min" : 21000, "max": 25000} },
"11" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 }, "11" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 },
"12" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 } "12" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 }
}, },

View File

@ -543,9 +543,24 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
{ {
placeObject(gen, treasure.second, treasure.first); placeObject(gen, treasure.second, treasure.first);
} }
guardPos = *RandomGeneratorUtil::nextItem(boundary, gen->rand);
std::vector<int3> accessibleTiles; //we can't place guard in dead-end of zone, make sure that at least one neightbouring tile is possible and not blocked
for (auto tile : boundary)
{
bool possible = false;
gen->foreach_neighbour(tile, [gen, &accessibleTiles, &possible, boundary](int3 pos)
{
if (gen->isPossible(pos) && !vstd::contains(boundary, pos)) //do not check tiles that are going to be blocked
possible = true;
});
if (possible)
accessibleTiles.push_back(tile);
}
guardPos = *RandomGeneratorUtil::nextItem(accessibleTiles, gen->rand);
if (addMonster(gen, guardPos, currentValue)) if (addMonster(gen, guardPos, currentValue))
{//block only if object is guarded {//block only if object is guarded
for (auto tile : boundary) for (auto tile : boundary)
{ {
if (gen->isPossible(tile)) if (gen->isPossible(tile))