mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +00:00
minor cleanup, some improvements to bnpc avoidance
This commit is contained in:
parent
12e09da3ca
commit
e6c59935e6
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_modelEquip, pTemplate->getModelEquip(), sizeof( m_modelEquip ) );
|
||||
|
||||
m_lastTickTime = 0;
|
||||
|
||||
auto exdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
assert( exdData );
|
||||
|
||||
|
@ -641,6 +639,9 @@ void Sapphire::Entity::BNpc::pushNearbyBNpcs()
|
|||
// todo: not sure what's good here
|
||||
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
|
||||
if( distance > factor )
|
||||
continue;
|
||||
|
@ -650,9 +651,9 @@ void Sapphire::Entity::BNpc::pushNearbyBNpcs()
|
|||
auto x = ( cosf( angle ) );
|
||||
auto z = ( sinf( angle ) );
|
||||
|
||||
bNpc->setPos( pos.x + ( x * factor ),
|
||||
bNpc->setPos( pos.x + ( x * factor * delta ),
|
||||
pos.y,
|
||||
pos.z + ( z * factor ) );
|
||||
pos.z + ( z * factor * delta ) );
|
||||
|
||||
// setPos( m_pos.x + ( xBase * -pushDistance ),
|
||||
// m_pos.y,
|
||||
|
|
|
@ -40,6 +40,10 @@ Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) :
|
|||
m_targetId( INVALID_GAME_OBJECT_ID64 ),
|
||||
m_pFw( std::move( std::move( pFw ) ) )
|
||||
{
|
||||
|
||||
m_lastTickTime = 0;
|
||||
m_lastUpdate = 0;
|
||||
|
||||
// initialize the free slot queue
|
||||
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();
|
||||
}
|
||||
|
||||
int64_t Sapphire::Entity::Chara::getLastUpdateTime() const
|
||||
{
|
||||
return m_lastUpdate;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,8 @@ namespace Sapphire::Entity
|
|||
|
||||
virtual void calculateStats() {};
|
||||
|
||||
int64_t getLastUpdateTime() const;
|
||||
|
||||
/// Status effect functions
|
||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue