From 05e75e121432923ab94ca8fab39a8c266aa674a6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 19 Jan 2014 20:27:33 +0100 Subject: [PATCH] Closes #1127: Fix for subtitles for idle dialogue appearing outside of hearing range --- apps/openmw/mwmechanics/aiwander.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 185805153..77b52f5be 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -191,8 +191,11 @@ namespace MWMechanics const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); float chance = store.get().find("fVoiceIdleOdds")->getFloat(); int roll = std::rand()/ (static_cast (RAND_MAX) + 1) * 100; // [0, 99] - // TODO: do not show subtitle messagebox if player is too far away? or do not say at all? - if (roll < chance) + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + + // Don't bother if the player is out of hearing range + if (roll < chance && Ogre::Vector3(player.getRefData().getPosition().pos).distance(Ogre::Vector3(actor.getRefData().getPosition().pos)) < 1500) MWBase::Environment::get().getDialogueManager()->say(actor, "idle"); } }