1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Nullkiller: stabilization

This commit is contained in:
Andrii Danylchenko
2021-05-16 14:45:45 +03:00
committed by Andrii Danylchenko
parent dec723b4be
commit 37f49f2ac5
8 changed files with 42 additions and 13 deletions

View File

@@ -73,7 +73,9 @@ bool needToRecruitHero(const CGTownInstance * startupTown)
auto heroToCheck = startupTown->garrisonHero ? startupTown->garrisonHero.get() : startupTown->visitingHero.get();
auto paths = cb->getPathsInfo(heroToCheck);
for(auto obj : ai->visitableObjs)
int treasureSourcesCount = 0;
for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects())
{
if(obj->ID == Obj::RESOURCE && obj->subID == Res::GOLD
|| obj->ID == Obj::TREASURE_CHEST
@@ -84,12 +86,15 @@ bool needToRecruitHero(const CGTownInstance * startupTown)
if((path->accessible == CGPathNode::BLOCKVIS || path->accessible == CGPathNode::VISIT)
&& path->reachable())
{
return true;
treasureSourcesCount++;
}
}
}
return false;
auto basicCount = cb->getTownsInfo().size() + 2;
auto boost = (int)std::floor(std::pow(treasureSourcesCount / 3.0, 2));
return cb->getHeroCount(ai->playerID, true) < basicCount + boost;
}
Goals::TGoalVec StartupBehavior::decompose() const