mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +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;
|
return;
|
||||||
|
|
||||||
auto stepPos = m_naviLastPath[ m_naviPathStep ];
|
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 &&
|
auto distanceToDest = Util::distance( getPos().x, getPos().y, getPos().z,
|
||||||
m_naviPathStep < m_naviLastPath.size() - 1 )
|
m_naviTarget.x, m_naviTarget.y, m_naviTarget.z );
|
||||||
|
|
||||||
|
if( distanceToStep <= 4 && m_naviPathStep < m_naviLastPath.size() - 1 )
|
||||||
{
|
{
|
||||||
// Reached step in path
|
// Reached step in path
|
||||||
m_naviPathStep++;
|
m_naviPathStep++;
|
||||||
|
@ -179,10 +183,16 @@ void Sapphire::Entity::BNpc::step()
|
||||||
if( m_state == BNpcState::Roaming )
|
if( m_state == BNpcState::Roaming )
|
||||||
speed *= 0.5f;
|
speed *= 0.5f;
|
||||||
|
|
||||||
|
if( distanceToDest <= distanceToStep + speed )
|
||||||
|
{
|
||||||
|
speed = distanceToDest;
|
||||||
|
}
|
||||||
|
|
||||||
auto x = ( cosf( angle ) * speed );
|
auto x = ( cosf( angle ) * speed );
|
||||||
auto y = stepPos.y;
|
auto y = stepPos.y;
|
||||||
auto z = ( sinf( angle ) * speed );
|
auto z = ( sinf( angle ) * speed );
|
||||||
|
|
||||||
|
|
||||||
face( stepPos );
|
face( stepPos );
|
||||||
setPos( { getPos().x + x, y, getPos().z + z } );
|
setPos( { getPos().x + x, y, getPos().z + z } );
|
||||||
sendPositionUpdate();
|
sendPositionUpdate();
|
||||||
|
|
Loading…
Add table
Reference in a new issue