aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-03-23 18:09:15 +0100
committerShauren <shauren.trinity@gmail.com>2016-04-09 17:32:24 +0200
commit7d8bab240b62c5196ae73a1c9360b23ebd697af9 (patch)
tree17a8a80e8d5ebb9053d9f47c89b06259e5d93968 /src/server/game/Spells/Spell.cpp
parentb359eda9b9ddb42b3306f9f26a6df085437c1aa8 (diff)
Entities/Pet: Finally fix pets spamming Blood Pact/Fel Intelligence in some scenarios. Your eardrums will thank me.
(cherry picked from commit 21cfacfba79312febf018b8924c359170569421b)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 6e8323de24e..97eb60e740f 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5810,30 +5810,39 @@ bool Spell::CanAutoCast(Unit* target)
{
ObjectGuid targetguid = target->GetGUID();
+ // check if target already has the same or a more powerful aura
for (SpellEffectInfo const* effect : GetEffects())
{
if (!effect)
continue;
- if (effect->Effect == SPELL_EFFECT_APPLY_AURA)
+ if (!effect->IsAura())
+ continue;
+
+ AuraType const& auraType = AuraType(effect->ApplyAuraName);
+ Unit::AuraEffectList const& auras = target->GetAuraEffectsByType(auraType);
+ for (Unit::AuraEffectList::const_iterator auraIt = auras.begin(); auraIt != auras.end(); ++auraIt)
{
- if (m_spellInfo->StackAmount <= 1)
+ if (GetSpellInfo()->Id == (*auraIt)->GetSpellInfo()->Id)
+ return false;
+
+ switch (sSpellMgr->CheckSpellGroupStackRules(GetSpellInfo(), (*auraIt)->GetSpellInfo()))
{
- if (target->HasAuraEffect(m_spellInfo->Id, effect->EffectIndex))
+ case SPELL_GROUP_STACK_RULE_DEFAULT:
+ break;
+ case SPELL_GROUP_STACK_RULE_EXCLUSIVE:
return false;
- }
- else
- {
- if (AuraEffect* aureff = target->GetAuraEffect(m_spellInfo->Id, effect->EffectIndex))
- if (aureff->GetBase()->GetStackAmount() >= m_spellInfo->StackAmount)
+ case SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER:
+ if (GetCaster() == (*auraIt)->GetCaster())
+ return false;
+ break;
+ case SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT: // this one has further checks, but i don't think they're necessary for autocast logic
+ case SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST:
+ if (abs(effect->BasePoints) <= abs((*auraIt)->GetAmount()))
return false;
+ break;
}
}
- else if (effect->IsAreaAuraEffect())
- {
- if (target->HasAuraEffect(m_spellInfo->Id, effect->EffectIndex))
- return false;
- }
}
SpellCastResult result = CheckPetCast(target);