mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-07-22 19:17:45 +00:00
Fixed deaggro function to now remove entities from aggro list (without crashing the server)
This commit is contained in:
parent
044bff026c
commit
9b2ebd5d3e
2 changed files with 24 additions and 13 deletions
|
@ -48,6 +48,11 @@ void AI::Fsm::StateCombat::onUpdate( Entity::BNpc& bnpc, uint64_t tickCount )
|
|||
bnpc.moveTo( *pHatedActor );
|
||||
}
|
||||
|
||||
if (bnpc.hasFlag(Entity::Immobile) && distance > 30.0f )
|
||||
{
|
||||
bnpc.deaggro( pHatedActor );
|
||||
}
|
||||
|
||||
if( pNaviProvider->syncPosToChara( bnpc ) )
|
||||
bnpc.sendPositionUpdate();
|
||||
|
||||
|
|
|
@ -447,7 +447,10 @@ void BNpc::hateListClear()
|
|||
for( auto& listEntry : m_hateList )
|
||||
{
|
||||
if( isInRangeSet( listEntry->m_pChara ) )
|
||||
deaggro( listEntry->m_pChara );
|
||||
{
|
||||
if( listEntry->m_pChara->isPlayer() )
|
||||
notifyPlayerDeaggro( listEntry->m_pChara )
|
||||
}
|
||||
}
|
||||
m_hateList.clear();
|
||||
}
|
||||
|
@ -623,22 +626,25 @@ void BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
|||
|
||||
void BNpc::deaggro( const CharaPtr& pChara )
|
||||
{
|
||||
if( !hateListHasActor( pChara ) )
|
||||
if( hateListHasActor( pChara ) )
|
||||
hateListRemove( pChara );
|
||||
|
||||
if( pChara->isPlayer() )
|
||||
{
|
||||
PlayerPtr tmpPlayer = pChara->getAsPlayer();
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, 0, 1, 1 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), SetBattle );
|
||||
tmpPlayer->onMobDeaggro( *this );
|
||||
notifyPlayerDeaggro(pChara)
|
||||
}
|
||||
|
||||
if( getTriggerOwnerId() == pChara->getId() )
|
||||
{
|
||||
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||
auto bnpc = *getAsBNpc();
|
||||
scriptMgr.onTriggerOwnerDeaggro( *tmpPlayer, bnpc );
|
||||
}
|
||||
void BNpc::notifyPlayerDeaggro(const CharaPtr& pChara)
|
||||
{
|
||||
PlayerPtr tmpPlayer = pChara->getAsPlayer();
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, 0, 1, 1 );
|
||||
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), SetBattle );
|
||||
tmpPlayer->onMobDeaggro( *this );
|
||||
|
||||
if( getTriggerOwnerId() == pChara->getId() )
|
||||
{
|
||||
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||
auto bnpc = *getAsBNpc();
|
||||
scriptMgr.onTriggerOwnerDeaggro( *tmpPlayer, bnpc );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue