From e033b0c565849b80c0f92def1e11fc6fdea292ec Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 20 Mar 2019 01:04:07 +0300 Subject: [PATCH] Avoid build path through the ground for flying wandering creatures --- apps/openmw/mwmechanics/aiwander.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 6b7d6bf162..8c01c7b968 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -298,7 +298,8 @@ namespace MWMechanics const auto currentPosition = actor.getRefData().getPosition().asVec3(); std::size_t attempts = 10; // If a unit can't wander out of water, don't want to hang here - bool isWaterCreature = actor.getClass().isPureWaterCreature(actor); + const bool isWaterCreature = actor.getClass().isPureWaterCreature(actor); + const bool isFlyingCreature = actor.getClass().isPureFlyingCreature(actor); do { // Determine a random location within radius of original position const float wanderRadius = (0.2f + Misc::Rng::rollClosedProbability() * 0.8f) * wanderDistance; @@ -312,7 +313,7 @@ namespace MWMechanics if (!isWaterCreature && destinationIsAtWater(actor, mDestination)) continue; - if (isWaterCreature && destinationThroughGround(currentPosition, mDestination)) + if ((isWaterCreature || isFlyingCreature) && destinationThroughGround(currentPosition, mDestination)) continue; const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getPathfindingHalfExtents(actor);