1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Merge pull request #482 from NotAdam/develop

fix bnpcs not despawning
This commit is contained in:
Mordred 2019-01-19 20:33:58 +01:00 committed by GitHub
commit a3652d4dbe
3 changed files with 17 additions and 10 deletions

View file

@ -130,6 +130,11 @@ void Sapphire::Entity::BNpc::spawn( PlayerPtr pTarget )
pTarget->queuePacket( std::make_shared< NpcSpawnPacket >( *getAsBNpc(), *pTarget ) );
}
void Sapphire::Entity::BNpc::despawn( PlayerPtr pTarget )
{
pTarget->freePlayerSpawnId( getId() );
}
Sapphire::Entity::BNpcState Sapphire::Entity::BNpc::getState() const
{
return m_state;
@ -306,6 +311,10 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
case BNpcState::Idle:
{
// passive mobs should ignore players unless aggro'd
if( m_aggressionMode == 1 )
return;
CharaPtr pClosestChara = getClosestChara();
if( pClosestChara && pClosestChara->isAlive() )

View file

@ -44,6 +44,7 @@ namespace Sapphire::Entity
virtual ~BNpc() override;
void spawn( PlayerPtr pTarget ) override;
void despawn( PlayerPtr pTarget ) override;
uint16_t getModelChara() const;
uint8_t getLevel() const override;

View file

@ -76,17 +76,14 @@ namespace Sapphire::Network::Packets::Server
m_data.bNPCName = bnpc.getBNpcNameId();
m_data.state = 1;
if( target.getId() == bnpc.getId() )
{
m_data.spawnIndex = 0x00;
}
else
{
assert( target.getId() != bnpc.getId() );
m_data.spawnIndex = target.getSpawnIdForActorId( bnpc.getId() );
if( !target.isActorSpawnIdValid( m_data.spawnIndex ) )
return;
}
// 0x20 == spawn hidden to be displayed by the spawneffect control
//m_data.displayFlags = bnpc.getDisplayFlags();