diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3de8d2a558728e..25f1c289377daf 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -10384,6 +10384,10 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) if (meleeAttack) AddUnitState(UNIT_STATE_MELEE_ATTACKING); + // Update leash timer when attacking creatures + if (victim->IsCreature()) + victim->ToCreature()->UpdateLeashExtensionTime(); + // set position before any AI calls/assistance //if (IsCreature()) // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); @@ -10393,6 +10397,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) SetInCombatWith(victim); if (victim->IsPlayer()) victim->SetInCombatWith(this); + AddThreat(victim, 0.0f); creature->SendAIReaction(AI_REACTION_HOSTILE); @@ -13623,9 +13628,6 @@ void Unit::SetInCombatWith(Unit* enemy, uint32 duration) } } - if (Creature* pCreature = ToCreature()) - pCreature->UpdateLeashExtensionTime(); - SetInCombatState(false, enemy, duration); } @@ -13700,6 +13702,10 @@ void Unit::CombatStart(Unit* victim, bool initialAggro) SetInCombatWith(victim); victim->SetInCombatWith(this); + // Update leash timer when attacking creatures + if (victim->IsCreature()) + victim->ToCreature()->UpdateLeashExtensionTime(); + // Xinef: If pet started combat - put owner in combat if (!alreadyInCombat && IsInCombat()) { @@ -13736,6 +13742,12 @@ void Unit::CombatStartOnCast(Unit* target, bool initialAggro, uint32 duration) // Xinef: If pet started combat - put owner in combat if (Unit* owner = GetOwner()) owner->SetInCombatWith(target, duration); + + // Update leash timer when attacking creatures + if (target->IsCreature()) + target->ToCreature()->UpdateLeashExtensionTime(); + else if (ToCreature()) // Reset leash if it is a spell caster, else it may evade inbetween casts + ToCreature()->UpdateLeashExtensionTime(); } Unit* who = target->GetCharmerOrOwnerOrSelf();