OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aifollow.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_AIFOLLOW_H
2 #define GAME_MWMECHANICS_AIFOLLOW_H
3 
4 #include "aipackage.hpp"
5 
6 #include <string>
7 
9 
10 #include "pathfinding.hpp"
11 
12 namespace ESM
13 {
14 namespace AiSequence
15 {
16  struct AiFollow;
17 }
18 }
19 
20 namespace MWMechanics
21 {
23  {
24  float mTimer;
25  bool mMoving;
28 
30  mTimer(0.f),
31  mMoving(false),
33  mTurnActorToTarget(false)
34  {}
35  };
36 
38 
40  class AiFollow : public AiPackage
41  {
42  public:
43  AiFollow(const std::string &actorId, float duration, float x, float y, float z);
44  AiFollow(const std::string &actorId, const std::string &CellId, float duration, float x, float y, float z);
46  AiFollow(const MWWorld::Ptr& actor, float duration, float X, float Y, float Z);
48  AiFollow(const MWWorld::Ptr& actor, const std::string &CellId, float duration, float X, float Y, float Z);
50  AiFollow(const MWWorld::Ptr& actor, bool commanded=false);
51 
52  AiFollow(const ESM::AiSequence::AiFollow* follow);
53 
54  virtual bool sideWithTarget() const { return true; }
55  virtual bool followTargetThroughDoors() const { return true; }
56  virtual bool shouldCancelPreviousAi() const { return !mCommanded; }
57 
58  virtual AiFollow *clone() const;
59 
60  virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
61 
62  virtual int getTypeId() const;
63 
65  std::string getFollowedActor();
66 
67  virtual void writeState (ESM::AiSequence::AiSequence& sequence) const;
68 
69  bool isCommanded() const;
70 
71  int getFollowIndex() const;
72 
73  void fastForward(const MWWorld::Ptr& actor, AiState& state);
74 
75  private:
77 
79  bool mCommanded;
80  float mDuration; // Hours
81  float mRemainingDuration; // Hours
82  float mX;
83  float mY;
84  float mZ;
85  std::string mCellId;
86  bool mActive; // have we spotted the target?
88 
89  static int mFollowIndexCounter;
90  };
91 }
92 #endif
base class for the temporary storage of AiPackages.
Definition: aistate.hpp:90
bool mTurnActorToTarget
Definition: aifollow.hpp:27
std::string getFollowedActor()
Returns the actor being followed.
Definition: aifollow.cpp:210
static int mFollowIndexCounter
Definition: aifollow.hpp:89
virtual void writeState(ESM::AiSequence::AiSequence &sequence) const
Definition: aifollow.cpp:230
bool mAlwaysFollow
This will make the actor always follow.
Definition: aifollow.hpp:78
bool mCommanded
Definition: aifollow.hpp:79
bool isCommanded() const
Definition: aifollow.cpp:225
virtual bool sideWithTarget() const
Return true if having this AiPackage makes the actor side with the target in fights (default false) ...
Definition: aifollow.hpp:54
void fastForward(const MWWorld::Ptr &actor, AiState &state)
Simulates the passing of time.
Definition: aifollow.cpp:255
virtual AiFollow * clone() const
Clones the package.
Definition: aifollow.cpp:215
float mTimer
Definition: aifollow.hpp:24
Base class for AI packages.
Definition: aipackage.hpp:33
float mRemainingDuration
Definition: aifollow.hpp:81
float mY
Definition: aifollow.hpp:83
Definition: aisequence.hpp:102
virtual int getTypeId() const
Definition: aifollow.cpp:220
Definition: character.hpp:154
virtual bool shouldCancelPreviousAi() const
Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default t...
Definition: aifollow.hpp:56
int getFollowIndex() const
Definition: aifollow.cpp:250
AiFollowStorage()
Definition: aifollow.hpp:29
AiPackage for an actor to follow another actor/the PC.
Definition: aifollow.hpp:40
AiFollow(const std::string &actorId, float duration, float x, float y, float z)
Definition: aifollow.cpp:22
Definition: aifollow.hpp:22
std::string mCellId
Definition: aifollow.hpp:85
bool mMoving
Definition: aifollow.hpp:25
float mX
Definition: aifollow.hpp:82
Definition: aisequence.hpp:151
float mDuration
Definition: aifollow.hpp:80
int mFollowIndex
Definition: aifollow.hpp:87
float mZ
Definition: aifollow.hpp:84
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
bool mActive
Definition: aifollow.hpp:86
virtual bool followTargetThroughDoors() const
Return true if the actor should follow the target through teleport doors (default false) ...
Definition: aifollow.hpp:55
float mTargetAngleRadians
Definition: aifollow.hpp:26
virtual bool execute(const MWWorld::Ptr &actor, CharacterController &characterController, AiState &state, float duration)
Definition: aifollow.cpp:75