Browse Source

BattleAI: fix waited attack calculation

Andrii Danylchenko 1 year ago
parent
commit
4e83deca92
2 changed files with 6 additions and 0 deletions
  1. 1 0
      AI/BattleAI/BattleExchangeVariant.cpp
  2. 5 0
      AI/BattleAI/StackWithBonuses.h

+ 1 - 0
AI/BattleAI/BattleExchangeVariant.cpp

@@ -230,6 +230,7 @@ EvaluationResult BattleExchangeEvaluator::findBestTarget(
 
 		auto hbWaited = std::make_shared<HypotheticBattle>(env.get(), hb);
 
+		hbWaited->resetActiveUnit();
 		hbWaited->getForUpdate(activeStack->unitId())->waiting = true;
 		hbWaited->getForUpdate(activeStack->unitId())->waitedThisTurn = true;
 

+ 5 - 0
AI/BattleAI/StackWithBonuses.h

@@ -164,6 +164,11 @@ public:
 
 	int64_t getTreeVersion() const;
 
+	void resetActiveUnit()
+	{
+		activeUnitId = -1;
+	}
+
 #if SCRIPTING_ENABLED
 	scripting::Pool * getContextPool() const override;
 #endif