mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 00:23:48 +00:00
fix(Core/Leash): Improve leashing behavior and timer handling (#22525)
This commit is contained in:
committed by
GitHub
parent
40c58123b1
commit
67aa022dbf
@@ -72,15 +72,27 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
|
||||
return false;
|
||||
|
||||
Creature* cOwner = owner->ToCreature();
|
||||
bool isStoppedBecauseOfCasting = cOwner && cOwner->IsMovementPreventedByCasting();
|
||||
|
||||
// the owner might be unable to move (rooted or casting), or we have lost the target, pause movement
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || HasLostTarget(owner) || (cOwner && cOwner->IsMovementPreventedByCasting()))
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || HasLostTarget(owner) || isStoppedBecauseOfCasting)
|
||||
{
|
||||
owner->StopMoving();
|
||||
_lastTargetPosition.reset();
|
||||
if (cOwner)
|
||||
{
|
||||
cOwner->UpdateLeashExtensionTime();
|
||||
if (isStoppedBecauseOfCasting)
|
||||
{
|
||||
// Don't reset leash timer if it's a spell like Shoot with a short cast time.
|
||||
/// @todo: Research how it should actually work.
|
||||
Spell *spell = cOwner->GetFirstCurrentCastingSpell();
|
||||
bool spellHasLongCast = spell && spell->GetCastTime() > 1 * SECOND * IN_MILLISECONDS;
|
||||
if (spellHasLongCast)
|
||||
cOwner->UpdateLeashExtensionTime();
|
||||
}
|
||||
else
|
||||
cOwner->UpdateLeashExtensionTime();
|
||||
|
||||
cOwner->SetCannotReachTarget();
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user