Skip to content

Commit

Permalink
Spells: Allow secondary target checking for area auras
Browse files Browse the repository at this point in the history
Closes #456
  • Loading branch information
insunaa authored and killerwife committed Jan 8, 2024
1 parent e43d31b commit db3f104
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/game/Spells/Scripts/SpellScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ struct AuraScript
virtual bool OnPersistentAreaAuraCheckTarget(DynamicObject* /*dynGo*/, Unit* /*target*/) const { return true; }
// called on unit heartbeat
virtual void OnHeartbeat(Aura* /*aura*/) const {}
// called on AreaAura target checking
virtual bool OnAreaAuraCheckTarget(Aura const* aura, Unit* target) const { return true; }
// called on affect check of aura - spellInfo can be nullptr in case of melee
virtual bool OnAffectCheck(Aura const* /*aura*/, SpellEntry const* /*spellInfo*/) const { return true; }
// used to override SPELL_AURA_TRANSFORM or SPELL_AURA_MOD_SHAPESHIFT display id - more uses in future
Expand Down
10 changes: 10 additions & 0 deletions src/game/Spells/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,13 @@ AreaAura::~AreaAura()
{
}

bool AreaAura::OnAreaAuraCheckTarget(Unit* target) const
{
if (AuraScript* script = GetAuraScript())
return script->OnAreaAuraCheckTarget(this, target);
return true;
}

PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 const* currentDamage, int32 const* currentBasePoints, SpellAuraHolder* holder, Unit* target,
Unit* caster, Item* castItem) : Aura(spellproto, eff, currentDamage, currentBasePoints, holder, target, caster, castItem)
{
Expand Down Expand Up @@ -691,6 +698,9 @@ void AreaAura::Update(uint32 diff)

for (auto& target : targets)
{
if (!OnAreaAuraCheckTarget(target))
continue;

// flag for selection is need apply aura to current iteration target
bool apply = true;

Expand Down
2 changes: 2 additions & 0 deletions src/game/Spells/SpellAuras.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ class AreaAura : public Aura
public:
AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 const* currentDamage, int32 const* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = nullptr, Item* castItem = nullptr, uint32 originalRankSpellId = 0);
virtual ~AreaAura();

bool OnAreaAuraCheckTarget(Unit* target) const;
protected:
void Update(uint32 diff) override;
private:
Expand Down

0 comments on commit db3f104

Please sign in to comment.