From 75b8ee74fa34cf2d7d23296c6dc60b553737c25f Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sun, 16 May 2021 14:49:39 +0300 Subject: [PATCH] Nullkiller: stabilisation after refactoring --- AI/Nullkiller/Engine/Nullkiller.cpp | 5 ++--- AI/Nullkiller/Pathfinding/AIPathfinder.cpp | 2 -- AI/Nullkiller/Pathfinding/AIPathfinder.h | 2 +- AI/Nullkiller/VCAI.cpp | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AI/Nullkiller/Engine/Nullkiller.cpp b/AI/Nullkiller/Engine/Nullkiller.cpp index a403e87b0..756db51f5 100644 --- a/AI/Nullkiller/Engine/Nullkiller.cpp +++ b/AI/Nullkiller/Engine/Nullkiller.cpp @@ -153,12 +153,11 @@ void Nullkiller::updateAiState() memory->removeInvisibleObjects(cb.get()); dangerHitMap->updateHitMap(); - // TODO: move to hero manager auto activeHeroes = cb->getHeroesInfo(); - vstd::erase_if(activeHeroes, [this](const HeroPtr & hero) -> bool + vstd::erase_if(activeHeroes, [this](const CGHeroInstance * hero) -> bool { - auto lockedReason = getHeroLockedReason(hero.h); + auto lockedReason = getHeroLockedReason(hero); return lockedReason == HeroLockedReason::DEFENCE; }); diff --git a/AI/Nullkiller/Pathfinding/AIPathfinder.cpp b/AI/Nullkiller/Pathfinding/AIPathfinder.cpp index 5c471f036..c4a36f94f 100644 --- a/AI/Nullkiller/Pathfinding/AIPathfinder.cpp +++ b/AI/Nullkiller/Pathfinding/AIPathfinder.cpp @@ -14,8 +14,6 @@ #include "../../../lib/mapping/CMap.h" #include "../Engine/Nullkiller.h" -std::shared_ptr AIPathfinder::storage; - AIPathfinder::AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller * ai) :cb(cb), ai(ai) { diff --git a/AI/Nullkiller/Pathfinding/AIPathfinder.h b/AI/Nullkiller/Pathfinding/AIPathfinder.h index 1e6cfa9b8..1052e1bcd 100644 --- a/AI/Nullkiller/Pathfinding/AIPathfinder.h +++ b/AI/Nullkiller/Pathfinding/AIPathfinder.h @@ -18,7 +18,7 @@ class Nullkiller; class AIPathfinder { private: - static std::shared_ptr storage; + std::shared_ptr storage; CPlayerSpecificInfoCallback * cb; Nullkiller * ai; diff --git a/AI/Nullkiller/VCAI.cpp b/AI/Nullkiller/VCAI.cpp index 1a3c9d11d..de1bfa5c5 100644 --- a/AI/Nullkiller/VCAI.cpp +++ b/AI/Nullkiller/VCAI.cpp @@ -770,6 +770,9 @@ void VCAI::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h) { makePossibleUpgrades(h.get()); + if(!nullkiller || !h->visitedTown->garrisonHero || !nullkiller->isHeroLocked(h->visitedTown->garrisonHero)) + moveCreaturesToHero(h->visitedTown); + if(ai->nullkiller->heroManager->getHeroRole(h) == HeroRole::MAIN && !h->hasSpellbook() && cb->getResourceAmount(Res::GOLD) >= GameConstants::SPELLBOOK_GOLD_COST) {