diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.cpp | 5 | ||||
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.h | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 22 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 1 |
4 files changed, 27 insertions, 3 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 2abe20f0ae6..9ef589ae3cd 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -134,7 +134,6 @@ void PetAI::UpdateAI(uint32 diff) // Autocast (cast only in combat or persistent spells in any state) if (!me->HasUnitState(UNIT_STATE_CASTING)) { - typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList; TargetSpellList targetSpellStore; for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i) @@ -222,7 +221,7 @@ void PetAI::UpdateAI(uint32 diff) } } - //found units to cast on to + // found units to cast on to if (!targetSpellStore.empty()) { TargetSpellList::iterator it = targetSpellStore.begin(); @@ -462,7 +461,7 @@ void PetAI::DoAttack(Unit* target, bool chase) ClearCharmInfoFlags(); me->GetCharmInfo()->SetIsCommandAttack(oldCmdAttack); // For passive pets commanded to attack so they will use spells me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveChase(target); + me->GetMotionMaster()->MoveChase(target, me->GetPetChaseDistance()); } else // (Stay && ((Aggressive || Defensive) && In Melee Range))) { diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 93ee6c41ece..1897dea449c 100644 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -25,6 +25,8 @@ class Creature; class Spell; +typedef std::vector<std::pair<Unit*, Spell*>> TargetSpellList; + class TC_GAME_API PetAI : public CreatureAI { public: diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 9df9d2ad53c..92b6e64ca72 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2575,6 +2575,28 @@ uint32 Creature::GetPetAutoSpellOnPos(uint8 pos) const return m_charmInfo->GetCharmSpell(pos)->GetAction(); } +float Creature::GetPetChaseDistance() const +{ + float range = MELEE_RANGE; + + for (uint8 i = 0; i < GetPetAutoSpellSize(); ++i) + { + uint32 spellID = GetPetAutoSpellOnPos(i); + if (!spellID) + continue; + + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID)) + { + if (spellInfo->GetRecoveryTime() == 0 && // No cooldown + spellInfo->RangeEntry->ID != 1 /*Self*/ && spellInfo->RangeEntry->ID != 2 /*Combat Range*/ && + spellInfo->GetMaxRange() > range) + range = spellInfo->GetMinRange(); + } + } + + return range; +} + void Creature::SetPosition(float x, float y, float z, float o) { // prevent crash when a bad coord is sent by the client diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index d79e55b623e..98ba6e5ccea 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -637,6 +637,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; } virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; } virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const; + float GetPetChaseDistance() const; void SetCannotReachTarget(bool cannotReach) { |