mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
#2689 - fix approaching guards when closest tile is double-guarded
This commit is contained in:
parent
717a765123
commit
903be33bf3
@ -455,6 +455,11 @@ bool CPathfinderHelper::passOneTurnLimitCheck(const PathNodeInfo & source) const
|
||||
return true;
|
||||
}
|
||||
|
||||
int CPathfinderHelper::getGuardiansCount(int3 tile) const
|
||||
{
|
||||
return getGuardingCreatures(tile).size();
|
||||
}
|
||||
|
||||
CPathfinderHelper::CPathfinderHelper(CGameState * gs, const CGHeroInstance * Hero, const PathfinderOptions & Options):
|
||||
CGameInfoCallback(gs),
|
||||
turn(-1),
|
||||
|
@ -121,6 +121,8 @@ public:
|
||||
|
||||
int movementPointsAfterEmbark(int movement, int basicCost, bool disembark) const;
|
||||
bool passOneTurnLimitCheck(const PathNodeInfo & source) const;
|
||||
|
||||
int getGuardiansCount(int3 tile) const;
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -298,8 +298,8 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea
|
||||
|
||||
if(source.guarded)
|
||||
{
|
||||
if(!(pathfinderConfig->options.originalMovementRules && source.node->layer == EPathfindingLayer::AIR) &&
|
||||
!destination.isGuardianTile) // Can step into tile of guard
|
||||
if(!(pathfinderConfig->options.originalMovementRules && source.node->layer == EPathfindingLayer::AIR)
|
||||
&& (!destination.isGuardianTile || pathfinderHelper->getGuardiansCount(source.coord) > 1)) // Can step into tile of guard
|
||||
{
|
||||
return BlockingReason::SOURCE_GUARDED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user