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() ); 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::NoDeaggro ) )
{ {
if( bnpc.hasFlag( Entity::Immobile ) && distance > 40.0f )
{
bnpc.deaggro( pHatedActor );
}
} }
if( !bnpc.hasFlag( Entity::Immobile ) && distance > ( bnpc.getNaviTargetReachedDistance() + pHatedActor->getRadius() ) ) if( !bnpc.hasFlag( Entity::Immobile ) && distance > ( bnpc.getNaviTargetReachedDistance() + pHatedActor->getRadius() ) )

View file

@ -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 );
} }
} }

View file

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