diff options
| author | treeston <treeston.mmoc@gmail.com> | 2016-03-23 18:09:15 +0100 | 
|---|---|---|
| committer | treeston <treeston.mmoc@gmail.com> | 2016-03-23 18:09:33 +0100 | 
| commit | 21cfacfba79312febf018b8924c359170569421b (patch) | |
| tree | 0405416a9e32cc4bddc0234c35293723be7a6a2a /src/server/game/Spells/Spell.cpp | |
| parent | 73a9e86c2a148ea16686d584cde810f934a1c578 (diff) | |
Entities/Pet: Finally fix pets spamming Blood Pact/Fel Intelligence in some scenarios. Your eardrums will thank me.
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 37 | 
1 files changed, 23 insertions, 14 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 2561ab57ca5..36f54fe17f6 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5702,27 +5702,36 @@ bool Spell::CanAutoCast(Unit* target)  {      ObjectGuid targetguid = target->GetGUID(); -    for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j) +    // check if target already has the same or a more powerful aura +    for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)      { -        if (m_spellInfo->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA) +        if (!GetSpellInfo()->Effects[i].IsAura()) +            continue; + +        AuraType const& auraType = AuraType(GetSpellInfo()->Effects[i].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, j)) +                case SPELL_GROUP_STACK_RULE_DEFAULT: +                    break; +                case SPELL_GROUP_STACK_RULE_EXCLUSIVE:                      return false; -            } -            else -            { -                if (AuraEffect* aureff = target->GetAuraEffect(m_spellInfo->Id, j)) -                    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(GetSpellInfo()->Effects[i].BasePoints) <= abs((*auraIt)->GetAmount()))                          return false; +                    break;              }          } -        else if (m_spellInfo->Effects[j].IsAreaAuraEffect()) -        { -            if (target->HasAuraEffect(m_spellInfo->Id, j)) -                return false; -        }      }      SpellCastResult result = CheckPetCast(target);  | 
