mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 19:59:55 +00:00
AIWander - Added support for the Repeat parameter to mimic vanilla.
This commit is contained in:
parent
681345dd15
commit
1cfe037d6b
3 changed files with 28 additions and 18 deletions
|
@ -1,8 +1,8 @@
|
|||
#include "aiwander.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle):
|
||||
mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle)
|
||||
MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle, bool repeat):
|
||||
mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle), mRepeat(repeat)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
class AiWander : public AiPackage
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& 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<int>& 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<int> mIdle;
|
||||
private:
|
||||
int mDistance;
|
||||
int mDuration;
|
||||
int mTimeOfDay;
|
||||
std::vector<int> mIdle;
|
||||
bool mRepeat;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -181,19 +181,29 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
std::vector<int> 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<arg0; ++i) runtime.pop();
|
||||
|
||||
MWMechanics::AiWander wanderPackage(range, duration, time, idleList);
|
||||
MWMechanics::AiWander wanderPackage(range, duration, time, idleList, repeat);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(wanderPackage);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue