mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Re-evaluate goal after hero move to make AI more consistent.
This commit is contained in:
parent
7793a57b0a
commit
76c4ef32c2
@ -1618,15 +1618,20 @@ void VCAI::wander(HeroPtr h)
|
||||
}
|
||||
|
||||
void VCAI::setGoal(HeroPtr h, Goals::TSubgoal goal)
|
||||
{ //TODO: check for presence?
|
||||
{
|
||||
if(goal->invalid())
|
||||
vstd::erase_if_present(lockedHeroes, h);
|
||||
else
|
||||
{
|
||||
lockedHeroes[h] = goal;
|
||||
goal->setisElementar(false); //always evaluate goals before realizing
|
||||
goal->setisElementar(false); //Force always evaluate goals before realizing
|
||||
}
|
||||
}
|
||||
void VCAI::evaluateGoal(HeroPtr h)
|
||||
{
|
||||
if (vstd::contains(lockedHeroes, h))
|
||||
fh->setPriority(lockedHeroes[h]);
|
||||
}
|
||||
|
||||
void VCAI::completeGoal (Goals::TSubgoal goal)
|
||||
{
|
||||
@ -2037,6 +2042,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
vstd::erase_if_present(lockedHeroes, h); //hero seemingly is confused
|
||||
throw cannotFulfillGoalException("Invalid path found!"); //FIXME: should never happen
|
||||
}
|
||||
evaluateGoal(h); //new hero position means new game situation
|
||||
logAi->debug("Hero %s moved from %s to %s. Returning %d.", h->name, startHpos(), h->visitablePos()(), ret);
|
||||
}
|
||||
return ret;
|
||||
|
@ -254,6 +254,7 @@ public:
|
||||
void endTurn();
|
||||
void wander(HeroPtr h);
|
||||
void setGoal(HeroPtr h, Goals::TSubgoal goal);
|
||||
void evaluateGoal(HeroPtr h); //evaluates goal assigned to hero, if any
|
||||
void completeGoal (Goals::TSubgoal goal); //safely removes goal from reserved hero
|
||||
void striveToQuest (const QuestInfo &q);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user