mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Scale dwelling / pandora with creatures value according to number of native zones.
This commit is contained in:
parent
4cea0a2973
commit
ced3d32f3f
@ -25,7 +25,7 @@ void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3&
|
||||
|
||||
|
||||
CMapGenerator::CMapGenerator(shared_ptr<CMapGenOptions> mapGenOptions, int RandomSeed /*= std::time(nullptr)*/) :
|
||||
mapGenOptions(mapGenOptions), randomSeed(RandomSeed), monolithIndex(0)
|
||||
mapGenOptions(mapGenOptions), randomSeed(RandomSeed), monolithIndex(0), zonesTotal(0)
|
||||
{
|
||||
rand.setSeed(randomSeed);
|
||||
}
|
||||
@ -435,3 +435,17 @@ int CMapGenerator::getNextMonlithIndex()
|
||||
else
|
||||
return monolithIndex++;
|
||||
}
|
||||
|
||||
void CMapGenerator::registerZone (TFaction faction)
|
||||
{
|
||||
zonesPerFaction[faction]++;
|
||||
zonesTotal++;
|
||||
}
|
||||
ui32 CMapGenerator::getZoneCount(TFaction faction)
|
||||
{
|
||||
return zonesPerFaction[faction];
|
||||
}
|
||||
ui32 CMapGenerator::getTotalZoneCount() const
|
||||
{
|
||||
return zonesTotal;
|
||||
}
|
||||
|
@ -78,9 +78,14 @@ public:
|
||||
void setNearestObjectDistance(int3 &tile, int value);
|
||||
|
||||
int getNextMonlithIndex();
|
||||
void registerZone (TFaction faction);
|
||||
ui32 getZoneCount(TFaction faction);
|
||||
ui32 getTotalZoneCount() const;
|
||||
|
||||
private:
|
||||
std::map<TRmgTemplateZoneId, CRmgTemplateZone*> zones;
|
||||
std::map<TFaction, ui32> zonesPerFaction;
|
||||
ui32 zonesTotal; //zones that have their main town only
|
||||
|
||||
CTileInfo*** tiles;
|
||||
|
||||
|
@ -786,6 +786,8 @@ void CRmgTemplateZone::initTownType (CMapGenerator* gen)
|
||||
{
|
||||
//first town in zone sets the facton of entire zone
|
||||
town->subID = townType;
|
||||
//register MAIN town of zone
|
||||
gen->registerZone(town->subID);
|
||||
//first town in zone goes in the middle
|
||||
placeObject(gen, town, getPos() + town->getVisitableOffset());
|
||||
}
|
||||
@ -820,6 +822,8 @@ void CRmgTemplateZone::initTownType (CMapGenerator* gen)
|
||||
placeObject(gen, town, getPos() + town->getVisitableOffset()); //towns are big objects and should be centered around visitable position
|
||||
|
||||
totalTowns++;
|
||||
//register MAIN town of zone only
|
||||
gen->registerZone (town->subID);
|
||||
|
||||
logGlobal->traceStream() << "Fill player info " << player_id;
|
||||
|
||||
@ -1425,7 +1429,7 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
|
||||
auto cre = creatures.front();
|
||||
if (cre->faction == townType)
|
||||
{
|
||||
oi.value = cre->AIValue * cre->growth * (1 + 0.5f); //TODO: include town count in formula
|
||||
oi.value = cre->AIValue * cre->growth * (1 + (float)(gen->getZoneCount(cre->faction)) / gen->getTotalZoneCount() + (float)(gen->getZoneCount(cre->faction) / 2)); //TODO: include town count in formula
|
||||
oi.probability = 40;
|
||||
|
||||
for (auto temp : dwellingHandler->getTemplates())
|
||||
@ -1542,7 +1546,7 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
|
||||
obj->creatures.putStack(SlotID(0), stack);
|
||||
return obj;
|
||||
};
|
||||
oi.value = (2 * (creature->AIValue) * creaturesAmount * (1 + 1) - 4000)/3; //TODO: count number of towns on the map
|
||||
oi.value = (2 * (creature->AIValue) * creaturesAmount * (1 + (float)(gen->getZoneCount(creature->faction)) / gen->getTotalZoneCount()))/3; //TODO: count number of towns on the map
|
||||
oi.probability = 3;
|
||||
possibleObjects.push_back (oi);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user