|
|
@@ -10,9 +10,28 @@
|
|
|
#include "StdInc.h"
|
|
|
#include "AIMovementAfterDestinationRule.h"
|
|
|
#include "../Actions/BattleAction.h"
|
|
|
+#include "../../Goals/Invalid.h"
|
|
|
|
|
|
namespace AIPathfinding
|
|
|
{
|
|
|
+ class QuestAction : public ISpecialAction
|
|
|
+ {
|
|
|
+ public:
|
|
|
+ QuestAction(QuestInfo questInfo)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual bool canAct(const CGHeroInstance * hero) const override
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual Goals::TSubgoal whatToDo(const HeroPtr & hero) const override
|
|
|
+ {
|
|
|
+ return Goals::sptr(Goals::Invalid());
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
AIMovementAfterDestinationRule::AIMovementAfterDestinationRule(
|
|
|
CPlayerSpecificInfoCallback * cb,
|
|
|
std::shared_ptr<AINodeStorage> nodeStorage)
|
|
|
@@ -50,6 +69,23 @@ namespace AIPathfinding
|
|
|
destination.blocked = true;
|
|
|
}
|
|
|
|
|
|
+ if(destination.nodeObject->ID == Obj::QUEST_GUARD || destination.nodeObject->ID == Obj::BORDERGUARD)
|
|
|
+ {
|
|
|
+ auto questObj = dynamic_cast<const IQuestObject *>(destination.nodeObject);
|
|
|
+ auto nodeHero = pathfinderHelper->hero;
|
|
|
+
|
|
|
+ if(!destination.nodeObject->wasVisited(nodeHero->tempOwner)
|
|
|
+ || !questObj->checkQuest(nodeHero))
|
|
|
+ {
|
|
|
+ nodeStorage->updateAINode(destination.node, [&](AIPathNode * node)
|
|
|
+ {
|
|
|
+ auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord);
|
|
|
+
|
|
|
+ node->specialAction.reset(new QuestAction(questInfo));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -141,6 +177,12 @@ namespace AIPathfinding
|
|
|
vstd::amax(battleNode->danger, danger);
|
|
|
|
|
|
battleNode->specialAction = std::make_shared<BattleAction>(destination.coord);
|
|
|
+
|
|
|
+ if(source.nodeObject && isObjectRemovable(source.nodeObject))
|
|
|
+ {
|
|
|
+ battleNode->theNodeBefore = source.node;
|
|
|
+ }
|
|
|
+
|
|
|
#ifdef VCMI_TRACE_PATHFINDER
|
|
|
logAi->trace(
|
|
|
"Begin bypass guard at destination with danger %s while moving %s -> %s",
|