1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00

Fixed AI-exploration-data being lost after loading savegame

The information of whether objects like a redwood-observatory or subterranian gates have been interacted with by the AI will now be retrieved from the game-state instead of using an AI-internal memory that won't survive loading a save-game.
This commit is contained in:
Xilmi 2024-07-07 22:08:19 +02:00
parent 54c6d99de3
commit e0a81b3e69

View File

@ -35,45 +35,30 @@ Goals::TGoalVec ExplorationBehavior::decompose(const Nullkiller * ai) const
for(auto obj : ai->memory->visitableObjs)
{
if(!vstd::contains(ai->memory->alreadyVisited, obj))
{
switch(obj->ID.num)
switch (obj->ID.num)
{
case Obj::REDWOOD_OBSERVATORY:
case Obj::PILLAR_OF_FIRE:
{
auto rObj = dynamic_cast<const CRewardableObject*>(obj);
if(!rObj->wasScouted(ai->playerID))
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 200)).addNext(CaptureObject(obj))));
break;
}
case Obj::MONOLITH_ONE_WAY_ENTRANCE:
case Obj::MONOLITH_TWO_WAY:
case Obj::SUBTERRANEAN_GATE:
auto tObj = dynamic_cast<const CGTeleport *>(obj);
if(TeleportChannel::IMPASSABLE != ai->memory->knownTeleportChannels[tObj->channel]->passability)
{
auto tObj = dynamic_cast<const CGTeleport*>(obj);
for (auto exit : cb->getTeleportChannelExits(tObj->channel))
{
if (exit != tObj->id)
{
if (!cb->isVisible(cb->getObjInstance(exit)))
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj))));
}
break;
}
}
else
{
switch(obj->ID.num)
{
case Obj::MONOLITH_TWO_WAY:
case Obj::SUBTERRANEAN_GATE:
auto tObj = dynamic_cast<const CGTeleport *>(obj);
if(TeleportChannel::IMPASSABLE == ai->memory->knownTeleportChannels[tObj->channel]->passability)
break;
for(auto exit : ai->memory->knownTeleportChannels[tObj->channel]->exits)
{
if(!cb->getObj(exit))
{
// Always attempt to visit two-way teleports if one of channel exits is not visible
tasks.push_back(sptr(Composition().addNext(ExplorationPoint(obj->visitablePos(), 50)).addNext(CaptureObject(obj))));
break;
}
}
break;
}
}
}