mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
Merge pull request #552 from NotAdam/crowd
more retail accurate stacking, fix bnpcs not being pushed
This commit is contained in:
commit
95512763ac
5 changed files with 19 additions and 18 deletions
|
@ -98,14 +98,14 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX
|
||||||
auto bNpcBaseData = exdData->get< Data::BNpcBase >( m_bNpcBaseId );
|
auto bNpcBaseData = exdData->get< Data::BNpcBase >( m_bNpcBaseId );
|
||||||
assert( bNpcBaseData );
|
assert( bNpcBaseData );
|
||||||
|
|
||||||
m_scale = bNpcBaseData->scale;
|
m_radius = bNpcBaseData->scale;
|
||||||
|
|
||||||
auto modelChara = exdData->get< Data::ModelChara >( bNpcBaseData->modelChara );
|
auto modelChara = exdData->get< Data::ModelChara >( bNpcBaseData->modelChara );
|
||||||
if( modelChara )
|
if( modelChara )
|
||||||
{
|
{
|
||||||
auto modelSkeleton = exdData->get< Data::ModelSkeleton >( modelChara->model );
|
auto modelSkeleton = exdData->get< Data::ModelSkeleton >( modelChara->model );
|
||||||
if( modelSkeleton )
|
if( modelSkeleton )
|
||||||
m_scale *= modelSkeleton->scaleFactor;
|
m_radius *= modelSkeleton->scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: is this actually good?
|
// todo: is this actually good?
|
||||||
|
@ -238,11 +238,11 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
||||||
|
|
||||||
auto pos1 = pNaviProvider->getMovePos( *this );
|
auto pos1 = pNaviProvider->getMovePos( *this );
|
||||||
|
|
||||||
if( Util::distance( pos1, pos ) < getScale() )
|
if( Util::distance( pos1, pos ) < getRadius() + 3.f )
|
||||||
{
|
{
|
||||||
// Reached destination
|
// Reached destination
|
||||||
face( pos );
|
face( pos );
|
||||||
|
@ -250,7 +250,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
||||||
sendPositionUpdate();
|
sendPositionUpdate();
|
||||||
//pNaviProvider->resetMoveTarget( *this );
|
//pNaviProvider->resetMoveTarget( *this );
|
||||||
pNaviProvider->updateAgentPosition( *this );
|
pNaviProvider->updateAgentPosition( *this );
|
||||||
pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,11 +274,11 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
||||||
|
|
||||||
auto pos1 = pNaviProvider->getMovePos( *this );
|
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
|
// Reached destination
|
||||||
face( targetChara.getPos() );
|
face( targetChara.getPos() );
|
||||||
|
@ -286,7 +286,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
|
||||||
sendPositionUpdate();
|
sendPositionUpdate();
|
||||||
//pNaviProvider->resetMoveTarget( *this );
|
//pNaviProvider->resetMoveTarget( *this );
|
||||||
pNaviProvider->updateAgentPosition( *this );
|
pNaviProvider->updateAgentPosition( *this );
|
||||||
pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( distance > ( getScale() + pHatedActor->getScale() ) )
|
if( distance > ( getRadius() + pHatedActor->getRadius() ) )
|
||||||
{
|
{
|
||||||
if( hasFlag( Immobile ) )
|
if( hasFlag( Immobile ) )
|
||||||
break;
|
break;
|
||||||
|
@ -572,10 +572,11 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
||||||
moveTo( *pHatedActor );
|
moveTo( *pHatedActor );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( distance - getScale() ) < 5 )
|
if( distance < ( getRadius() + pHatedActor->getRadius() + 3.f ) )
|
||||||
{
|
{
|
||||||
if( !hasFlag( TurningDisabled ) && face( pHatedActor->getPos() ) )
|
if( !hasFlag( TurningDisabled ) && face( pHatedActor->getPos() ) )
|
||||||
sendPositionUpdate();
|
sendPositionUpdate();
|
||||||
|
|
||||||
// in combat range. ATTACK!
|
// in combat range. ATTACK!
|
||||||
autoAttack( pHatedActor );
|
autoAttack( pHatedActor );
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) :
|
||||||
m_targetId( INVALID_GAME_OBJECT_ID64 ),
|
m_targetId( INVALID_GAME_OBJECT_ID64 ),
|
||||||
m_pFw( std::move( std::move( pFw ) ) ),
|
m_pFw( std::move( std::move( pFw ) ) ),
|
||||||
m_directorId( 0 ),
|
m_directorId( 0 ),
|
||||||
m_scale( 2.f )
|
m_radius( 1.f )
|
||||||
{
|
{
|
||||||
|
|
||||||
m_lastTickTime = 0;
|
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;
|
||||||
}
|
}
|
|
@ -132,7 +132,7 @@ namespace Sapphire::Entity
|
||||||
uint32_t m_agentId;
|
uint32_t m_agentId;
|
||||||
|
|
||||||
/*! Detour Crowd actor scale */
|
/*! Detour Crowd actor scale */
|
||||||
float m_scale;
|
float m_radius;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Chara( Common::ObjKind type, FrameworkPtr pFw );
|
Chara( Common::ObjKind type, FrameworkPtr pFw );
|
||||||
|
@ -278,7 +278,7 @@ namespace Sapphire::Entity
|
||||||
uint32_t getAgentId() const;
|
uint32_t getAgentId() const;
|
||||||
void setAgentId( uint32_t agentId );
|
void setAgentId( uint32_t agentId );
|
||||||
|
|
||||||
float getScale() const;
|
float getRadius() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
|
||||||
m_queuedZoneing = nullptr;
|
m_queuedZoneing = nullptr;
|
||||||
m_status = ActorStatus::Idle;
|
m_status = ActorStatus::Idle;
|
||||||
m_invincibilityType = InvincibilityType::InvincibilityNone;
|
m_invincibilityType = InvincibilityType::InvincibilityNone;
|
||||||
m_scale = 1.f;
|
m_radius = 1.f;
|
||||||
|
|
||||||
memset( m_questTracking, 0, sizeof( m_questTracking ) );
|
memset( m_questTracking, 0, sizeof( m_questTracking ) );
|
||||||
memset( m_name, 0, sizeof( m_name ) );
|
memset( m_name, 0, sizeof( m_name ) );
|
||||||
|
|
|
@ -572,8 +572,8 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara )
|
||||||
std::memset( ¶ms, 0, sizeof( params ) );
|
std::memset( ¶ms, 0, sizeof( params ) );
|
||||||
params.height = 3.f;
|
params.height = 3.f;
|
||||||
params.maxAcceleration = 25.f;
|
params.maxAcceleration = 25.f;
|
||||||
params.maxSpeed = std::pow( 2, chara.getScale() * 0.35f ) + 1.f;
|
params.maxSpeed = std::pow( 2, chara.getRadius() * 0.35f ) + 1.f;
|
||||||
params.radius = ( chara.getScale() ) * 0.75f;
|
params.radius = ( chara.getRadius() ) * 0.75f;
|
||||||
params.collisionQueryRange = params.radius * 12.0f;
|
params.collisionQueryRange = params.radius * 12.0f;
|
||||||
params.pathOptimizationRange = params.radius * 20.0f;
|
params.pathOptimizationRange = params.radius * 20.0f;
|
||||||
params.updateFlags = 0;
|
params.updateFlags = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue