mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +00:00
fixed roaming/following speed inconsistency
This commit is contained in:
parent
f0d28bf30f
commit
0cb0b5bc23
2 changed files with 8 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue