fix(Core/Unit): Fix fast creatures chasing indefinitely (#21200)
This commit is contained in:
parent
4a3fab424c
commit
882951c613
1 changed files with 15 additions and 3 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue