mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-07-23 11:37: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 );
|
bnpc.moveTo( *pHatedActor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bnpc.hasFlag(Entity::Immobile) && distance > 30.0f )
|
||||||
|
{
|
||||||
|
bnpc.deaggro( pHatedActor );
|
||||||
|
}
|
||||||
|
|
||||||
if( pNaviProvider->syncPosToChara( bnpc ) )
|
if( pNaviProvider->syncPosToChara( bnpc ) )
|
||||||
bnpc.sendPositionUpdate();
|
bnpc.sendPositionUpdate();
|
||||||
|
|
||||||
|
|
|
@ -447,7 +447,10 @@ void BNpc::hateListClear()
|
||||||
for( auto& listEntry : m_hateList )
|
for( auto& listEntry : m_hateList )
|
||||||
{
|
{
|
||||||
if( isInRangeSet( listEntry->m_pChara ) )
|
if( isInRangeSet( listEntry->m_pChara ) )
|
||||||
deaggro( listEntry->m_pChara );
|
{
|
||||||
|
if( listEntry->m_pChara->isPlayer() )
|
||||||
|
notifyPlayerDeaggro( listEntry->m_pChara )
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_hateList.clear();
|
m_hateList.clear();
|
||||||
}
|
}
|
||||||
|
@ -623,22 +626,25 @@ void BNpc::aggro( const Sapphire::Entity::CharaPtr& pChara )
|
||||||
|
|
||||||
void BNpc::deaggro( const CharaPtr& pChara )
|
void BNpc::deaggro( const CharaPtr& pChara )
|
||||||
{
|
{
|
||||||
if( !hateListHasActor( pChara ) )
|
if( hateListHasActor( pChara ) )
|
||||||
hateListRemove( pChara );
|
hateListRemove( pChara );
|
||||||
|
|
||||||
if( pChara->isPlayer() )
|
if( pChara->isPlayer() )
|
||||||
{
|
notifyPlayerDeaggro(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() )
|
void BNpc::notifyPlayerDeaggro(const CharaPtr& pChara)
|
||||||
{
|
{
|
||||||
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
PlayerPtr tmpPlayer = pChara->getAsPlayer();
|
||||||
auto bnpc = *getAsBNpc();
|
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, 0, 1, 1 );
|
||||||
scriptMgr.onTriggerOwnerDeaggro( *tmpPlayer, bnpc );
|
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