mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 08:27:46 +00:00
minor cleanup, some improvements to bnpc avoidance
This commit is contained in:
parent
dc89f0af10
commit
31cb9ba97c
3 changed files with 15 additions and 4 deletions
|
@ -90,8 +90,6 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX
|
||||||
memcpy( m_customize, pTemplate->getCustomize(), sizeof( m_customize ) );
|
memcpy( m_customize, pTemplate->getCustomize(), sizeof( m_customize ) );
|
||||||
memcpy( m_modelEquip, pTemplate->getModelEquip(), sizeof( m_modelEquip ) );
|
memcpy( m_modelEquip, pTemplate->getModelEquip(), sizeof( m_modelEquip ) );
|
||||||
|
|
||||||
m_lastTickTime = 0;
|
|
||||||
|
|
||||||
auto exdData = m_pFw->get< Data::ExdDataGenerated >();
|
auto exdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||||
assert( exdData );
|
assert( exdData );
|
||||||
|
|
||||||
|
@ -641,6 +639,9 @@ void Sapphire::Entity::BNpc::pushNearbyBNpcs()
|
||||||
// todo: not sure what's good here
|
// todo: not sure what's good here
|
||||||
auto factor = bNpc->getNaviTargetReachedDistance();
|
auto factor = bNpc->getNaviTargetReachedDistance();
|
||||||
|
|
||||||
|
auto delta = static_cast< float >( Util::getTimeMs() - bNpc->getLastUpdateTime() ) / 1000.f;
|
||||||
|
delta = std::min< float >( factor, delta );
|
||||||
|
|
||||||
// too far away, ignore it
|
// too far away, ignore it
|
||||||
if( distance > factor )
|
if( distance > factor )
|
||||||
continue;
|
continue;
|
||||||
|
@ -650,9 +651,9 @@ void Sapphire::Entity::BNpc::pushNearbyBNpcs()
|
||||||
auto x = ( cosf( angle ) );
|
auto x = ( cosf( angle ) );
|
||||||
auto z = ( sinf( angle ) );
|
auto z = ( sinf( angle ) );
|
||||||
|
|
||||||
bNpc->setPos( pos.x + ( x * factor ),
|
bNpc->setPos( pos.x + ( x * factor * delta ),
|
||||||
pos.y,
|
pos.y,
|
||||||
pos.z + ( z * factor ) );
|
pos.z + ( z * factor * delta ) );
|
||||||
|
|
||||||
// setPos( m_pos.x + ( xBase * -pushDistance ),
|
// setPos( m_pos.x + ( xBase * -pushDistance ),
|
||||||
// m_pos.y,
|
// m_pos.y,
|
||||||
|
|
|
@ -40,6 +40,10 @@ 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_lastTickTime = 0;
|
||||||
|
m_lastUpdate = 0;
|
||||||
|
|
||||||
// initialize the free slot queue
|
// initialize the free slot queue
|
||||||
for( uint8_t i = 0; i < MAX_STATUS_EFFECTS; i++ )
|
for( uint8_t i = 0; i < MAX_STATUS_EFFECTS; i++ )
|
||||||
{
|
{
|
||||||
|
@ -791,3 +795,7 @@ bool Sapphire::Entity::Chara::hasStatusEffect( uint32_t id )
|
||||||
return m_statusEffectMap.find( id ) != m_statusEffectMap.end();
|
return m_statusEffectMap.find( id ) != m_statusEffectMap.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t Sapphire::Entity::Chara::getLastUpdateTime() const
|
||||||
|
{
|
||||||
|
return m_lastUpdate;
|
||||||
|
}
|
||||||
|
|
|
@ -118,6 +118,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
virtual void calculateStats() {};
|
virtual void calculateStats() {};
|
||||||
|
|
||||||
|
int64_t getLastUpdateTime() const;
|
||||||
|
|
||||||
/// Status effect functions
|
/// Status effect functions
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue