fix(Core/Pets): Pets should update speed out of combat only if are following their owner. (#6207)
- Closes #5250 - Closes chromiecraft/chromiecraft#406
This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
#include "SpellAuras.h"
|
#include "SpellAuras.h"
|
||||||
#include "SpellInfo.h"
|
#include "SpellInfo.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
|
#include "TargetedMovementGenerator.h"
|
||||||
#include "TemporarySummon.h"
|
#include "TemporarySummon.h"
|
||||||
#include "Totem.h"
|
#include "Totem.h"
|
||||||
#include "TotemAI.h"
|
#include "TotemAI.h"
|
||||||
@@ -13583,19 +13584,24 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
|||||||
{
|
{
|
||||||
if (GetTypeId() == TYPEID_UNIT)
|
if (GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
Unit* pOwner = GetCharmerOrOwner();
|
Unit* followed = nullptr;
|
||||||
if (pOwner && !IsInCombat() && !IsVehicle() && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) && (IsPet() || IsGuardian() || GetGUID() == pOwner->GetCritterGUID() || GetCharmerGUID() == pOwner->GetGUID()))
|
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE)
|
||||||
{
|
{
|
||||||
if (pOwner->GetTypeId() != TYPEID_PLAYER)
|
followed = static_cast<FollowMovementGenerator<Creature>const*>(GetMotionMaster()->top())->GetTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (followed && !IsInCombat() && !IsVehicle() && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) && (IsPet() || IsGuardian() || GetGUID() == followed->GetCritterGUID() || GetCharmerOrOwnerGUID() == followed->GetGUID()))
|
||||||
{
|
{
|
||||||
if (speed < pOwner->GetSpeedRate(mtype) + 0.1f)
|
if (followed->GetTypeId() != TYPEID_PLAYER)
|
||||||
speed = pOwner->GetSpeedRate(mtype) + 0.1f; // pets derive speed from owner when not in combat
|
{
|
||||||
|
if (speed < followed->GetSpeedRate(mtype) + 0.1f)
|
||||||
|
speed = followed->GetSpeedRate(mtype) + 0.1f; // pets derive speed from owner when not in combat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// special treatment for player pets in order to avoid stuttering
|
// special treatment for player pets in order to avoid stuttering
|
||||||
float ownerSpeed = pOwner->GetSpeedRate(mtype);
|
float ownerSpeed = followed->GetSpeedRate(mtype);
|
||||||
float distOwner = GetDistance(pOwner);
|
float distOwner = GetDistance(followed);
|
||||||
float minDist = 2.5f;
|
float minDist = 2.5f;
|
||||||
|
|
||||||
if (ToCreature()->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
if (ToCreature()->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
||||||
|
|||||||
Reference in New Issue
Block a user