From b86155dc11f4a3009e6823693adf09f676d7ba65 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 10 Jul 2018 01:40:57 +0300 Subject: [PATCH] [Client] Allow AiFollow package to have infinite distance when desired --- apps/openmw/mwmechanics/aifollow.cpp | 24 ++++++++++++++++++++++++ apps/openmw/mwmechanics/aifollow.hpp | 20 ++++++++++++++++++++ apps/openmw/mwmp/DedicatedActor.cpp | 3 ++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 13de01f9a..b40f15618 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -110,6 +110,17 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte return false; } + /* + Start of tes3mp addition + + If this follow package is set to allow for any distance, skip the checks below + */ + if (mIgnoreDistance) + mActive = true; + /* + End of tes3mp addition + */ + // AiFollow requires the target to be in range and within sight for the initial activation if (!mActive) { @@ -275,4 +286,17 @@ void AiFollow::fastForward(const MWWorld::Ptr& actor, AiState &state) mRemainingDuration--; } +/* + Start of tes3mp addition + + Make it possible to allow following from any distance +*/ +void AiFollow::allowAnyDistance(bool state) +{ + mIgnoreDistance = state; +} +/* + End of tes3mp addition +*/ + } diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index f0d43c9a7..66d334d32 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -57,6 +57,16 @@ namespace MWMechanics void fastForward(const MWWorld::Ptr& actor, AiState& state); + /* + Start of tes3mp addition + + Make it possible to allow following from any distance + */ + void allowAnyDistance(bool state); + /* + End of tes3mp addition + */ + private: /// This will make the actor always follow. /** Thus ignoring mDuration and mX,mY,mZ (used for summoned creatures). **/ @@ -72,6 +82,16 @@ namespace MWMechanics int mFollowIndex; static int mFollowIndexCounter; + + /* + Start of tes3mp addition + + Track whether this package allows following to start from any distance + */ + bool mIgnoreDistance = false; + /* + End of tes3mp addition + */ }; } #endif diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 634faf04e..d488bdd2e 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -233,7 +233,8 @@ void DedicatedActor::setAI() if (aiAction == mwmp::BaseActorList::FOLLOW) { MWMechanics::AiFollow package(targetPtr); - ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(package, ptr); + package.allowAnyDistance(true); + ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(package, ptr, true); } } }