Created
January 6, 2019 07:13
-
-
Save Langerz82/a201a3f0ab251dc265bb210600492d86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp | |
index 20a93451c9..06c490ad31 100644 | |
--- a/src/server/game/AI/CoreAI/PetAI.cpp | |
+++ b/src/server/game/AI/CoreAI/PetAI.cpp | |
@@ -257,7 +257,6 @@ void PetAI::UpdateAI(uint32 diff) | |
me->UpdateSpeed(MOVE_RUN); | |
me->UpdateSpeed(MOVE_WALK); | |
me->UpdateSpeed(MOVE_FLIGHT); | |
- | |
} | |
void PetAI::UpdateAllies() | |
@@ -518,8 +517,7 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) | |
// otherwise we're probably chasing a creature | |
if (me->GetCharmerOrOwner() && me->GetCharmInfo() && data == me->GetCharmerOrOwner()->GetGUID().GetCounter() && me->GetCharmInfo()->IsReturning()) | |
{ | |
- ClearCharmInfoFlags(); | |
- me->GetCharmInfo()->SetIsFollowing(true); | |
+ Follow(); | |
} | |
break; | |
} | |
@@ -528,6 +526,12 @@ void PetAI::MovementInform(uint32 moveType, uint32 data) | |
} | |
} | |
+void PetAI::Follow() | |
+{ | |
+ ClearCharmInfoFlags(); | |
+ me->GetCharmInfo()->SetIsFollowing(true); | |
+} | |
+ | |
bool PetAI::CanAttack(Unit* target) | |
{ | |
// Evaluates wether a pet can attack a specific target based on CommandState, ReactState and other flags | |
diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h | |
index d41a1080f6..af9deb3fe5 100644 | |
--- a/src/server/game/AI/CoreAI/PetAI.h | |
+++ b/src/server/game/AI/CoreAI/PetAI.h | |
@@ -52,6 +52,7 @@ class TC_GAME_API PetAI : public CreatureAI | |
void MoveInLineOfSight_Safe(Unit* /*who*/) { } // CreatureAI interferes with returning pets | |
void EnterEvadeMode(EvadeReason /*why*/) override { } // For fleeing, pets don't use this type of Evade mechanic | |
+ void Follow(); | |
private: | |
bool _needToStop(void); | |
void _stopAttack(void); | |
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp | |
index 06838cbc9c..46f9036b02 100644 | |
--- a/src/server/game/Entities/Pet/Pet.cpp | |
+++ b/src/server/game/Entities/Pet/Pet.cpp | |
@@ -1986,3 +1986,23 @@ std::string Pet::GetDebugInfo() const | |
<< "PetType: " << std::to_string(getPetType()); | |
return sstr.str(); | |
} | |
+ | |
+ | |
+bool Pet::IsMovementPreventedByCasting() const | |
+{ | |
+ // first check if currently a movement allowed channel is active and we're not casting | |
+ if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) | |
+ { | |
+ if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive()) | |
+ if (spell->GetSpellInfo()->IsMoveAllowedChannel()) | |
+ return false; | |
+ } | |
+ | |
+ if (const_cast<Pet*>(this)->IsFocusing(nullptr, true)) | |
+ return true; | |
+ | |
+ if (HasUnitState(UNIT_STATE_CASTING)) | |
+ return true; | |
+ | |
+ return false; | |
+} | |
diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h | |
index b5c2dcf2d9..66b209e5ca 100644 | |
--- a/src/server/game/Entities/Pet/Pet.h | |
+++ b/src/server/game/Entities/Pet/Pet.h | |
@@ -149,6 +149,8 @@ class TC_GAME_API Pet : public Guardian | |
std::string GetDebugInfo() const override; | |
+ bool IsMovementPreventedByCasting() const override; | |
+ | |
protected: | |
uint32 m_happinessTimer; | |
PetType m_petType; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment