1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +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 ) ); 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 Sapphire::Entity::BNpcState Sapphire::Entity::BNpc::getState() const
{ {
return m_state; return m_state;
@ -306,6 +311,10 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
case BNpcState::Idle: case BNpcState::Idle:
{ {
// passive mobs should ignore players unless aggro'd
if( m_aggressionMode == 1 )
return;
CharaPtr pClosestChara = getClosestChara(); CharaPtr pClosestChara = getClosestChara();
if( pClosestChara && pClosestChara->isAlive() ) if( pClosestChara && pClosestChara->isAlive() )

View file

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

View file

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