mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
- Added faction-specific dwellings
- Fixed generation of terrain-specific objects
This commit is contained in:
@ -218,6 +218,17 @@ bool CDwellingInstanceConstructor::producesCreature(const CCreature * crea) cons
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<const CCreature *> CDwellingInstanceConstructor::getProducedCreatures() const
|
||||||
|
{
|
||||||
|
std::vector<const CCreature *> creatures; //no idea why it's 2D, to be honest
|
||||||
|
for (auto & entry : availableCreatures)
|
||||||
|
{
|
||||||
|
for (const CCreature * cre : entry)
|
||||||
|
creatures.push_back(cre);
|
||||||
|
}
|
||||||
|
return creatures;
|
||||||
|
}
|
||||||
|
|
||||||
CBankInstanceConstructor::CBankInstanceConstructor()
|
CBankInstanceConstructor::CBankInstanceConstructor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class CGObjectInstance;
|
||||||
class CGTownInstance;
|
class CGTownInstance;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
class CGDwelling;
|
class CGDwelling;
|
||||||
@ -123,6 +124,7 @@ public:
|
|||||||
void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const;
|
void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const;
|
||||||
|
|
||||||
bool producesCreature(const CCreature * crea) const;
|
bool producesCreature(const CCreature * crea) const;
|
||||||
|
std::vector<const CCreature *> getProducedCreatures() const;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,14 @@
|
|||||||
#include "../CCreatureHandler.h"
|
#include "../CCreatureHandler.h"
|
||||||
#include "../CSpellHandler.h" //for choosing random spells
|
#include "../CSpellHandler.h" //for choosing random spells
|
||||||
|
|
||||||
#include "../mapObjects/CObjectClassesHandler.h"
|
#include "../mapObjects/CommonConstructors.h"
|
||||||
|
#include "../mapObjects/MapObjects.h" //needed to resolve templates for CommonConstructors.h
|
||||||
#include "../mapObjects/CGPandoraBox.h"
|
#include "../mapObjects/CGPandoraBox.h"
|
||||||
#include "../mapObjects/CRewardableObject.h"
|
#include "../mapObjects/CRewardableObject.h"
|
||||||
|
|
||||||
class CMap;
|
class CMap;
|
||||||
class CMapEditManager;
|
class CMapEditManager;
|
||||||
|
//class CGObjectInstance;
|
||||||
|
|
||||||
CRmgTemplateZone::CTownInfo::CTownInfo() : townCount(0), castleCount(0), townDensity(0), castleDensity(0)
|
CRmgTemplateZone::CTownInfo::CTownInfo() : townCount(0), castleCount(0), townDensity(0), castleDensity(0)
|
||||||
{
|
{
|
||||||
@ -1049,9 +1051,9 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
|
|||||||
|
|
||||||
bool CRmgTemplateZone::fill(CMapGenerator* gen)
|
bool CRmgTemplateZone::fill(CMapGenerator* gen)
|
||||||
{
|
{
|
||||||
addAllPossibleObjects (gen);
|
|
||||||
initTownType(gen);
|
initTownType(gen);
|
||||||
initTerrainType(gen);
|
initTerrainType(gen);
|
||||||
|
addAllPossibleObjects (gen);
|
||||||
placeMines(gen);
|
placeMines(gen);
|
||||||
createRequiredObjects(gen);
|
createRequiredObjects(gen);
|
||||||
fractalize(gen); //after required objects are created and linked with their own paths
|
fractalize(gen); //after required objects are created and linked with their own paths
|
||||||
@ -1404,7 +1406,40 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//dwellings
|
||||||
|
|
||||||
|
for (auto secondaryID : VLC->objtypeh->knownSubObjects(Obj::CREATURE_GENERATOR1))
|
||||||
|
{
|
||||||
|
auto dwellingHandler = dynamic_cast<const CDwellingInstanceConstructor*>(VLC->objtypeh->getHandlerFor(Obj::CREATURE_GENERATOR1, secondaryID).get());
|
||||||
|
auto creatures = dwellingHandler->getProducedCreatures();
|
||||||
|
if (creatures.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto cre = creatures.front();
|
||||||
|
if (cre->faction == townType)
|
||||||
|
{
|
||||||
|
oi.value = cre->AIValue * cre->growth * (1 + 0.5f); //TODO: include town count in formula
|
||||||
|
oi.probability = 40;
|
||||||
|
|
||||||
|
for (auto temp : dwellingHandler->getTemplates())
|
||||||
|
{
|
||||||
|
if (temp.canBePlacedAt(terrainType))
|
||||||
|
{
|
||||||
|
oi.generateObject = [gen, temp, secondaryID, dwellingHandler]() -> CGObjectInstance *
|
||||||
|
{
|
||||||
|
auto obj = VLC->objtypeh->getHandlerFor(Obj::CREATURE_GENERATOR1, secondaryID)->create(temp);
|
||||||
|
//dwellingHandler->configureObject(obj, gen->rand);
|
||||||
|
obj->tempOwner = PlayerColor::NEUTRAL;
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
possibleObjects.push_back (oi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const int scrollValues[] = {500, 2000, 3000, 4000, 5000};
|
static const int scrollValues[] = {500, 2000, 3000, 4000, 5000};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user