Skip to content

Commit a86d29e

Browse files
committed
fix goomba stomp escape check on large units
large units are accounted for automatically when pathing invoking getTUCost() for each section gives bad results
1 parent b4b1361 commit a86d29e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/Battlescape/UnitFallBState.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,27 @@ void UnitFallBState::think()
238238
{
239239
Position offset;
240240
Pathfinding::directionToVector(dir, &offset);
241-
241+
Position destination = unitBelow->getPosition() + offset;
242+
if (_parent->getSave()->getPathfinding()->getTUCost(unitBelow->getPosition(), dir, &destination, unitBelow, 0, false) == 255)
243+
{
244+
// can't move this way, try another direction
245+
continue;
246+
}
242247
for (std::vector<Position>::iterator bs = bodySections.begin(); bs < bodySections.end(); )
243248
{
244249
Position originalPosition = (*bs);
245250
Position endPosition = originalPosition + offset;
251+
246252
Tile *t = _parent->getSave()->getTile(endPosition);
247253
Tile *bt = _parent->getSave()->getTile(endPosition + Position(0,0,-1));
248254

249255
bool aboutToBeOccupiedFromAbove = t && std::find(tilesToFallInto.begin(), tilesToFallInto.end(), t) != tilesToFallInto.end();
250256
bool alreadyTaken = t && std::find(escapeTiles.begin(), escapeTiles.end(), t) != escapeTiles.end();
251257
bool alreadyOccupied = t && t->getUnit() && (t->getUnit() != unitBelow);
252-
bool movementBlocked = _parent->getSave()->getPathfinding()->getTUCost(originalPosition, dir, &endPosition, *ub, 0, false) == 255;
253258
bool hasFloor = t && !t->hasNoFloor(bt);
254259
bool unitCanFly = unitBelow->getMovementType() == MT_FLY;
255260

256-
bool canMoveToTile = t && !alreadyOccupied && !alreadyTaken && !aboutToBeOccupiedFromAbove && !movementBlocked && (hasFloor || unitCanFly);
261+
bool canMoveToTile = t && !alreadyOccupied && !alreadyTaken && !aboutToBeOccupiedFromAbove && (hasFloor || unitCanFly);
257262
if (canMoveToTile)
258263
{
259264
// Check next section of the unit.
@@ -291,7 +296,7 @@ void UnitFallBState::think()
291296
}
292297
if (!escapeFound)
293298
{
294-
// STOMP THAT GOOMBAH!
299+
// STOMP THAT GOOMBA!
295300
unitBelow->knockOut(_parent);
296301
ub = unitsToMove.erase(ub);
297302
}

0 commit comments

Comments
 (0)