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:
parent
1bbba84c5c
commit
b3ee248778
3 changed files with 19 additions and 9 deletions
|
@ -608,12 +608,12 @@ void Sapphire::Entity::BNpc::setBlind( bool state )
|
||||||
m_isBlind = state;
|
m_isBlind = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Entity::BNpc::isDeaf()
|
bool Sapphire::Entity::BNpc::getIsDeaf()
|
||||||
{
|
{
|
||||||
return m_isDeaf;
|
return m_isDeaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Entity::BNpc::isBlind()
|
bool Sapphire::Entity::BNpc::getIsBlind()
|
||||||
{
|
{
|
||||||
return m_isBlind;
|
return m_isBlind;
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ void Sapphire::Entity::BNpc::checkAggro()
|
||||||
|
|
||||||
if( distance < range )
|
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 );
|
aggro( pClosestChara );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,9 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
void setBlind( bool state );
|
void setBlind( bool state );
|
||||||
|
|
||||||
bool isDeaf();
|
bool getIsDeaf();
|
||||||
|
|
||||||
bool isBlind();
|
bool getIsBlind();
|
||||||
|
|
||||||
void regainHp();
|
void regainHp();
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,20 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
||||||
( player.getPos().y != *reinterpret_cast< float* >( ©.data[ 0x20 ] ) ) ||
|
( player.getPos().y != *reinterpret_cast< float* >( ©.data[ 0x20 ] ) ) ||
|
||||||
( player.getPos().z != *reinterpret_cast< float* >( ©.data[ 0x24 ] ) ) )
|
( player.getPos().z != *reinterpret_cast< float* >( ©.data[ 0x24 ] ) ) )
|
||||||
bPosChanged = true;
|
bPosChanged = true;
|
||||||
if( !bPosChanged && player.getRot() == *reinterpret_cast< float* >( ©.data[ 0x10 ] ) )
|
|
||||||
|
if( bPosChanged )
|
||||||
|
{
|
||||||
|
float distanceToNewPos = Util::distance( { player.getPos().x,
|
||||||
|
player.getPos().y,
|
||||||
|
player.getPos().z },
|
||||||
|
{ *reinterpret_cast< float* >( ©.data[ 0x1C ] ),
|
||||||
|
*reinterpret_cast< float* >( ©.data[ 0x20 ] ),
|
||||||
|
*reinterpret_cast< float* >( ©.data[ 0x24 ] ) } );
|
||||||
|
//TODO: find a better value
|
||||||
|
player.setRunning( distanceToNewPos > 1.0f ? true : false );
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!bPosChanged && player.getRot() == *reinterpret_cast< float* >( ©.data[ 0x10 ] ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.setRot( *reinterpret_cast< float* >( ©.data[ 0x10 ] ) );
|
player.setRot( *reinterpret_cast< float* >( ©.data[ 0x10 ] ) );
|
||||||
|
@ -256,7 +269,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
||||||
unk1 = 0x7F;
|
unk1 = 0x7F;
|
||||||
unk2 = 0x00;
|
unk2 = 0x00;
|
||||||
unk4 = 0x3C;
|
unk4 = 0x3C;
|
||||||
player.setRunning( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( moveType & MoveType::Strafing )
|
if( moveType & MoveType::Strafing )
|
||||||
|
@ -268,7 +280,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
||||||
//else
|
//else
|
||||||
// unk1 = 0x5f;
|
// unk1 = 0x5f;
|
||||||
unk4 = 0x3C;
|
unk4 = 0x3C;
|
||||||
player.setRunning( false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( moveType & MoveType::Walking )
|
if( moveType & MoveType::Walking )
|
||||||
|
@ -277,7 +288,6 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
||||||
unk2 = 0x02;
|
unk2 = 0x02;
|
||||||
unk3 = 0x00;
|
unk3 = 0x00;
|
||||||
unk4 = 0x18;
|
unk4 = 0x18;
|
||||||
player.setRunning( false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( moveType & MoveType::Walking && moveType & MoveType::Strafing )
|
if( moveType & MoveType::Walking && moveType & MoveType::Strafing )
|
||||||
|
|
Loading…
Add table
Reference in a new issue