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

Fuzzy rework, added more defence and gather army routines

This commit is contained in:
Andrii Danylchenko
2023-06-04 16:02:02 +03:00
parent b1ca663eb6
commit b19ac01bf9
28 changed files with 710 additions and 195 deletions

View File

@ -56,7 +56,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(const std::vector<AIPath>
tasks.reserve(paths.size());
const AIPath * closestWay = nullptr;
std::unordered_map<HeroRole, const AIPath *> closestWaysByRole;
std::vector<ExecuteHeroChain *> waysToVisitObj;
for(auto & path : paths)
@ -128,8 +128,9 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(const std::vector<AIPath>
auto heroRole = ai->nullkiller->heroManager->getHeroRole(path.targetHero);
if(heroRole == HeroRole::SCOUT
&& (!closestWay || closestWay->movementCost() > path.movementCost()))
auto & closestWay = closestWaysByRole[heroRole];
if(!closestWay || closestWay->movementCost() > path.movementCost())
{
closestWay = &path;
}
@ -142,9 +143,12 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(const std::vector<AIPath>
}
}
if(closestWay)
for(auto way : waysToVisitObj)
{
for(auto way : waysToVisitObj)
auto heroRole = ai->nullkiller->heroManager->getHeroRole(way->getPath().targetHero);
auto closestWay = closestWaysByRole[heroRole];
if(closestWay)
{
way->closestWayRatio
= closestWay->movementCost() / way->getPath().movementCost();