From 28fc21792e7e4078029139b8f06828354ffde78d Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 11 Apr 2021 19:17:23 +0200 Subject: [PATCH] Allow water walking actors to find path over water surface --- apps/openmw/mwmechanics/actorutil.cpp | 6 ++++++ apps/openmw/mwmechanics/actorutil.hpp | 1 + apps/openmw/mwmechanics/aipackage.cpp | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/actorutil.cpp b/apps/openmw/mwmechanics/actorutil.cpp index e27c9de49..04cbb8e9f 100644 --- a/apps/openmw/mwmechanics/actorutil.cpp +++ b/apps/openmw/mwmechanics/actorutil.cpp @@ -23,4 +23,10 @@ namespace MWMechanics MWBase::World* world = MWBase::Environment::get().getWorld(); return (actor.getClass().canSwim(actor) && world->isSwimming(actor)) || world->isFlying(actor); } + + bool hasWaterWalking(const MWWorld::Ptr& actor) + { + const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects(); + return effects.get(ESM::MagicEffect::WaterWalking).getMagnitude() > 0; + } } diff --git a/apps/openmw/mwmechanics/actorutil.hpp b/apps/openmw/mwmechanics/actorutil.hpp index 1e993f560..a226fc9cb 100644 --- a/apps/openmw/mwmechanics/actorutil.hpp +++ b/apps/openmw/mwmechanics/actorutil.hpp @@ -31,6 +31,7 @@ namespace MWMechanics MWWorld::Ptr getPlayer(); bool isPlayerInCombat(); bool canActorMoveByZAxis(const MWWorld::Ptr& actor); + bool hasWaterWalking(const MWWorld::Ptr& actor); template void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value) diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index 87ee562c6..8dcf37355 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -419,7 +419,8 @@ DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld:: if (actorClass.isPureWaterCreature(actor) || (getTypeId() != AiPackageTypeId::Wander && ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow) - || actorClass.canSwim(actor)))) + || actorClass.canSwim(actor) + || hasWaterWalking(actor)))) result |= DetourNavigator::Flag_swim; if (actorClass.canWalk(actor))