1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-27 21:49:10 +02:00

Nullkiller: fix border gate and garrison bypassing when owned

This commit is contained in:
Andrii Danylchenko 2021-05-16 14:45:17 +03:00 committed by Andrii Danylchenko
parent 0705ee595a
commit 1a69a43f09
4 changed files with 19 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -23,8 +23,23 @@ namespace AIPathfinding
const PathfinderConfig * pathfinderConfig, const PathfinderConfig * pathfinderConfig,
CPathfinderHelper * pathfinderHelper) const 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 // we can not directly bypass objects, we need to interact with them first
destination.node->theNodeBefore = source.node; destination.node->theNodeBefore = source.node;