aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp19
-rw-r--r--src/server/game/Spells/Spell.cpp35
2 files changed, 27 insertions, 27 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 46a0342fea5..e7d6fc077d9 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -224,26 +224,17 @@ void PetAI::UpdateAI(uint32 diff)
//found units to cast on to
if (!targetSpellStore.empty())
{
- uint32 index = urand(0, targetSpellStore.size() - 1);
+ TargetSpellList::iterator it = targetSpellStore.begin();
+ std::advance(it, urand(0, targetSpellStore.size() - 1));
- Spell* spell = targetSpellStore[index].second;
- Unit* target = targetSpellStore[index].first;
+ Spell* spell = (*it).second;
+ Unit* target = (*it).first;
- targetSpellStore.erase(targetSpellStore.begin() + index);
+ targetSpellStore.erase(it);
SpellCastTargets targets;
targets.SetUnitTarget(target);
- if (!me->HasInArc(float(M_PI), target))
- {
- me->SetInFront(target);
- if (target && target->GetTypeId() == TYPEID_PLAYER)
- me->SendUpdateToPlayer(target->ToPlayer());
-
- if (owner && owner->GetTypeId() == TYPEID_PLAYER)
- me->SendUpdateToPlayer(owner->ToPlayer());
- }
-
spell->prepare(&targets);
}
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);