diff options
author | ccrs <ccrs@users.noreply.github.com> | 2016-11-28 01:22:46 +0100 |
---|---|---|
committer | DoctorKraft <DoctorKraft@users.noreply.github.com> | 2018-03-11 16:42:38 +0100 |
commit | 1c46e7ca8414c7398f2e638bbcbadaceab53f327 (patch) | |
tree | d73c0657932360602a013a8b211699c98aee66e3 | |
parent | 75f36787d2afd851343adc34fca40f391fe6e679 (diff) |
Core/Pets: Pet Attack Distance
(cherry picked from commit 2d1ef6b5b0bf9aedf9453e6a8b41210271399d42)
typo fix
by ccrs
(cherry picked from commit b049caf62fff5c8196a1ccc4ac4e825a97660eab)
-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 d49725fb732..f30b2369e91 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -135,7 +135,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) @@ -223,7 +222,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(); @@ -463,7 +462,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 fd1a03ada10..b4f4bc82838 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 8fa76b560b2..1c8bafc43ec 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2701,6 +2701,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->GetMinRange() > 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 4fff15be6ca..ace1bba8734 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -279,6 +279,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) { if (cannotReach == m_cannotReachTarget) return; m_cannotReachTarget = cannotReach; m_cannotReachTimer = 0; } bool CanNotReachTarget() const { return m_cannotReachTarget; } |