mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 05:57:45 +00:00
fix naviprovider not being set on instances
This commit is contained in:
parent
a344990a63
commit
a7f31c77a9
5 changed files with 13 additions and 46 deletions
|
@ -224,19 +224,15 @@ void Sapphire::Entity::BNpc::step()
|
|||
|
||||
bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||
{
|
||||
// do this first, this will update local actor position and the position of other actors
|
||||
// and then this npc will then path from the position after pushing/being pushed
|
||||
//pushNearbyBNpcs();
|
||||
|
||||
if( Util::distance( getPos(), pos ) <= m_naviTargetReachedDistance )
|
||||
{
|
||||
// Reached destination
|
||||
m_naviLastPath.clear();
|
||||
// return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto pNaviMgr = m_pFw->get< World::Manager::NaviMgr >();
|
||||
auto pNaviProvider = pNaviMgr->getNaviProvider( m_pCurrentZone->getBgPath() );
|
||||
auto pNaviProvider = m_pCurrentZone->getNaviProvider();
|
||||
|
||||
if( !pNaviProvider )
|
||||
{
|
||||
|
@ -285,7 +281,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
|||
|
||||
step();*/
|
||||
|
||||
//pNaviProvider->setMoveTarget( *this, pos );
|
||||
pNaviProvider->setMoveTarget( *this, pos );
|
||||
auto pos1 = pNaviProvider->getMovePos( *this );
|
||||
|
||||
//Logger::debug( "{} {} {}", pos1.x, pos1.y, pos1.z );
|
||||
|
@ -480,7 +476,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
|||
case BNpcState::Roaming:
|
||||
{
|
||||
auto pNaviMgr = m_pFw->get< World::Manager::NaviMgr >();
|
||||
auto pNaviProvider = pNaviMgr->getNaviProvider( m_pCurrentZone->getBgPath() );
|
||||
auto pNaviProvider = m_pCurrentZone->getNaviProvider();
|
||||
|
||||
if( pNaviProvider )
|
||||
{
|
||||
|
@ -507,7 +503,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
|||
if( !hasFlag( Immobile ) && ( Util::getTimeSeconds() - m_lastRoamTargetReached > roamTick ) )
|
||||
{
|
||||
auto pNaviMgr = m_pFw->get< World::Manager::NaviMgr >();
|
||||
auto pNaviProvider = pNaviMgr->getNaviProvider( m_pCurrentZone->getBgPath() );
|
||||
auto pNaviProvider = m_pCurrentZone->getNaviProvider();
|
||||
|
||||
if( !pNaviProvider )
|
||||
{
|
||||
|
@ -671,39 +667,6 @@ void Sapphire::Entity::BNpc::checkAggro()
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::pushNearbyBNpcs()
|
||||
{
|
||||
for( auto& bNpc : m_inRangeBNpc )
|
||||
{
|
||||
auto pos = bNpc->getPos();
|
||||
auto distance = Util::distance( m_pos, bNpc->getPos() );
|
||||
|
||||
|
||||
// todo: not sure what's good here
|
||||
auto factor = bNpc->getNaviTargetReachedDistance();
|
||||
|
||||
auto delta = static_cast< float >( Util::getTimeMs() - bNpc->getLastUpdateTime() ) / 1000.f;
|
||||
delta = std::min< float >( factor, delta );
|
||||
|
||||
// too far away, ignore it
|
||||
if( distance > factor )
|
||||
continue;
|
||||
|
||||
auto angle = Util::calcAngFrom( m_pos.x, m_pos.y, pos.x, pos.y ) + PI;
|
||||
|
||||
auto x = ( cosf( angle ) );
|
||||
auto z = ( sinf( angle ) );
|
||||
|
||||
bNpc->setPos( pos.x + ( x * factor * delta ),
|
||||
pos.y,
|
||||
pos.z + ( z * factor * delta ), true );
|
||||
|
||||
// setPos( m_pos.x + ( xBase * -pushDistance ),
|
||||
// m_pos.y,
|
||||
// m_pos.z + ( zBase * -pushDistance ) );
|
||||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setOwner( Sapphire::Entity::CharaPtr m_pChara )
|
||||
{
|
||||
m_pOwner = m_pChara;
|
||||
|
|
|
@ -111,8 +111,6 @@ namespace Sapphire::Entity
|
|||
|
||||
void checkAggro();
|
||||
|
||||
void pushNearbyBNpcs();
|
||||
|
||||
void setOwner( CharaPtr m_pChara );
|
||||
|
||||
void setLevelId( uint32_t levelId );
|
||||
|
|
|
@ -39,7 +39,7 @@ Sapphire::World::Navi::NaviProviderPtr Sapphire::World::Manager::NaviMgr::getNav
|
|||
|
||||
std::string Sapphire::World::Manager::NaviMgr::getBgName( const std::string& bgPath )
|
||||
{
|
||||
auto findPos = bgPath.find_last_of( "/" );
|
||||
auto findPos = bgPath.find_last_of( '/' );
|
||||
if( findPos != std::string::npos )
|
||||
return bgPath.substr( findPos + 1 );
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ Sapphire::InstanceContent::InstanceContent( std::shared_ptr< Sapphire::Data::Ins
|
|||
|
||||
bool Sapphire::InstanceContent::init()
|
||||
{
|
||||
if( !Zone::init() )
|
||||
return false;
|
||||
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onInstanceInit( getAsInstanceContent() );
|
||||
|
||||
|
@ -99,7 +102,7 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
|
|||
{
|
||||
case Created:
|
||||
{
|
||||
if( m_boundPlayerIds.size() == 0 )
|
||||
if( m_boundPlayerIds.empty() )
|
||||
return;
|
||||
|
||||
for( auto playerId : m_boundPlayerIds )
|
||||
|
|
|
@ -48,6 +48,9 @@ Sapphire::QuestBattle::QuestBattle( std::shared_ptr< Sapphire::Data::QuestBattle
|
|||
|
||||
bool Sapphire::QuestBattle::init()
|
||||
{
|
||||
if( !Zone::init() )
|
||||
return false;
|
||||
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onInstanceInit( getAsQuestBattle() );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue