aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-05 15:48:04 -0500
committermegamage <none@none>2009-08-05 15:48:04 -0500
commit9bc5334c00c97e3640230c29a551527ddd4b6c67 (patch)
tree8137a8cd34fc8c137ae4c6a0b09e2b0b2330e92d /src
parent11488f2063b6340630e38f50f0d64da69dd9dfb8 (diff)
[8297] Partly revert "[8291] Now allow auto-casting pet spells out of combat by PetAI, related code cleanups." Author: VladimirMangos
Use less stricted limitations for pet out-of-combat autoucasts. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/PetAI.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp
index 9515cbba46d..0fcc707b104 100644
--- a/src/game/PetAI.cpp
+++ b/src/game/PetAI.cpp
@@ -122,8 +122,8 @@ void PetAI::UpdateAI(const uint32 diff)
bool inCombat = me->getVictim();
- //Autocast (casted only in combat)
- if (inCombat && m_creature->GetGlobalCooldown() == 0 && !m_creature->hasUnitState(UNIT_STAT_CASTING))
+ // Autocast (casted only in combat or persistent spells in any state)
+ if (m_creature->GetGlobalCooldown() == 0 && !m_creature->hasUnitState(UNIT_STAT_CASTING))
{
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
TargetSpellList targetSpellStore;
@@ -139,12 +139,38 @@ void PetAI::UpdateAI(const uint32 diff)
continue;
// ignore some combinations of combat state and combat/noncombat spells
- if (IsNonCombatSpell(spellInfo))
- continue;
+ if (!inCombat)
+ {
+ // ignore attacking spells, and allow only self/around spells
+ if (!IsPositiveSpell(spellInfo->Id))
+ continue;
+
+ // non combat spells allowed
+ // only pet spells have IsNonCombatSpell and not fit this reqs:
+ // Consume Shadows, Lesser Invisibility, so ignore checks for its
+ if (!IsNonCombatSpell(spellInfo))
+ {
+ // allow only spell without spell cost or with spell cost but not duration limit
+ int32 duration = GetSpellDuration(spellInfo);
+ if ((spellInfo->manaCost || spellInfo->ManaCostPercentage || spellInfo->manaPerSecond) && duration > 0)
+ continue;
+
+ // allow only spell without cooldown > duration
+ int32 cooldown = GetSpellRecoveryTime(spellInfo);
+ if (cooldown >= 0 && duration >= 0 && cooldown > duration)
+ continue;
+ }
+ }
+ else
+ {
+ // just ignore non-combat spells
+ if (IsNonCombatSpell(spellInfo))
+ continue;
+ }
Spell *spell = new Spell(m_creature, spellInfo, false, 0);
- if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW) && spell->CanAutoCast(m_creature->getVictim()))
+ if (inCombat && !m_creature->hasUnitState(UNIT_STAT_FOLLOW) && spell->CanAutoCast(m_creature->getVictim()))
{
targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(m_creature->getVictim(), spell));
continue;