fix(Core/Unit): Avoid resetting leash timer when not necessary. (#27390)

This commit is contained in:
AlsoNotMehh
2026-09-24 11:47:04 -03:00
committed by GitHub
parent 746a298841
commit ec218ca8f9
2 changed files with 9 additions and 16 deletions
+7 -1
View File
@@ -1264,7 +1264,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
if (!victim->IsPlayer())
{
/// @fix: Hack to avoid premature leashing
// DoT ticks and passive damage (e.g. Thorns) do not reset leash timer
if (damagetype != DOT && damage > 0 && !victim->GetOwnerGUID().IsPlayer() && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD)))
victim->ToCreature()->UpdateLeashExtensionTime();
@@ -11199,6 +11199,12 @@ void Unit::AtTargetAttacked(Unit* target, bool canInitialAggro)
if (!target->IsEngaged() && !canInitialAggro)
return;
if (Creature* cTarget = target->ToCreature())
{
if (!cTarget->GetOwnerGUID().IsPlayer())
cTarget->UpdateLeashExtensionTime();
}
target->EngageWithTarget(this);
if (Unit* targetOwner = target->GetCharmerOrOwner())
targetOwner->EngageWithTarget(this);
@@ -234,12 +234,8 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
_lastTargetPosition.reset();
if (cOwner)
{
if (!isStoppedBecauseOfCasting)
cOwner->UpdateLeashExtensionTime();
cOwner->SetCannotReachTarget();
}
return true;
}
@@ -317,16 +313,7 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
if (cOwner)
{
if (owner->movespline->Finalized() && cOwner->IsWithinMeleeRange(target))
{ // Mobs should chase you infinitely if you stop and wait every few seconds.
i_leashExtensionTimer.Update(time_diff);
if (i_leashExtensionTimer.Passed())
{
i_leashExtensionTimer.Reset(cOwner->GetAttackTime(BASE_ATTACK));
cOwner->UpdateLeashExtensionTime();
}
}
else if (i_recalculateTravel)
if (i_recalculateTravel)
i_leashExtensionTimer.Reset(cOwner->GetAttackTime(BASE_ATTACK));
}