mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
More fixes and tweaks for AI, including #1590.
This commit is contained in:
parent
a6ce282f8a
commit
362a54b4df
@ -242,7 +242,7 @@ TSubgoal GetObj::whatToDoToAchieve()
|
||||
if(!obj)
|
||||
return sptr (Goals::Explore());
|
||||
int3 pos = obj->visitablePos();
|
||||
return sptr (Goals::VisitTile(pos));
|
||||
return sptr (Goals::VisitTile(pos).sethero(hero)); //we must visit object with same hero, if any
|
||||
}
|
||||
|
||||
float GetObj::importanceWhenLocked() const
|
||||
@ -426,7 +426,7 @@ TGoalVec Explore::getAllPossibleSubgoals()
|
||||
}
|
||||
|
||||
int3 t = whereToExplore(h);
|
||||
if (t.z != -1) //no valid tile was found
|
||||
if (cb->isInTheMap(t)) //valid tile was found - could be invalid (none)
|
||||
ret.push_back (sptr (Goals::VisitTile(t).sethero(h)));
|
||||
}
|
||||
if (!hero && ai->canRecruitAnyHero())//if hero is assigned to that goal, no need to buy another one yet
|
||||
|
@ -796,6 +796,7 @@ void VCAI::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h)
|
||||
}
|
||||
break;
|
||||
}
|
||||
completeGoal (sptr(Goals::GetObj(obj->id.getNum()).sethero(h)));
|
||||
}
|
||||
|
||||
void VCAI::moveCreaturesToHero(const CGTownInstance * t)
|
||||
@ -1823,7 +1824,7 @@ Goals::TSubgoal VCAI::striveToGoalInternal(Goals::TSubgoal ultimateGoal, bool on
|
||||
|
||||
void VCAI::striveToQuest (const QuestInfo &q)
|
||||
{
|
||||
if (q.quest->missionType && q.quest->progress != CQuest::COMPLETE) //FIXME: quests are never synchronized. Pointer handling needed
|
||||
if (q.quest->missionType && q.quest->progress != CQuest::COMPLETE)
|
||||
{
|
||||
MetaString ms;
|
||||
q.quest->getRolloverText(ms, false);
|
||||
@ -2494,8 +2495,7 @@ bool isWeeklyRevisitable (const CGObjectInstance * obj)
|
||||
bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
{
|
||||
switch (obj->ID)
|
||||
{
|
||||
case Obj::BORDERGUARD:
|
||||
{
|
||||
case Obj::BORDER_GATE:
|
||||
{
|
||||
for (auto q : ai->myCb->getMyQuests())
|
||||
@ -2507,6 +2507,8 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
}
|
||||
return true; //we don't have this quest yet
|
||||
}
|
||||
break;
|
||||
case Obj::BORDERGUARD: //open borderguard if possible
|
||||
case Obj::SEER_HUT:
|
||||
case Obj::QUEST_GUARD:
|
||||
{
|
||||
@ -2514,7 +2516,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
{
|
||||
if (q.obj == obj)
|
||||
{
|
||||
if (q.quest->checkQuest(*h))
|
||||
if (q.quest->checkQuest(h.h))
|
||||
return true; //we completed the quest
|
||||
else
|
||||
return false; //we can't complete this quest
|
||||
@ -2522,6 +2524,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
||||
}
|
||||
return true; //we don't have this quest yet
|
||||
}
|
||||
break;
|
||||
case Obj::CREATURE_GENERATOR1:
|
||||
{
|
||||
if (obj->tempOwner != h->tempOwner)
|
||||
|
Loading…
Reference in New Issue
Block a user