1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

Merge pull request #552 from NotAdam/crowd

more retail accurate stacking, fix bnpcs not being pushed
This commit is contained in:
Mordred 2019-04-21 22:52:46 +02:00 committed by GitHub
commit 95512763ac
5 changed files with 19 additions and 18 deletions

View file

@ -98,14 +98,14 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX
auto bNpcBaseData = exdData->get< Data::BNpcBase >( m_bNpcBaseId );
assert( bNpcBaseData );
m_scale = bNpcBaseData->scale;
m_radius = bNpcBaseData->scale;
auto modelChara = exdData->get< Data::ModelChara >( bNpcBaseData->modelChara );
if( modelChara )
{
auto modelSkeleton = exdData->get< Data::ModelSkeleton >( modelChara->model );
if( modelSkeleton )
m_scale *= modelSkeleton->scaleFactor;
m_radius *= modelSkeleton->scaleFactor;
}
// todo: is this actually good?
@ -238,11 +238,11 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
return false;
}
pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
auto pos1 = pNaviProvider->getMovePos( *this );
if( Util::distance( pos1, pos ) < getScale() )
if( Util::distance( pos1, pos ) < getRadius() + 3.f )
{
// Reached destination
face( pos );
@ -250,7 +250,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
sendPositionUpdate();
//pNaviProvider->resetMoveTarget( *this );
pNaviProvider->updateAgentPosition( *this );
pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
return true;
}
@ -274,11 +274,11 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
return false;
}
pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
auto pos1 = pNaviProvider->getMovePos( *this );
if( Util::distance( pos1, targetChara.getPos() ) <= ( getScale() + targetChara.getScale() ) + 0.25f )
if( Util::distance( pos1, targetChara.getPos() ) <= ( getRadius() + targetChara.getRadius() ) + 3.f )
{
// Reached destination
face( targetChara.getPos() );
@ -286,7 +286,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
sendPositionUpdate();
//pNaviProvider->resetMoveTarget( *this );
pNaviProvider->updateAgentPosition( *this );
pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
return true;
}
@ -560,7 +560,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
break;
}
if( distance > ( getScale() + pHatedActor->getScale() ) )
if( distance > ( getRadius() + pHatedActor->getRadius() ) )
{
if( hasFlag( Immobile ) )
break;
@ -572,10 +572,11 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
moveTo( *pHatedActor );
}
if( ( distance - getScale() ) < 5 )
if( distance < ( getRadius() + pHatedActor->getRadius() + 3.f ) )
{
if( !hasFlag( TurningDisabled ) && face( pHatedActor->getPos() ) )
sendPositionUpdate();
// in combat range. ATTACK!
autoAttack( pHatedActor );
}

View file

@ -39,7 +39,7 @@ Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) :
m_targetId( INVALID_GAME_OBJECT_ID64 ),
m_pFw( std::move( std::move( pFw ) ) ),
m_directorId( 0 ),
m_scale( 2.f )
m_radius( 1.f )
{
m_lastTickTime = 0;
@ -715,7 +715,7 @@ void Sapphire::Entity::Chara::setAgentId( uint32_t agentId )
}
float Sapphire::Entity::Chara::getScale() const
float Sapphire::Entity::Chara::getRadius() const
{
return m_scale;
return m_radius;
}

View file

@ -132,7 +132,7 @@ namespace Sapphire::Entity
uint32_t m_agentId;
/*! Detour Crowd actor scale */
float m_scale;
float m_radius;
public:
Chara( Common::ObjKind type, FrameworkPtr pFw );
@ -278,7 +278,7 @@ namespace Sapphire::Entity
uint32_t getAgentId() const;
void setAgentId( uint32_t agentId );
float getScale() const;
float getRadius() const;
};

View file

@ -84,7 +84,7 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
m_queuedZoneing = nullptr;
m_status = ActorStatus::Idle;
m_invincibilityType = InvincibilityType::InvincibilityNone;
m_scale = 1.f;
m_radius = 1.f;
memset( m_questTracking, 0, sizeof( m_questTracking ) );
memset( m_name, 0, sizeof( m_name ) );

View file

@ -572,8 +572,8 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara )
std::memset( &params, 0, sizeof( params ) );
params.height = 3.f;
params.maxAcceleration = 25.f;
params.maxSpeed = std::pow( 2, chara.getScale() * 0.35f ) + 1.f;
params.radius = ( chara.getScale() ) * 0.75f;
params.maxSpeed = std::pow( 2, chara.getRadius() * 0.35f ) + 1.f;
params.radius = ( chara.getRadius() ) * 0.75f;
params.collisionQueryRange = params.radius * 12.0f;
params.pathOptimizationRange = params.radius * 20.0f;
params.updateFlags = 0;