Explorar o código

Nullkiller: fix border gate and garrison bypassing when owned

Andrii Danylchenko %!s(int64=4) %!d(string=hai) anos
pai
achega
1a69a43f09

+ 1 - 1
AI/Nullkiller/Behaviors/ClusterBehavior.cpp

@@ -54,7 +54,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(std::shared_ptr<ObjectCluster>
 
 #if AI_TRACE_LEVEL >= 2
 	logAi->trace(
-		"Checking cluster %s, found %d paths",
+		"Checking cluster %s %s, found %d paths",
 		cluster->blocker->getObjectName(),
 		cluster->blocker->visitablePos().toString(),
 		paths.size());

+ 2 - 2
AI/Nullkiller/Goals/CGoal.h

@@ -83,12 +83,12 @@ namespace Goals
 	template<typename T> class DLL_EXPORT ElementarGoal : public CGoal<T>, public ITask
 	{
 	public:
-		ElementarGoal(EGoals goal = INVALID) : CGoal(goal), ITask()
+		ElementarGoal<T>(EGoals goal = INVALID) : CGoal(goal), ITask()
 		{
 			isAbstract = false;
 		}
 
-		ElementarGoal(const ElementarGoal<T> & other) : CGoal(other), ITask(other)
+		ElementarGoal<T>(const ElementarGoal<T> & other) : CGoal(other), ITask(other)
 		{
 		}
 

+ 0 - 5
AI/Nullkiller/Goals/Composition.cpp

@@ -90,11 +90,6 @@ TGoalVec Composition::decompose() const
 			newComposition.addNext(goal);
 		}
 
-		if(newComposition.isElementar() && !newComposition.hero.validAndSet())
-		{
-			logAi->error("Bad");
-		}
-
 		result.push_back(sptr(newComposition));
 	}
 

+ 16 - 1
AI/Nullkiller/Pathfinding/Rules/AIPreviousNodeRule.cpp

@@ -23,8 +23,23 @@ namespace AIPathfinding
 		const PathfinderConfig * pathfinderConfig,
 		CPathfinderHelper * pathfinderHelper) const
 	{
-		if(source.node->action == CGPathNode::ENodeAction::BLOCKING_VISIT || source.node->action == CGPathNode::ENodeAction::VISIT)
+		if(source.node->action == CGPathNode::ENodeAction::BLOCKING_VISIT 
+			|| source.node->action == CGPathNode::ENodeAction::VISIT)
 		{
+			if(source.nodeObject)
+			{
+				if((source.nodeObject->ID == Obj::GARRISON || source.nodeObject->ID == Obj::GARRISON2)
+					&& source.heroRelations != PlayerRelations::ENEMIES)
+					return;
+
+				if(source.nodeObject->ID == Obj::BORDER_GATE)
+				{
+					auto quest = dynamic_cast<const CGBorderGate *>(source.nodeObject);
+
+					if(quest->wasMyColorVisited(pathfinderHelper->hero->tempOwner))
+						return;
+				}
+			}
 			// we can not directly bypass objects, we need to interact with them first
 			destination.node->theNodeBefore = source.node;