aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMrSmite <no_mail@email.com>2012-05-07 17:41:58 -0400
committerMrSmite <no_mail@email.com>2012-05-24 06:36:32 -0400
commit3ea75c50d019f1b29145bc974ae51039544beb16 (patch)
tree541957f85ef2c27344ee2a65d0a4baa2974e18c0 /src
parenta8a5b5a8f02bbb112abbb9ca418939f003c74a22 (diff)
Fixes broken autocast spells such as Furious Howl and Leap to cast when on autocast and "attack" is clicked.
Fixes wrong check for spell cooldown and removes check for duration (some spells with duration such as poison are stackable)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/AI/CoreAI/PetAI.cpp58
1 files changed, 39 insertions, 19 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index bcec8d273b9..14306c8861f 100755
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -153,40 +153,60 @@ void PetAI::UpdateAI(const uint32 diff)
if (spellInfo->IsPositive())
{
- // non combat spells allowed
- // only pet spells have IsNonCombatSpell and not fit this reqs:
- // Consume Shadows, Lesser Invisibility, so ignore checks for its
if (spellInfo->CanBeUsedInCombat())
{
- // allow only spell without spell cost or with spell cost but not duration limit
- int32 duration = spellInfo->GetDuration();
- if ((spellInfo->ManaCost || spellInfo->ManaCostPercentage || spellInfo->ManaPerSecond) && duration > 0)
+ // check spell cooldown
+ if (me->HasSpellCooldown(spellInfo->Id))
continue;
- // allow only spell without cooldown > duration
- int32 cooldown = spellInfo->GetRecoveryTime();
- if (cooldown >= 0 && duration >= 0 && cooldown > duration)
+ // Check if we're in combat or commanded to attack
+ if (!me->isInCombat() && !me->GetCharmInfo()->IsCommandAttack())
continue;
}
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
-
bool spellUsed = false;
- for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++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)
- continue;
-
- if (spell->CanAutoCast(target))
+ // Some spells can target enemy or friendly (DK Ghoul's Leap)
+ // Check for enemy first (pet then owner)
+ if (Unit* target = me->getAttackerForHelper())
+ {
+ if (CanAttack(target) && spell->CanAutoCast(target))
+ {
+ targetSpellStore.push_back(std::make_pair(target, spell));
+ spellUsed = true;
+ }
+ }
+ else if (Unit* target = me->GetCharmerOrOwner()->getAttackerForHelper())
+ {
+ if (CanAttack(target) && spell->CanAutoCast(target))
{
targetSpellStore.push_back(std::make_pair(target, spell));
spellUsed = true;
- break;
}
}
+
+ // No enemy, check friendly
+ if (!spellUsed)
+ {
+ for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++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)
+ continue;
+
+ if (spell->CanAutoCast(target))
+ {
+ targetSpellStore.push_back(std::make_pair(target, spell));
+ spellUsed = true;
+ break;
+ }
+ }
+ }
+
+ // No valid targets at all
if (!spellUsed)
delete spell;
}