mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
probably fix stepping past the next step destination
This commit is contained in:
parent
c2356b9057
commit
2011c8ca91
1 changed files with 12 additions and 2 deletions
|
@ -162,9 +162,13 @@ void Sapphire::Entity::BNpc::step()
|
|||
return;
|
||||
|
||||
auto stepPos = m_naviLastPath[ m_naviPathStep ];
|
||||
auto distanceToStep = Util::distance( getPos().x, getPos().y, getPos().z,
|
||||
stepPos.x, stepPos.y, stepPos.z );
|
||||
|
||||
if( Util::distance( getPos().x, getPos().y, getPos().z, stepPos.x, stepPos.y, stepPos.z ) <= 4 &&
|
||||
m_naviPathStep < m_naviLastPath.size() - 1 )
|
||||
auto distanceToDest = Util::distance( getPos().x, getPos().y, getPos().z,
|
||||
m_naviTarget.x, m_naviTarget.y, m_naviTarget.z );
|
||||
|
||||
if( distanceToStep <= 4 && m_naviPathStep < m_naviLastPath.size() - 1 )
|
||||
{
|
||||
// Reached step in path
|
||||
m_naviPathStep++;
|
||||
|
@ -179,10 +183,16 @@ void Sapphire::Entity::BNpc::step()
|
|||
if( m_state == BNpcState::Roaming )
|
||||
speed *= 0.5f;
|
||||
|
||||
if( distanceToDest <= distanceToStep + speed )
|
||||
{
|
||||
speed = distanceToDest;
|
||||
}
|
||||
|
||||
auto x = ( cosf( angle ) * speed );
|
||||
auto y = stepPos.y;
|
||||
auto z = ( sinf( angle ) * speed );
|
||||
|
||||
|
||||
face( stepPos );
|
||||
setPos( { getPos().x + x, y, getPos().z + z } );
|
||||
sendPositionUpdate();
|
||||
|
|
Loading…
Add table
Reference in a new issue