1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

Fix for new pathfinder code - generate proper goals

This commit is contained in:
Dydzio 2018-10-15 21:17:14 +02:00
parent 6958f2cddf
commit a00a7762b5
2 changed files with 4 additions and 23 deletions

View File

@ -77,7 +77,10 @@ Goals::TGoalVec PathfindingManager::howToVisitObj(HeroPtr hero, ObjectIdRef obj,
return findPath(hero, dest, allowGatherArmy, [&](int3 firstTileToGet) -> Goals::TSubgoal
{
return selectVisitingGoal(hero, obj);
if(obj->ID.num == Obj::HERO && obj->getOwner() == hero->getOwner())
return sptr(Goals::VisitHero(obj->id.getNum()).sethero(hero).setisAbstract(true));
else
return sptr(Goals::VisitObj(obj->id.getNum()).sethero(hero).setisAbstract(true));
});
}
@ -141,26 +144,6 @@ Goals::TGoalVec PathfindingManager::findPath(
return result;
}
Goals::TSubgoal PathfindingManager::selectVisitingGoal(HeroPtr hero, ObjectIdRef obj) const
{
int3 dest = obj->visitablePos();
if(obj->ID.num == Obj::HERO) //enemy hero may move to other position
{
return sptr(Goals::VisitHero(obj->id.getNum()).sethero(hero).setisAbstract(true));
}
else //just visit that tile
{
//if target is town, fuzzy system will use additional "estimatedReward" variable to increase priority a bit
//TODO: change to getObj eventually and and move appropiate logic there
return obj->ID.num == Obj::TOWN
? sptr(Goals::VisitTile(dest).sethero(hero).setobjid(obj->ID.num).setisAbstract(true))
: sptr(Goals::VisitTile(dest).sethero(hero).setisAbstract(true));
}
return sptr(Goals::VisitTile(dest).sethero(hero).setisAbstract(true));
}
Goals::TSubgoal PathfindingManager::clearWayTo(HeroPtr hero, int3 firstTileToGet)
{
if(isBlockedBorderGate(firstTileToGet))

View File

@ -59,6 +59,4 @@ private:
const std::function<Goals::TSubgoal(int3)> goalFactory);
Goals::TSubgoal clearWayTo(HeroPtr hero, int3 firstTileToGet);
Goals::TSubgoal selectVisitingGoal(HeroPtr hero, ObjectIdRef obj) const;
};