mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix pathfinding issues when hero has expert navigation
This commit is contained in:
parent
98c6215ab6
commit
11e6e0d6f7
@ -209,15 +209,17 @@ void MovementCostRule::process(
|
||||
int moveAtNextTile = destination.movementLeft;
|
||||
int cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile);
|
||||
int remains = moveAtNextTile - cost;
|
||||
int maxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
|
||||
int sourceLayerMaxMovePoints = pathfinderHelper->getMaxMovePoints(source.node->layer);
|
||||
|
||||
if(remains < 0)
|
||||
{
|
||||
//occurs rarely, when hero with low movepoints tries to leave the road
|
||||
costAtNextTile += static_cast<float>(moveAtNextTile) / maxMovePoints;//we spent all points of current turn
|
||||
costAtNextTile += static_cast<float>(moveAtNextTile) / sourceLayerMaxMovePoints;//we spent all points of current turn
|
||||
pathfinderHelper->updateTurnInfo(++turnAtNextTile);
|
||||
|
||||
maxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
|
||||
moveAtNextTile = maxMovePoints;
|
||||
int destinationLayerMaxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
|
||||
|
||||
moveAtNextTile = destinationLayerMaxMovePoints;
|
||||
|
||||
cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile); //cost must be updated, movement points changed :(
|
||||
remains = moveAtNextTile - cost;
|
||||
@ -231,7 +233,7 @@ void MovementCostRule::process(
|
||||
cost = moveAtNextTile - remains;
|
||||
}
|
||||
|
||||
costAtNextTile += static_cast<float>(cost) / maxMovePoints;
|
||||
costAtNextTile += static_cast<float>(cost) / sourceLayerMaxMovePoints;
|
||||
|
||||
destination.cost = costAtNextTile;
|
||||
destination.turn = turnAtNextTile;
|
||||
|
Loading…
Reference in New Issue
Block a user