1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-07-22 11:17:44 +00:00

Merge pull request #977 from Kooper16/dummy_fix

Dummy aggro fix
This commit is contained in:
hkAlice 2025-07-21 18:31:04 -03:00 committed by GitHub
commit 3d1797ff4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 14 deletions

View file

@ -35,9 +35,13 @@ void AI::Fsm::StateCombat::onUpdate( Entity::BNpc& bnpc, uint64_t tickCount )
auto distance = Common::Util::distance( bnpc.getPos(), pHatedActor->getPos() );
// All possibilities to automatically lose aggro go here
if( !bnpc.hasFlag( Entity::NoDeaggro ) )
{
if( bnpc.hasFlag( Entity::Immobile ) && distance > 40.0f )
{
bnpc.deaggro( pHatedActor );
}
}
if( !bnpc.hasFlag( Entity::Immobile ) && distance > ( bnpc.getNaviTargetReachedDistance() + pHatedActor->getRadius() ) )

View file

@ -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,10 +626,14 @@ 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() )
notifyPlayerDeaggro( pChara );
}
void BNpc::notifyPlayerDeaggro(const CharaPtr& pChara)
{
PlayerPtr tmpPlayer = pChara->getAsPlayer();
Network::Util::Packet::sendActorControl( getInRangePlayerIds(), getId(), ToggleWeapon, 0, 1, 1 );
@ -640,7 +647,6 @@ void BNpc::deaggro( const CharaPtr& pChara )
scriptMgr.onTriggerOwnerDeaggro( *tmpPlayer, bnpc );
}
}
}
void BNpc::onTick()
{

View file

@ -115,6 +115,7 @@ namespace Sapphire::Entity
void aggro( const CharaPtr& pChara );
void deaggro( const CharaPtr& pChara );
void notifyPlayerDeaggro( const CharaPtr& pChara );
void update( uint64_t tickCount ) override;
void onTick() override;