Fix pets lagging behind and despawning by slightly adjusting speed
if too far from owner. Closes #8740
This commit is contained in:
1 parent
63ea4b1056
commit
8ce003700c
2 files changed
+22
-1
No files matched your search
@@ -12690,7 +12690,22 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
{
|
||||
// Set creature speed rate from CreatureInfo
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
|
||||
if (isPet() && !isInCombat())
|
||||
{
|
||||
// For every yard over 5, increase speed by 0.01
|
||||
// to help prevent pet from lagging behind and despawning
|
||||
float dist = GetDistance(GetCharmerOrOwner());
|
||||
float base_rate = 1.00f; // base speed is 100% of owner speed
|
||||
|
||||
if (dist < 5)
|
||||
dist = 5;
|
||||
|
||||
float mult = base_rate + ((dist - 5) * 0.01f);
|
||||
|
||||
speed *= GetCharmerOrOwner()->GetSpeedRate(mtype) * mult; // pets default to owner's speed when not in combat
|
||||
}
|
||||
else
|
||||
speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
|
||||
|
||||
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
|
||||
// TODO: possible affect only on MOVE_RUN
|
||||
|
||||
Reference in new issue
Block a user