From fc329050b34524ac5e9e52e3fa6d0245189806bd Mon Sep 17 00:00:00 2001 From: Dobrohotov Alexei Date: Wed, 3 Mar 2021 22:04:10 +0300 Subject: [PATCH] AIPursue: Pursue the player until LOS is established (#5869) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/aipursue.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a46f47f530..84580d9fdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ Bug #5838: Local map and other menus become blank in some locations while playing Wizards' Islands mod. Bug #5840: GetSoundPlaying "Health Damage" doesn't play when NPC hits target with shield effect ( vanilla engine behavior ) Bug #5841: Can't Cast Zero Cost Spells When Magicka is < 0 + Bug #5869: Guards can initiate arrest dialogue behind locked doors Bug #5871: The console appears if you type the Russian letter "Ё" in the name of the enchantment Feature #390: 3rd person look "over the shoulder" Feature #1536: Show more information about level on menu diff --git a/apps/openmw/mwmechanics/aipursue.cpp b/apps/openmw/mwmechanics/aipursue.cpp index bfe860d6d9..5af73887cb 100644 --- a/apps/openmw/mwmechanics/aipursue.cpp +++ b/apps/openmw/mwmechanics/aipursue.cpp @@ -53,9 +53,14 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte const float pathTolerance = 100.f; - if (pathTo(actor, dest, duration, pathTolerance) && - std::abs(dest.z() - actorPos.z()) < pathTolerance) // check the true distance in case the target is far away in Z-direction + // check the true distance in case the target is far away in Z-direction + bool reached = pathTo(actor, dest, duration, pathTolerance) && + std::abs(dest.z() - actorPos.z()) < pathTolerance; + + if (reached) { + if (!MWBase::Environment::get().getWorld()->getLOS(target, actor)) + return false; MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue, actor); //Arrest player when reached return true; }