Skip to content

Commit a7691b4

Browse files
committed
fix pathfinding oversight.
1 parent 2edacf3 commit a7691b4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/Battlescape/Pathfinding.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ int Pathfinding::getTUCost(const Position &startPosition, int direction, Positio
413413
cost += wallcost;
414414
if (_unit->getFaction() == FACTION_HOSTILE &&
415415
destinationTile->getUnit() &&
416+
destinationTile->getUnit()->getFaction() == FACTION_HOSTILE &&
416417
destinationTile->getUnit() != _unit)
417418
cost += 32; // try to find a better path, but don't exclude this path entirely.
418419

src/Battlescape/UnitWalkBState.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ void UnitWalkBState::think()
285285

286286
Position destination;
287287
int tu = _pf->getTUCost(_unit->getPosition(), dir, &destination, _unit, 0, false); // gets tu cost, but also gets the destination position.
288+
if (_unit->getFaction() == FACTION_HOSTILE &&
289+
_parent->getSave()->getTile(destination)->getUnit() &&
290+
_parent->getSave()->getTile(destination)->getUnit()->getFaction() == FACTION_HOSTILE &&
291+
_parent->getSave()->getTile(destination)->getUnit() != _unit)
292+
{
293+
tu -= 32; // we artificially inflate the TU cost by 32 points in getTUCost under these conditions, so we have to deflate it here.
294+
}
288295
if (_falling)
289296
{
290297
tu = 0;

0 commit comments

Comments
 (0)