diff options
-rwxr-xr-x | src/server/game/AI/CoreAI/PetAI.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 442da862b8a..5a0c199a4c0 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -141,13 +141,8 @@ void PetAI::UpdateAI(const uint32 diff) if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) continue; - // ignore some combinations of combat state and combat/noncombat spells - if (!me->getVictim()) + if (spellInfo->IsPositive()) { - // ignore attacking spells, and allow only self/around spells - if (!spellInfo->IsPositive()) - continue; - // non combat spells allowed // only pet spells have IsNonCombatSpell and not fit this reqs: // Consume Shadows, Lesser Invisibility, so ignore checks for its @@ -163,36 +158,21 @@ void PetAI::UpdateAI(const uint32 diff) if (cooldown >= 0 && duration >= 0 && cooldown > duration) continue; } - } - else - { - // just ignore non-combat spells - if (!spellInfo->CanBeUsedInCombat()) - continue; - } - Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); + Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); - // Fix to allow pets on STAY to autocast - if (me->getVictim() && _CanAttack(me->getVictim()) && spell->CanAutoCast(me->getVictim())) - { - targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell)); - continue; - } - else - { bool spellUsed = false; for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) { - Unit* Target = ObjectAccessor::GetUnit(*me, *tar); + Unit* target = ObjectAccessor::GetUnit(*me, *tar); //only buff targets that are in combat, unless the spell can only be cast while out of combat - if (!Target) + if (!target) continue; - if (spell->CanAutoCast(Target)) + if (spell->CanAutoCast(target)) { - targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(Target, spell)); + targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(target, spell)); spellUsed = true; break; } @@ -200,6 +180,14 @@ void PetAI::UpdateAI(const uint32 diff) if (!spellUsed) delete spell; } + else if (me->getVictim() && _CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat()) + { + Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); + if (spell->CanAutoCast(me->getVictim())) + targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell)); + else + delete spell; + } } //found units to cast on to |