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 
25  class AiFollow : public AiPackage
26  {
27  public:
29  AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z);
31  AiFollow(const std::string &ActorId,const std::string &CellId,float duration, float X, float Y, float Z);
33  AiFollow(const std::string &ActorId, bool commanded=false);
34 
35  AiFollow(const ESM::AiSequence::AiFollow* follow);
36 
37  MWWorld::Ptr getTarget() const;
38  virtual bool sideWithTarget() const { return true; }
39  virtual bool followTargetThroughDoors() const { return true; }
40  virtual bool shouldCancelPreviousAi() const { return !mCommanded; }
41 
42  virtual AiFollow *clone() const;
43 
44  virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
45 
46  virtual int getTypeId() const;
47 
49  std::string getFollowedActor();
50 
51  virtual void writeState (ESM::AiSequence::AiSequence& sequence) const;
52 
53  bool isCommanded() const;
54 
55  int getFollowIndex() const;
56 
57  void fastForward(const MWWorld::Ptr& actor, AiState& state);
58 
59  private:
61 
63  bool mCommanded;
64  float mDuration; // Hours
65  float mRemainingDuration; // Hours
66  float mX;
67  float mY;
68  float mZ;
69  std::string mActorRefId;
70  mutable int mActorId;
71  std::string mCellId;
72  bool mActive; // have we spotted the target?
74 
75  static int mFollowIndexCounter;
76  };
77 }
78 #endif
std::string getFollowedActor()
Returns the actor being followed.
Definition: aifollow.cpp:162
int mActorId
Definition: aifollow.hpp:70
static int mFollowIndexCounter
Definition: aifollow.hpp:75
virtual void writeState(ESM::AiSequence::AiSequence &sequence) const
Definition: aifollow.cpp:182
bool mAlwaysFollow
This will make the actor always follow.
Definition: aifollow.hpp:62
bool mCommanded
Definition: aifollow.hpp:63
bool isCommanded() const
Definition: aifollow.cpp:177
virtual bool sideWithTarget() const
Return true if having this AiPackage makes the actor side with the target in fights (default false) ...
Definition: aifollow.hpp:38
void fastForward(const MWWorld::Ptr &actor, AiState &state)
Simulates the passing of time.
Definition: aifollow.cpp:229
virtual AiFollow * clone() const
Clones the package.
Definition: aifollow.cpp:167
MWWorld::Ptr getTarget() const
Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty P...
Definition: aifollow.cpp:201
Base class for AI packages.
Definition: aipackage.hpp:32
float mRemainingDuration
Definition: aifollow.hpp:65
float mY
Definition: aifollow.hpp:67
Definition: aisequence.hpp:100
virtual int getTypeId() const
Definition: aifollow.cpp:172
Definition: character.hpp:145
std::string mActorRefId
Definition: aifollow.hpp:69
virtual bool shouldCancelPreviousAi() const
Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default t...
Definition: aifollow.hpp:40
int getFollowIndex() const
Definition: aifollow.cpp:224
AiPackage for an actor to follow another actor/the PC.
Definition: aifollow.hpp:25
std::string mCellId
Definition: aifollow.hpp:71
float mX
Definition: aifollow.hpp:66
Definition: aisequence.hpp:148
AiFollow(const std::string &ActorId, float duration, float X, float Y, float Z)
Follow Actor for duration or until you arrive at a world position.
Definition: aifollow.cpp:31
float mDuration
Definition: aifollow.hpp:64
int mFollowIndex
Definition: aifollow.hpp:73
float mZ
Definition: aifollow.hpp:68
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
bool mActive
Definition: aifollow.hpp:72
virtual bool followTargetThroughDoors() const
Return true if the actor should follow the target through teleport doors (default false) ...
Definition: aifollow.hpp:39
virtual bool execute(const MWWorld::Ptr &actor, CharacterController &characterController, AiState &state, float duration)
Definition: aifollow.cpp:63