1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-06-07 16:47:44 +00:00

rework setRunning by distance

This commit is contained in:
AriAvery 2019-02-01 12:53:00 +01:00
parent 1bbba84c5c
commit b3ee248778
3 changed files with 19 additions and 9 deletions

View file

@ -608,12 +608,12 @@ void Sapphire::Entity::BNpc::setBlind( bool state )
m_isBlind = state;
}
bool Sapphire::Entity::BNpc::isDeaf()
bool Sapphire::Entity::BNpc::getIsDeaf()
{
return m_isDeaf;
}
bool Sapphire::Entity::BNpc::isBlind()
bool Sapphire::Entity::BNpc::getIsBlind()
{
return m_isBlind;
}
@ -648,7 +648,7 @@ void Sapphire::Entity::BNpc::checkAggro()
if( distance < range )
{
if( ( !isBlind() && !isDeaf() ) || ( isBlind() && pClosestChara->getAsPlayer()->isRunning() ) || ( isDeaf() && isFacing( pClosestChara ) ) )
if( ( !getIsBlind() && !getIsDeaf() ) || ( getIsBlind() && pClosestChara->getAsPlayer()->isRunning() ) || ( getIsDeaf() && isFacing( pClosestChara ) ) )
aggro( pClosestChara );
}
}

View file

@ -98,9 +98,9 @@ namespace Sapphire::Entity
void setBlind( bool state );
bool isDeaf();
bool getIsDeaf();
bool isBlind();
bool getIsBlind();
void regainHp();

View file

@ -224,6 +224,19 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
( player.getPos().y != *reinterpret_cast< float* >( &copy.data[ 0x20 ] ) ) ||
( player.getPos().z != *reinterpret_cast< float* >( &copy.data[ 0x24 ] ) ) )
bPosChanged = true;
if( bPosChanged )
{
float distanceToNewPos = Util::distance( { player.getPos().x,
player.getPos().y,
player.getPos().z },
{ *reinterpret_cast< float* >( &copy.data[ 0x1C ] ),
*reinterpret_cast< float* >( &copy.data[ 0x20 ] ),
*reinterpret_cast< float* >( &copy.data[ 0x24 ] ) } );
//TODO: find a better value
player.setRunning( distanceToNewPos > 1.0f ? true : false );
}
if(!bPosChanged && player.getRot() == *reinterpret_cast< float* >( &copy.data[ 0x10 ] ))
return;
@ -256,7 +269,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
unk1 = 0x7F;
unk2 = 0x00;
unk4 = 0x3C;
player.setRunning( true );
}
if( moveType & MoveType::Strafing )
@ -268,7 +280,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
//else
// unk1 = 0x5f;
unk4 = 0x3C;
player.setRunning( false );
}
if( moveType & MoveType::Walking )
@ -277,7 +288,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
unk2 = 0x02;
unk3 = 0x00;
unk4 = 0x18;
player.setRunning( false );
}
if( moveType & MoveType::Walking && moveType & MoveType::Strafing )