From 39b2467cd0557d21728f24bd76e6882d98dd85a0 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 11 Mar 2018 14:50:43 -0400 Subject: [PATCH] Core/Pets: Pet Attack Distance --- Source/Game/AI/CoreAI/PetAI.cs | 2 +- Source/Game/Entities/Creature/Creature.cs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/Game/AI/CoreAI/PetAI.cs b/Source/Game/AI/CoreAI/PetAI.cs index 00ac807c2..9738ef470 100644 --- a/Source/Game/AI/CoreAI/PetAI.cs +++ b/Source/Game/AI/CoreAI/PetAI.cs @@ -462,7 +462,7 @@ namespace Game.AI 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 { diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index d6a9de2d6..201a36cf3 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -2515,6 +2515,29 @@ namespace Game.Entities return GetCharmInfo().GetCharmSpell(pos).GetAction(); } + public float GetPetChaseDistance() + { + float range = SharedConst.MeleeRange; + + for (byte i = 0; i < GetPetAutoSpellSize(); ++i) + { + uint spellID = GetPetAutoSpellOnPos(i); + if (spellID == 0) + continue; + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellID); + if (spellInfo != null) + { + if (spellInfo.GetRecoveryTime() == 0 // No cooldown + && spellInfo.RangeEntry.Id != 1 /*Self*/ && spellInfo.RangeEntry.Id != 2 /*Combat Range*/ + && spellInfo.GetMinRange() > range) + range = spellInfo.GetMinRange(); + } + } + + return range; + } + public void SetCannotReachTarget(bool cannotReach) { if (cannotReach == m_cannotReachTarget)