1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

- Added monoliths between remote zones

- Fixed land connections between zones, now they're generated correctly.
This commit is contained in:
DjWarmonger
2014-06-01 12:02:43 +02:00
parent e97933035c
commit aee748d8d6
8 changed files with 45 additions and 22 deletions

View File

@ -2845,9 +2845,9 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
} }
return false; return false;
} }
case Obj::MONOLITH1: case Obj::MONOLITH_ONE_WAY_ENTRANCE:
case Obj::MONOLITH2: case Obj::MONOLITH_ONE_WAY_EXIT:
case Obj::MONOLITH3: case Obj::MONOLITH_TWO_WAY:
case Obj::WHIRLPOOL: case Obj::WHIRLPOOL:
//TODO: mechanism for handling monoliths //TODO: mechanism for handling monoliths
return false; return false;

View File

@ -4071,11 +4071,11 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
ObjectInstanceID destinationid; ObjectInstanceID destinationid;
switch(ID) switch(ID)
{ {
case Obj::MONOLITH1: //one way - find corresponding exit monolith case Obj::MONOLITH_ONE_WAY_ENTRANCE: //one way - find corresponding exit monolith
{ {
if(vstd::contains(objs,Obj::MONOLITH2) && vstd::contains(objs[Obj::MONOLITH2],subID) && objs[Obj::MONOLITH2][subID].size()) if(vstd::contains(objs,Obj::MONOLITH_ONE_WAY_EXIT) && vstd::contains(objs[Obj::MONOLITH_ONE_WAY_EXIT],subID) && objs[Obj::MONOLITH_ONE_WAY_EXIT][subID].size())
{ {
destinationid = *RandomGeneratorUtil::nextItem(objs[Obj::MONOLITH2][subID], cb->gameState()->getRandomGenerator()); destinationid = *RandomGeneratorUtil::nextItem(objs[Obj::MONOLITH_ONE_WAY_EXIT][subID], cb->gameState()->getRandomGenerator());
} }
else else
{ {
@ -4083,7 +4083,7 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
} }
break; break;
} }
case Obj::MONOLITH3://two way monolith - pick any other one case Obj::MONOLITH_TWO_WAY://two way monolith - pick any other one
case Obj::WHIRLPOOL: //Whirlpool case Obj::WHIRLPOOL: //Whirlpool
if(vstd::contains(objs,ID) && vstd::contains(objs[ID],subID) && objs[ID][subID].size()>1) if(vstd::contains(objs,ID) && vstd::contains(objs[ID],subID) && objs[ID][subID].size()>1)
{ {

View File

@ -507,9 +507,9 @@ public:
LEAN_TO = 39, LEAN_TO = 39,
LIBRARY_OF_ENLIGHTENMENT = 41, LIBRARY_OF_ENLIGHTENMENT = 41,
LIGHTHOUSE = 42, LIGHTHOUSE = 42,
MONOLITH1 = 43, MONOLITH_ONE_WAY_ENTRANCE = 43,
MONOLITH2 = 44, MONOLITH_ONE_WAY_EXIT = 44,
MONOLITH3 = 45, MONOLITH_TWO_WAY = 45,
MAGIC_PLAINS1 = 46, MAGIC_PLAINS1 = 46,
SCHOOL_OF_MAGIC = 47, SCHOOL_OF_MAGIC = 47,
MAGIC_SPRING = 48, MAGIC_SPRING = 48,

View File

@ -1084,9 +1084,9 @@ void CMapLoaderH3M::readObjects()
nobj = new CGVisitableOPW(); nobj = new CGVisitableOPW();
break; break;
} }
case Obj::MONOLITH1: case Obj::MONOLITH_ONE_WAY_ENTRANCE:
case Obj::MONOLITH2: case Obj::MONOLITH_ONE_WAY_EXIT:
case Obj::MONOLITH3: case Obj::MONOLITH_TWO_WAY:
case Obj::SUBTERRANEAN_GATE: case Obj::SUBTERRANEAN_GATE:
case Obj::WHIRLPOOL: case Obj::WHIRLPOOL:
{ {

View File

@ -26,7 +26,7 @@ void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3&
CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int randomSeed /*= std::time(nullptr)*/) : CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int randomSeed /*= std::time(nullptr)*/) :
mapGenOptions(mapGenOptions), randomSeed(randomSeed) mapGenOptions(mapGenOptions), randomSeed(randomSeed), monolithIndex(0)
{ {
rand.setSeed(randomSeed); rand.setSeed(randomSeed);
} }
@ -307,3 +307,8 @@ int CMapGenerator::getNearestObjectDistance(const int3 &tile) const
return tiles[tile.x][tile.y][tile.z].getNearestObjectDistance(); return tiles[tile.x][tile.y][tile.z].getNearestObjectDistance();
} }
int CMapGenerator::getNextMonlithIndex()
{
return monolithIndex++;
}

View File

@ -76,11 +76,15 @@ public:
int getNearestObjectDistance(const int3 &tile) const; int getNearestObjectDistance(const int3 &tile) const;
void setNearestObjectDistance(int3 &tile, int value); void setNearestObjectDistance(int3 &tile, int value);
int getNextMonlithIndex();
private: private:
std::map<TRmgTemplateZoneId, CRmgTemplateZone*> zones; std::map<TRmgTemplateZoneId, CRmgTemplateZone*> zones;
CTileInfo*** tiles; CTileInfo*** tiles;
int monolithIndex;
/// Generation methods /// Generation methods
std::string getMapDescription() const; std::string getMapDescription() const;
void addPlayerInfo(); void addPlayerInfo();

View File

@ -349,7 +349,7 @@ void CRmgTemplateZone::createConnections(CMapGenerator* gen)
}); });
if (guardPos.valid()) if (guardPos.valid())
{ {
gen->setOccupied (pos, ETileType::FREE); //TODO: place monster here gen->setOccupied (guardPos, ETileType::FREE); //TODO: place monster here
//zones can make paths only in their own area //zones can make paths only in their own area
this->crunchPath (gen, guardPos, this->getPos(), this->getId()); //make connection towards our zone center this->crunchPath (gen, guardPos, this->getPos(), this->getId()); //make connection towards our zone center
gen->getZones()[connection]->crunchPath (gen, guardPos, otherZoneCenter, connection); //make connection towards other zone center gen->getZones()[connection]->crunchPath (gen, guardPos, otherZoneCenter, connection); //make connection towards other zone center
@ -357,7 +357,16 @@ void CRmgTemplateZone::createConnections(CMapGenerator* gen)
} }
} }
if (!guardPos.valid()) if (!guardPos.valid())
logGlobal->warnStream() << boost::format ("Did not find connection between zones %d and %d") %getId() %connection; {
auto teleport1 = new CGTeleport;
teleport1->ID = Obj::MONOLITH_TWO_WAY;
teleport1->subID = gen->getNextMonlithIndex();
auto teleport2 = new CGTeleport(*teleport1);
addRequiredObject (teleport1);
gen->getZones()[connection]->addRequiredObject(teleport2);
}
} }
} }
@ -440,10 +449,13 @@ do not leave zone border
return result; return result;
} }
void CRmgTemplateZone::addRequiredObject(CGObjectInstance * obj)
{
requiredObjects.push_back(obj);
}
bool CRmgTemplateZone::fill(CMapGenerator* gen) bool CRmgTemplateZone::fill(CMapGenerator* gen)
{ {
std::vector<CGObjectInstance*> required_objects;
int townId = 0; int townId = 0;
if ((type == ETemplateZoneType::CPU_START) || (type == ETemplateZoneType::PLAYER_START)) if ((type == ETemplateZoneType::CPU_START) || (type == ETemplateZoneType::PLAYER_START))
@ -478,7 +490,7 @@ bool CRmgTemplateZone::fill(CMapGenerator* gen)
playerInfo.posOfMainTown = town->pos - int3(2, 0, 0); playerInfo.posOfMainTown = town->pos - int3(2, 0, 0);
playerInfo.generateHeroAtMainTown = true; playerInfo.generateHeroAtMainTown = true;
//required_objects.push_back(town); //requiredObjects.push_back(town);
std::vector<Res::ERes> required_mines; std::vector<Res::ERes> required_mines;
required_mines.push_back(Res::ERes::WOOD); required_mines.push_back(Res::ERes::WOOD);
@ -491,7 +503,7 @@ bool CRmgTemplateZone::fill(CMapGenerator* gen)
mine->subID = static_cast<si32>(res); mine->subID = static_cast<si32>(res);
mine->producedResource = res; mine->producedResource = res;
mine->producedQuantity = mine->defaultResProduction(); mine->producedQuantity = mine->defaultResProduction();
required_objects.push_back(mine); requiredObjects.push_back(mine);
} }
} }
else else
@ -515,7 +527,7 @@ bool CRmgTemplateZone::fill(CMapGenerator* gen)
gen->editManager->drawTerrain(VLC->townh->factions[townId]->nativeTerrain, &gen->rand); gen->editManager->drawTerrain(VLC->townh->factions[townId]->nativeTerrain, &gen->rand);
logGlobal->infoStream() << "Creating required objects"; logGlobal->infoStream() << "Creating required objects";
for(const auto &obj : required_objects) for(const auto &obj : requiredObjects)
{ {
int3 pos; int3 pos;
logGlobal->traceStream() << "Looking for place"; logGlobal->traceStream() << "Looking for place";

View File

@ -112,6 +112,7 @@ public:
void addTile (const int3 &pos); void addTile (const int3 &pos);
std::set<int3> getTileInfo () const; std::set<int3> getTileInfo () const;
void addRequiredObject(CGObjectInstance * obj);
bool fill(CMapGenerator* gen); bool fill(CMapGenerator* gen);
void createConnections(CMapGenerator* gen); void createConnections(CMapGenerator* gen);
void createBorder(CMapGenerator* gen); void createBorder(CMapGenerator* gen);
@ -135,6 +136,7 @@ private:
//content info //content info
std::vector<int3> shape; //TODO: remove std::vector<int3> shape; //TODO: remove
std::vector<CGObjectInstance*> requiredObjects;
std::vector<CGObjectInstance*> objects; std::vector<CGObjectInstance*> objects;
//placement info //placement info