fix(Core/Pet): Fixed set hunter pet's speed on load. (#15206)

This commit is contained in:
UltraNix
2023-03-04 21:41:10 +01:00
committed by GitHub
parent d68913d1df
commit ac0581bd43
3 changed files with 18 additions and 17 deletions

View File

@@ -10700,11 +10700,6 @@ void Unit::SetMinion(Minion* minion, bool apply)
// PvP, FFAPvP
minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
// FIXME: hack, speed must be set only at follow
if (GetTypeId() == TYPEID_PLAYER && minion->IsPet())
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
// Ghoul pets have energy instead of mana (is anywhere better place for this code?)
if (minion->IsPetGhoul() || minion->GetEntry() == 24207 /*ENTRY_ARMY_OF_THE_DEAD*/)
minion->setPowerType(POWER_ENERGY);
@@ -14251,7 +14246,17 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
{
// Set creature speed rate
if (GetTypeId() == TYPEID_UNIT)
speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
{
if (IsPet() && ToPet()->isControlled() && IsControlledByPlayer())
{
// contant value for player pets
speed *= 1.15f;
}
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
@@ -15380,7 +15385,7 @@ void Unit::SetHealth(uint32 val)
SetUInt32Value(UNIT_FIELD_HEALTH, val);
// mobs that are now or were below 30% need to update their speed
if (GetTypeId() == TYPEID_UNIT && (prevHealthPct < 30.0 || HealthBelowPct(30)))
if (GetTypeId() == TYPEID_UNIT && !(IsPet() && ToPet()->isControlled() && IsControlledByPlayer()) && (prevHealthPct < 30.0 || HealthBelowPct(30)))
{
UpdateSpeed(MOVE_RUN, false);
}