mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-06-07 16:47:44 +00:00
fixed facing
This commit is contained in:
parent
b3ee248778
commit
12a2eae7fc
4 changed files with 14 additions and 5 deletions
|
@ -77,6 +77,15 @@ uint8_t Sapphire::Util::floatToUInt8Rot( float val )
|
|||
|
||||
float Sapphire::Util::RelativeAngle( float heading, float x1, float y1, float x2, float y2 )
|
||||
{
|
||||
float angle = ( ( float ) atan2( y2 - y1, x2 - x1 ) * ( 180.0 / PI ) );
|
||||
return clamp( angle - heading , -180.0f, 180.0f );
|
||||
float angle = ( (float)atan2( y2 - y1, x2 - x1 ) * ( 180.0 / PI ) );
|
||||
float value = angle - heading;
|
||||
|
||||
float high = 180.0f;
|
||||
float low = -180.0;
|
||||
|
||||
float range = high - low;
|
||||
float modifier = ( ( int ) ( ( value - low ) / range ) - ( value < low ? 1 : 0 ) ) * range;
|
||||
value -= modifier;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ std::string Sapphire::Entity::Chara::getName() const
|
|||
bool Sapphire::Entity::Chara::isFacing( Entity::CharaPtr target, float arcDegree )
|
||||
{
|
||||
auto angleBetween = Util::RelativeAngle( getRot(), getPos().x, getPos().y, target->getPos().x, target->getPos().y );
|
||||
return angleBetween >= ( -( arcDegree / 2 ) && angleBetween <= ( arcDegree / 2 ) );
|
||||
return angleBetween >= -( arcDegree / 2 ) && angleBetween <= ( arcDegree / 2 );
|
||||
}
|
||||
|
||||
/*! \return current stance of the actors */
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace Sapphire::Entity
|
|||
|
||||
std::string getName() const;
|
||||
|
||||
bool isFacing( Entity::CharaPtr target, float arcDegree = 100 );
|
||||
bool isFacing( Entity::CharaPtr target, float arcDegree = 80 );
|
||||
|
||||
bool face( const Common::FFXIVARR_POSITION3& p );
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
|||
float distanceToNewPos = Util::distance( { player.getPos().x,
|
||||
player.getPos().y,
|
||||
player.getPos().z },
|
||||
{ *reinterpret_cast< float* >( ©.data[ 0x1C ] ),
|
||||
{ *reinterpret_cast< float* >( ©.data[ 0x1C ] ),
|
||||
*reinterpret_cast< float* >( ©.data[ 0x20 ] ),
|
||||
*reinterpret_cast< float* >( ©.data[ 0x24 ] ) } );
|
||||
//TODO: find a better value
|
||||
|
|
Loading…
Add table
Reference in a new issue