1 #ifndef GAME_MWMECHANICS_AIESCORT_H 2 #define GAME_MWMECHANICS_AIESCORT_H 3 4 #include "typedaipackage.hpp" 5 6 #include <string> 7 8 namespace ESM 9 { 10 namespace AiSequence 11 { 12 struct AiEscort; 13 } 14 } 15 16 namespace MWMechanics 17 { 18 /// \brief AI Package to have an NPC lead the player to a specific point 19 class AiEscort final : public TypedAiPackage<AiEscort> 20 { 21 public: 22 /// Implementation of AiEscort 23 /** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time 24 \implement AiEscort **/ 25 AiEscort(const std::string &actorId, int duration, float x, float y, float z); 26 /// Implementation of AiEscortCell 27 /** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time 28 \implement AiEscortCell **/ 29 AiEscort(const std::string &actorId, const std::string &cellId, int duration, float x, float y, float z); 30 31 AiEscort(const ESM::AiSequence::AiEscort* escort); 32 33 bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) override; 34 getTypeId()35 static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::Escort; } 36 makeDefaultOptions()37 static constexpr Options makeDefaultOptions() 38 { 39 AiPackage::Options options; 40 options.mUseVariableSpeed = true; 41 options.mSideWithTarget = true; 42 return options; 43 } 44 45 void writeState(ESM::AiSequence::AiSequence &sequence) const override; 46 47 void fastForward(const MWWorld::Ptr& actor, AiState& state) override; 48 getDestination() const49 osg::Vec3f getDestination() const override { return osg::Vec3f(mX, mY, mZ); } 50 51 private: 52 const std::string mCellId; 53 const float mX; 54 const float mY; 55 const float mZ; 56 float mMaxDist = 450; 57 const float mDuration; // In hours 58 float mRemainingDuration; // In hours 59 60 const int mCellX; 61 const int mCellY; 62 }; 63 } 64 #endif 65