2012-11-15 21:15:20 +00:00
|
|
|
#ifndef GAME_MWMECHANICS_AIWANDER_H
|
|
|
|
#define GAME_MWMECHANICS_AIWANDER_H
|
2012-11-14 17:42:04 +00:00
|
|
|
|
|
|
|
#include "aipackage.hpp"
|
|
|
|
#include <vector>
|
|
|
|
|
2013-05-26 15:49:44 +00:00
|
|
|
#include "pathfinding.hpp"
|
2014-04-17 23:03:36 +00:00
|
|
|
#include "obstacle.hpp"
|
2013-05-26 15:49:44 +00:00
|
|
|
|
|
|
|
#include "../mwworld/timestamp.hpp"
|
|
|
|
|
2012-11-14 17:42:04 +00:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
2012-11-16 17:38:15 +00:00
|
|
|
class AiWander : public AiPackage
|
|
|
|
{
|
2013-05-24 11:49:20 +00:00
|
|
|
public:
|
2012-11-14 17:42:04 +00:00
|
|
|
|
2013-05-24 11:49:20 +00:00
|
|
|
AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle, bool repeat);
|
|
|
|
virtual AiPackage *clone() const;
|
2013-10-30 19:42:50 +00:00
|
|
|
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
2013-05-24 11:49:20 +00:00
|
|
|
///< \return Package completed?
|
|
|
|
virtual int getTypeId() const;
|
|
|
|
///< 0: Wander
|
2012-11-14 17:42:04 +00:00
|
|
|
|
2013-05-24 11:49:20 +00:00
|
|
|
private:
|
2013-05-30 02:26:45 +00:00
|
|
|
void stopWalking(const MWWorld::Ptr& actor);
|
2013-05-26 15:49:44 +00:00
|
|
|
void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
|
|
|
bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
int mDistance; // how far the actor can wander from the spawn point
|
2013-05-24 11:49:20 +00:00
|
|
|
int mDuration;
|
|
|
|
int mTimeOfDay;
|
|
|
|
std::vector<int> mIdle;
|
|
|
|
bool mRepeat;
|
2013-05-26 15:49:44 +00:00
|
|
|
|
2014-01-19 16:03:25 +00:00
|
|
|
bool mSaidGreeting;
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
// Cached current cell location
|
2013-05-26 15:49:44 +00:00
|
|
|
int mCellX;
|
|
|
|
int mCellY;
|
2014-03-29 09:17:04 +00:00
|
|
|
// Cell location multiplied by ESM::Land::REAL_SIZE
|
2013-05-26 15:49:44 +00:00
|
|
|
float mXCell;
|
|
|
|
float mYCell;
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
const MWWorld::CellStore* mCell; // for detecting cell change
|
2014-03-13 12:44:52 +00:00
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
// if false triggers calculating allowed nodes based on mDistance
|
2013-05-26 15:49:44 +00:00
|
|
|
bool mStoredAvailableNodes;
|
2014-04-17 23:03:36 +00:00
|
|
|
// AiWander states
|
2013-05-26 15:49:44 +00:00
|
|
|
bool mChooseAction;
|
|
|
|
bool mIdleNow;
|
|
|
|
bool mMoveNow;
|
|
|
|
bool mWalking;
|
|
|
|
|
2013-05-26 18:30:42 +00:00
|
|
|
float mIdleChanceMultiplier;
|
2013-05-26 15:49:44 +00:00
|
|
|
unsigned short mPlayedIdle;
|
|
|
|
|
|
|
|
MWWorld::TimeStamp mStartTime;
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
// allowed pathgrid nodes based on mDistance from the spawn point
|
2013-05-26 15:49:44 +00:00
|
|
|
std::vector<ESM::Pathgrid::Point> mAllowedNodes;
|
|
|
|
ESM::Pathgrid::Point mCurrentNode;
|
2014-04-17 23:03:36 +00:00
|
|
|
bool mTrimCurrentNode;
|
|
|
|
void trimAllowedNodes(std::vector<ESM::Pathgrid::Point>& nodes,
|
|
|
|
const PathFinder& pathfinder);
|
2013-05-26 15:49:44 +00:00
|
|
|
|
|
|
|
PathFinder mPathFinder;
|
2014-04-17 23:03:36 +00:00
|
|
|
|
|
|
|
ObstacleCheck mObstacleCheck;
|
|
|
|
float mDoorCheckDuration;
|
|
|
|
int mStuckCount;
|
2012-11-16 17:38:15 +00:00
|
|
|
};
|
2013-05-24 11:49:20 +00:00
|
|
|
}
|
2012-11-14 17:42:04 +00:00
|
|
|
|
2012-11-16 19:28:20 +00:00
|
|
|
#endif
|