1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Merge pull request #542 from nullkiller/ai-stability-fixes

AI: stability fixes
This commit is contained in:
Alexander Shishkin 2019-01-27 01:08:01 +03:00 committed by GitHub
commit 08b841d668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -370,6 +370,12 @@ bool isObjectRemovable(const CGObjectInstance * obj)
case Obj::TREASURE_CHEST:
case Obj::ARTIFACT:
case Obj::BORDERGUARD:
case Obj::FLOTSAM:
case Obj::PANDORAS_BOX:
case Obj::OCEAN_BOTTLE:
case Obj::SEA_CHEST:
case Obj::SHIPWRECK_SURVIVOR:
case Obj::SPELL_SCROLL:
return true;
break;
default:

View File

@ -300,10 +300,9 @@ namespace AIPathfinding
if(blocker == BlockingReason::DESTINATION_BLOCKVIS && destination.nodeObject)
{
auto objID = destination.nodeObject->ID;
if((objID == Obj::HERO && destination.objectRelations != PlayerRelations::ENEMIES)
|| objID == Obj::SUBTERRANEAN_GATE || objID == Obj::MONOLITH_TWO_WAY
|| objID == Obj::MONOLITH_ONE_WAY_ENTRANCE || objID == Obj::MONOLITH_ONE_WAY_EXIT
|| objID == Obj::WHIRLPOOL)
auto enemyHero = objID == Obj::HERO && destination.objectRelations == PlayerRelations::ENEMIES;
if(!enemyHero && !isObjectRemovable(destination.nodeObject))
{
destination.blocked = true;
}

View File

@ -834,6 +834,8 @@ void VCAI::mainLoop()
std::vector<Goals::TSubgoal> elementarGoals; //no duplicates allowed (operator ==)
basicGoals.clear();
validateVisitableObjs();
//get all potential and saved goals
//TODO: not lose
basicGoals.push_back(sptr(Goals::Win()));
@ -1748,6 +1750,9 @@ std::vector<const CGObjectInstance *> VCAI::getFlaggedObjects() const
void VCAI::addVisitableObj(const CGObjectInstance * obj)
{
if(obj->ID == Obj::EVENT)
return;
visitableObjs.insert(obj);
// All teleport objects seen automatically assigned to appropriate channels