From 1cfe037d6b6e2ed4d3c26f4934a1cc38d6268e5c Mon Sep 17 00:00:00 2001 From: Torben Carrington Date: Fri, 24 May 2013 04:49:20 -0700 Subject: [PATCH] AIWander - Added support for the Repeat parameter to mimic vanilla. --- apps/openmw/mwmechanics/aiwander.cpp | 4 ++-- apps/openmw/mwmechanics/aiwander.hpp | 28 +++++++++++++-------------- apps/openmw/mwscript/aiextensions.cpp | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 3cd78a9338..a730475482 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,8 +1,8 @@ #include "aiwander.hpp" #include -MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector& idle): - mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle) +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector& idle, bool repeat): + mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle), mRepeat(repeat) { } diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index a71858febc..e06e714bc4 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -6,24 +6,24 @@ namespace MWMechanics { - class AiWander : public AiPackage { - public: + public: - AiWander(int distance, int duration, int timeOfDay, const std::vector& idle); - virtual AiPackage *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - virtual int getTypeId() const; - ///< 0: Wander + AiWander(int distance, int duration, int timeOfDay, const std::vector& idle, bool repeat); + virtual AiPackage *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + ///< 0: Wander - private: - int mDistance; - int mDuration; - int mTimeOfDay; - std::vector mIdle; + private: + int mDistance; + int mDuration; + int mTimeOfDay; + std::vector mIdle; + bool mRepeat; }; - } +} #endif diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 65ca3ae210..24fc58ef65 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -181,19 +181,29 @@ namespace MWScript runtime.pop(); std::vector idleList; + bool repeat = false; - for (int i=2; i<10 && arg0; ++i) + for(short i=1; i < 10 && arg0; ++i) { + if(!repeat) + repeat = true; Interpreter::Type_Integer idleValue = runtime[0].mInteger; idleList.push_back(idleValue); runtime.pop(); --arg0; } + if(arg0) + { + repeat = runtime[0].mInteger; + runtime.pop(); + --arg0; + } + // discard additional arguments (reset), because we have no idea what they mean. for (unsigned int i=0; i