Skip to content

Commit

Permalink
Merge pull request #2698 from Capostrophic/wander
Browse files Browse the repository at this point in the history
Support movement deceleration for wander AI
  • Loading branch information
akortunov committed Feb 11, 2020
2 parents 54e7e0c + 013953e commit 10fafab
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/openmw/mwmechanics/aiescort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace MWMechanics

void fastForward(const MWWorld::Ptr& actor, AiState& state);

virtual osg::Vec3f getDestination() { return osg::Vec3f(mX, mY, mZ); }
virtual osg::Vec3f getDestination() const { return osg::Vec3f(mX, mY, mZ); }

private:
std::string mCellId;
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwmechanics/aifollow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace MWMechanics

void fastForward(const MWWorld::Ptr& actor, AiState& state);

virtual osg::Vec3f getDestination()
virtual osg::Vec3f getDestination() const
{
MWWorld::Ptr target = getTarget();
if (target.isEmpty())
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwmechanics/aipackage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace MWMechanics
/// Return true if this package should repeat. Currently only used for Wander packages.
virtual bool getRepeat() const;

virtual osg::Vec3f getDestination() { return osg::Vec3f(0, 0, 0); }
virtual osg::Vec3f getDestination() const { return osg::Vec3f(0, 0, 0); }

// Return true if any loaded actor with this AI package must be active.
virtual bool alwaysActive() const { return false; }
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwmechanics/aitravel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace MWMechanics

virtual bool alwaysActive() const { return true; }

virtual osg::Vec3f getDestination() { return osg::Vec3f(mX, mY, mZ); }
virtual osg::Vec3f getDestination() const { return osg::Vec3f(mX, mY, mZ); }

private:
float mX;
Expand Down
10 changes: 10 additions & 0 deletions apps/openmw/mwmechanics/aiwander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ namespace MWMechanics

virtual int getTypeId() const;

virtual bool useVariableSpeed() const { return true;}

virtual void writeState(ESM::AiSequence::AiSequence &sequence) const;

virtual void fastForward(const MWWorld::Ptr& actor, AiState& state);
Expand All @@ -105,6 +107,14 @@ namespace MWMechanics

osg::Vec3f getDestination(const MWWorld::Ptr& actor) const;

virtual osg::Vec3f getDestination() const
{
if (!mHasDestination)
return osg::Vec3f(0, 0, 0);

return mDestination;
}

private:
// NOTE: mDistance and mDuration must be set already
void init();
Expand Down

0 comments on commit 10fafab

Please sign in to comment.