From 0cb0b5bc2334e7117f3ba89659ff698949f47b38 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Mon, 28 Jan 2019 15:44:27 +1100 Subject: [PATCH] fixed roaming/following speed inconsistency --- src/world/Actor/BNpc.cpp | 13 +++++++------ src/world/Territory/Zone.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 1de0334e..16744ef8 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -177,15 +177,16 @@ void Sapphire::Entity::BNpc::step() // This is probably not a good way to do it but works fine for now float angle = Util::calcAngFrom( getPos().x, getPos().z, stepPos.x, stepPos.z ) + PI; - float speed = 1.7f; + auto delta = static_cast< float >( Util::getTimeMs() - m_lastTickTime ) / 1000.f; + + float speed = 7.25f * delta; if( m_state == BNpcState::Roaming ) - speed *= 0.5f; + speed *= 0.3f; - if( distanceToDest <= distanceToStep + speed ) - { - speed = distanceToDest; - } + // this seems to fix it but i don't know why :( + if( speed > distanceToDest ) + speed = distanceToDest / delta; auto x = ( cosf( angle ) * speed ); auto y = stepPos.y; diff --git a/src/world/Territory/Zone.cpp b/src/world/Territory/Zone.cpp index e1bfb528..a98bcc87 100644 --- a/src/world/Territory/Zone.cpp +++ b/src/world/Territory/Zone.cpp @@ -387,7 +387,7 @@ bool Sapphire::Zone::checkWeather() void Sapphire::Zone::updateBNpcs( int64_t tickCount ) { - if( ( tickCount - m_lastMobUpdate ) <= 250 ) + if( ( tickCount - m_lastMobUpdate ) <= 100 ) return; m_lastMobUpdate = tickCount;