mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fix for new pathfinder code - generate proper goals
This commit is contained in:
parent
6958f2cddf
commit
a00a7762b5
@ -77,7 +77,10 @@ Goals::TGoalVec PathfindingManager::howToVisitObj(HeroPtr hero, ObjectIdRef obj,
|
|||||||
|
|
||||||
return findPath(hero, dest, allowGatherArmy, [&](int3 firstTileToGet) -> Goals::TSubgoal
|
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;
|
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)
|
Goals::TSubgoal PathfindingManager::clearWayTo(HeroPtr hero, int3 firstTileToGet)
|
||||||
{
|
{
|
||||||
if(isBlockedBorderGate(firstTileToGet))
|
if(isBlockedBorderGate(firstTileToGet))
|
||||||
|
@ -59,6 +59,4 @@ private:
|
|||||||
const std::function<Goals::TSubgoal(int3)> goalFactory);
|
const std::function<Goals::TSubgoal(int3)> goalFactory);
|
||||||
|
|
||||||
Goals::TSubgoal clearWayTo(HeroPtr hero, int3 firstTileToGet);
|
Goals::TSubgoal clearWayTo(HeroPtr hero, int3 firstTileToGet);
|
||||||
|
|
||||||
Goals::TSubgoal selectVisitingGoal(HeroPtr hero, ObjectIdRef obj) const;
|
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user