1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +02:00

Merge pull request #498 from dydzio0614/AiHotfix

Fix severely broken AI behavior + tweak default hero AI value
This commit is contained in:
Alexander Shishkin
2018-10-16 12:25:59 +03:00
committed by GitHub
3 changed files with 5 additions and 24 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;
};

View File

@ -23,7 +23,7 @@
"hero" : {
"index" :34,
"handler": "hero",
"defaultAiValue" : 5000,
"defaultAiValue" : 7500,
"base" : {
"base" : {
"visitableFrom" : [ "+++", "+-+", "+++" ],