Skip to content

Commit

Permalink
Spells: Allow secondary target checking for area auras
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Jun 17, 2023
1 parent dc5621b commit d36511d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/game/Entities/DynamicObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ void DynamicObject::OnPersistentAreaAuraEnd()
m_auraScript->OnPersistentAreaAuraEnd(this);
}

bool DynamicObject::OnAreaAuraCheckTarget(Aura* aura, Unit* target)
bool DynamicObject::OnAreaAuraCheckTarget(Unit* target)
{
if (aura->GetAuraScript())
return aura->GetAuraScript()->OnAreaAuraCheckTarget(aura, target);
if (m_auraScript)
return m_auraScript->OnAreaAuraCheckTarget(this, target);
return true;
}
2 changes: 1 addition & 1 deletion src/game/Entities/DynamicObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DynamicObject : public WorldObject
bool CanAssistSpell(Unit const* target, SpellEntry const* spellInfo = nullptr) const override;

void OnPersistentAreaAuraEnd();
bool OnAreaAuraCheckTarget(Aura* aura, Unit* target);
bool OnAreaAuraCheckTarget(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
Expand Down
6 changes: 2 additions & 4 deletions src/game/Grids/GridNotifiersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
}
}

i_dynobject.OnAreaAuraCheckTarget(target);

if (spellInfo->HasAttribute(SPELL_ATTR_EX3_ONLY_ON_PLAYER) && target->GetTypeId() != TYPEID_PLAYER)
return;

Expand All @@ -284,8 +286,6 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
if (!holder->GetAuraByEffectIndex(eff_index))
{
PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, &i_dynobject.GetDamage(), &i_dynobject.GetBasePoints(), holder, target, caster);
if (!i_dynobject.OnAreaAuraCheckTarget(Aur, target))
return;
holder->AddAura(Aur, eff_index);
target->AddAuraToModList(Aur);
Aur->ApplyModifier(true, true);
Expand All @@ -300,8 +300,6 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
{
holder = CreateSpellAuraHolder(spellInfo, target, caster);
PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, &i_dynobject.GetDamage(), &i_dynobject.GetBasePoints(), holder, target, caster);
if (!i_dynobject.OnAreaAuraCheckTarget(Aur, target))
return;
holder->SetAuraDuration(i_dynobject.GetDuration());
holder->AddAura(Aur, eff_index);
if (!target->AddSpellAuraHolder(holder))
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/Scripts/SpellScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct AuraScript
// called on persistent area aura dyngo lifetime end
virtual void OnPersistentAreaAuraEnd(DynamicObject* /*dynGo*/) const {}
// called on AreaAura target selection
virtual bool OnAreaAuraCheckTarget(Aura* aura, Unit* target) const { return true; }
virtual bool OnAreaAuraCheckTarget(DynamicObject* /*dynGo*/, Unit* /*target*/) const { return true; }
// called on unit heartbeat
virtual void OnHeartbeat(Aura* /*aura*/) const {}
// used to override SPELL_AURA_TRANSFORM or SPELL_AURA_MOD_SHAPESHIFT display id - more uses in future
Expand Down

0 comments on commit d36511d

Please sign in to comment.