fix(Core/Leash): Improve leashing behavior and timer handling (#22525)

This commit is contained in:
Anton Popovichenko
2025-07-29 14:55:56 +02:00
committed by GitHub
parent 40c58123b1
commit 67aa022dbf
4 changed files with 51 additions and 7 deletions

View File

@@ -801,7 +801,7 @@ void Creature::Update(uint32 diff)
// Periodically check if able to move, if not, extend leash timer
if (diff >= m_extendLeashTime)
{
if (!CanFreeMove())
if (HasUnitState(UNIT_STATE_LOST_CONTROL))
UpdateLeashExtensionTime();
m_extendLeashTime = EXTEND_LEASH_CHECK_INTERVAL;
}
@@ -2685,10 +2685,11 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
float dist = sWorld->getFloatConfig(CONFIG_CREATURE_LEASH_RADIUS);
if (GetCharmerOrOwner())
if (Unit* unit = GetCharmerOrOwner())
{
dist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize() * 2, 150.0f);
return IsWithinDist(victim, dist);
float visibilityDist = std::min<float>(GetMap()->GetVisibilityRange() + GetObjectSize() * 2, 150.0f);
if (!victim->IsWithinDist(unit, visibilityDist))
return false;
}
if (!dist)