diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b62bf1a..83682c507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Bug #4125: OpenMW logo cropped on bugtracker Bug #4215: OpenMW shows book text after last EOL tag Bug #4221: Characters get stuck in V-shaped terrain + Bug #4230: AiTravel package issues break some Tribunal quests Bug #4251: Stationary NPCs do not return to their position after combat Bug #4274: Pre-0.43 death animations are not forward-compatible with 0.43+ Bug #4286: Scripted animations can be interrupted diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 72e6ced19..8b52b15a4 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -53,7 +53,23 @@ namespace MWMechanics if (!isWithinMaxRange(osg::Vec3f(mX, mY, mZ), pos.asVec3())) return false; - if (pathTo(actor, ESM::Pathgrid::Point(static_cast(mX), static_cast(mY), static_cast(mZ)), duration)) + // Unfortunately, with vanilla assets destination is sometimes blocked by other actor. + // If we got close to target, check for actors nearby. If they are, finish AI package. + int destinationTolerance = 64; + ESM::Pathgrid::Point dest(static_cast(mX), static_cast(mY), static_cast(mZ)); + if (distance(pos.pos, dest) <= destinationTolerance) + { + std::vector targetActors; + std::pair result = MWBase::Environment::get().getWorld()->getHitContact(actor, destinationTolerance, targetActors); + + if (!result.first.isEmpty()) + { + actor.getClass().getMovementSettings(actor).mPosition[1] = 0; + return true; + } + } + + if (pathTo(actor, dest, duration)) { actor.getClass().getMovementSettings(actor).mPosition[1] = 0; return true;