diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 28390970..7c0e8808 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -224,12 +224,6 @@ void Sapphire::Entity::BNpc::step() bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) { - if( Util::distance( getPos(), pos ) <= m_naviTargetReachedDistance ) - { - // Reached destination - m_naviLastPath.clear(); - return true; - } auto pNaviMgr = m_pFw->get< World::Manager::NaviMgr >(); auto pNaviProvider = m_pCurrentZone->getNaviProvider(); @@ -281,9 +275,15 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) step();*/ - pNaviProvider->setMoveTarget( *this, pos ); + //pNaviProvider->setMoveTarget( *this, pos ); auto pos1 = pNaviProvider->getMovePos( *this ); + if( Util::distance( pos1, pos ) < 0.1f ) + { + // Reached destination + pNaviProvider->resetMoveTarget( *this ); + return true; + } //Logger::debug( "{} {} {}", pos1.x, pos1.y, pos1.z ); m_pCurrentZone->updateActorPosition( *this ); @@ -480,7 +480,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount ) if( pNaviProvider ) { - //if( !pNaviProvider->isAgentActive( *this ) ) + //if( !pNaviProvider->hasTargetState( *this ) ) pNaviProvider->setMoveTarget( *this, m_roamPos ); } diff --git a/src/world/Navi/NaviProvider.cpp b/src/world/Navi/NaviProvider.cpp index f17b7f5e..ff735ac6 100644 --- a/src/world/Navi/NaviProvider.cpp +++ b/src/world/Navi/NaviProvider.cpp @@ -638,3 +638,14 @@ bool Sapphire::World::Navi::NaviProvider::isAgentActive( Entity::Chara& chara ) return ag && ag->active; } + +bool Sapphire::World::Navi::NaviProvider::hasTargetState( Entity::Chara& chara ) const +{ + const dtCrowdAgent* ag = m_pCrowd->getAgent( chara.getAgentId() ); + return ag->targetState != DT_CROWDAGENT_TARGET_NONE; +} + +void Sapphire::World::Navi::NaviProvider::resetMoveTarget( Entity::Chara& chara ) +{ + m_pCrowd->resetMoveTarget( chara.getAgentId() ); +} diff --git a/src/world/Navi/NaviProvider.h b/src/world/Navi/NaviProvider.h index 9053dcd0..95f7b488 100644 --- a/src/world/Navi/NaviProvider.h +++ b/src/world/Navi/NaviProvider.h @@ -61,6 +61,9 @@ namespace Sapphire::World::Navi Common::FFXIVARR_POSITION3 getMovePos( Entity::Chara& chara ); bool isAgentActive( Entity::Chara& chara ) const; + bool hasTargetState( Entity::Chara& chara ) const; + + void resetMoveTarget( Entity::Chara& chara ); protected: std::string m_internalName;