mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Obstacles won't be generated around unguarded objects.
This commit is contained in:
parent
464ffc4afa
commit
c470b9606b
@ -104,13 +104,13 @@
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 2,
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treaureLikeZone" : 1
|
||||
"treasureLikeZone" : 1
|
||||
},
|
||||
"3" :
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 3,
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treaureLikeZone" : 1
|
||||
"treasureLikeZone" : 1
|
||||
},
|
||||
"4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasure" : {"min" : 3000, "max": 10000} },
|
||||
"5" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasureLikeZone" : 4},
|
||||
|
@ -412,7 +412,7 @@ void CRmgTemplateZone::addRequiredObject(CGObjectInstance * obj, si32 strength)
|
||||
requiredObjects.push_back(std::make_pair(obj, strength));
|
||||
}
|
||||
|
||||
void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
{
|
||||
//precalculate actual (randomized) monster strength based on this post
|
||||
//http://forum.vcmi.eu/viewtopic.php?p=12426#12426
|
||||
@ -430,7 +430,7 @@ void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
|
||||
strength = strength1 + strength2;
|
||||
if (strength < 2000)
|
||||
return; //no guard at all
|
||||
return false; //no guard at all
|
||||
|
||||
CreatureID creId = CreatureID::NONE;
|
||||
int amount = 0;
|
||||
@ -455,6 +455,7 @@ void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||
guard->putStack(SlotID(0), hlp);
|
||||
|
||||
placeObject(gen, guard, pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
|
||||
@ -903,7 +904,6 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
|
||||
if (gen->isPossible(pos))
|
||||
{
|
||||
tiles.push_back(pos);
|
||||
gen->setOccupied(pos, ETileType::BLOCKED);
|
||||
};
|
||||
});
|
||||
if ( ! tiles.size())
|
||||
@ -912,9 +912,16 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
|
||||
return false;
|
||||
}
|
||||
auto guard_tile = *RandomGeneratorUtil::nextItem(tiles, gen->rand);
|
||||
gen->setOccupied (guard_tile, ETileType::USED);
|
||||
|
||||
addMonster (gen, guard_tile, str);
|
||||
if (addMonster (gen, guard_tile, str)) //do not lace obstacles aroudn unguarded object
|
||||
{
|
||||
for (auto pos : tiles)
|
||||
gen->setOccupied(pos, ETileType::BLOCKED);
|
||||
|
||||
gen->setOccupied (guard_tile, ETileType::USED);
|
||||
}
|
||||
else
|
||||
gen->setOccupied (guard_tile, ETileType::FREE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
std::set<int3> getTileInfo () const;
|
||||
|
||||
void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0);
|
||||
void addMonster(CMapGenerator* gen, int3 &pos, si32 strength);
|
||||
bool addMonster(CMapGenerator* gen, int3 &pos, si32 strength);
|
||||
bool createTreasurePile (CMapGenerator* gen, int3 &pos);
|
||||
bool fill(CMapGenerator* gen);
|
||||
void createBorder(CMapGenerator* gen);
|
||||
|
Loading…
Reference in New Issue
Block a user