From ed8ce173380ca99822951bdb0e396c7badd8bbf7 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 3 Aug 2009 00:05:22 +0400 Subject: [PATCH] [8297] Partly revert "[8291] Now allow auto-casting pet spells out of combat by PetAI, related code cleanups." Use less stricted limitations for pet out-of-combat autoucasts. --- src/game/PetAI.cpp | 36 +++++++++++++++++++++++++++++++----- src/shared/revision_nr.h | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 28341beef..7bc2c7cef 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -194,8 +194,8 @@ void PetAI::UpdateAI(const uint32 diff) } } - //Autocast (casted only in combat) - if (inCombat && m_creature->GetGlobalCooldown() == 0 && !m_creature->IsNonMeleeSpellCasted(false)) + // Autocast (casted only in combat or persistent spells in any state) + if (m_creature->GetGlobalCooldown() == 0 && !m_creature->IsNonMeleeSpellCasted(false)) { typedef std::vector > TargetSpellList; TargetSpellList targetSpellStore; @@ -211,12 +211,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(m_creature->getVictim(), spell)); continue; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7294c629e..22b5022ee 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8296" + #define REVISION_NR "8297" #endif // __REVISION_NR_H__ -- 2.11.4.GIT