diff --git a/src/game/Entities/DynamicObject.cpp b/src/game/Entities/DynamicObject.cpp index 16a5271e534..a7261315fb5 100644 --- a/src/game/Entities/DynamicObject.cpp +++ b/src/game/Entities/DynamicObject.cpp @@ -216,3 +216,9 @@ void DynamicObject::OnPersistentAreaAuraEnd() m_auraScript->OnPersistentAreaAuraEnd(this); } +bool DynamicObject::OnPersistentAreaAuraCheckTarget(Unit* target) +{ + if (m_auraScript) + return m_auraScript->OnPersistentAreaAuraCheckTarget(this, target); + return true; +} diff --git a/src/game/Entities/DynamicObject.h b/src/game/Entities/DynamicObject.h index 7da3af36794..bb3a0ee1cfe 100644 --- a/src/game/Entities/DynamicObject.h +++ b/src/game/Entities/DynamicObject.h @@ -71,6 +71,7 @@ class DynamicObject : public WorldObject bool CanAssistSpell(Unit const* target, SpellEntry const* spellInfo = nullptr) const override; void OnPersistentAreaAuraEnd(); + bool OnPersistentAreaAuraCheckTarget(Unit* target); float GetObjectBoundingRadius() const override { return 0.f; } // dynamic object not have real interact size float GetCollisionHeight() const override { return 1.f; } // to get away with ground collision diff --git a/src/game/Grids/GridNotifiersImpl.h b/src/game/Grids/GridNotifiersImpl.h index 0ae0da9d292..911d8fb55e7 100644 --- a/src/game/Grids/GridNotifiersImpl.h +++ b/src/game/Grids/GridNotifiersImpl.h @@ -258,6 +258,9 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) } } + if (!i_dynobject.OnPersistentAreaAuraCheckTarget(target)) + return; + if (spellInfo->HasAttribute(SPELL_ATTR_EX3_ONLY_ON_PLAYER) && target->GetTypeId() != TYPEID_PLAYER) return; diff --git a/src/game/Spells/Scripts/SpellScript.h b/src/game/Spells/Scripts/SpellScript.h index 6959858f886..6248a53d2c5 100644 --- a/src/game/Spells/Scripts/SpellScript.h +++ b/src/game/Spells/Scripts/SpellScript.h @@ -127,6 +127,8 @@ struct AuraScript virtual void OnPeriodicTickEnd(Aura* /*aura*/) const {} // called on persistent area aura dyngo lifetime end virtual void OnPersistentAreaAuraEnd(DynamicObject* /*dynGo*/) const {} + // called on AreaAura target selection + virtual bool OnPersistentAreaAuraCheckTarget(DynamicObject* /*dynGo*/, Unit* /*target*/) const { return true; } // called on unit heartbeat virtual void OnHeartbeat(Aura* /*aura*/) const {} // called on affect check of aura - spellInfo can be nullptr in case of melee