mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 00:08:01 +00:00
fix(Core/Unit): Fix fast creatures chasing indefinitely (#21200)
This commit is contained in:
@@ -10384,6 +10384,10 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
|||||||
if (meleeAttack)
|
if (meleeAttack)
|
||||||
AddUnitState(UNIT_STATE_MELEE_ATTACKING);
|
AddUnitState(UNIT_STATE_MELEE_ATTACKING);
|
||||||
|
|
||||||
|
// Update leash timer when attacking creatures
|
||||||
|
if (victim->IsCreature())
|
||||||
|
victim->ToCreature()->UpdateLeashExtensionTime();
|
||||||
|
|
||||||
// set position before any AI calls/assistance
|
// set position before any AI calls/assistance
|
||||||
//if (IsCreature())
|
//if (IsCreature())
|
||||||
// ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
|
// ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||||
@@ -10393,6 +10397,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
|||||||
SetInCombatWith(victim);
|
SetInCombatWith(victim);
|
||||||
if (victim->IsPlayer())
|
if (victim->IsPlayer())
|
||||||
victim->SetInCombatWith(this);
|
victim->SetInCombatWith(this);
|
||||||
|
|
||||||
AddThreat(victim, 0.0f);
|
AddThreat(victim, 0.0f);
|
||||||
|
|
||||||
creature->SendAIReaction(AI_REACTION_HOSTILE);
|
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);
|
SetInCombatState(false, enemy, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13700,6 +13702,10 @@ void Unit::CombatStart(Unit* victim, bool initialAggro)
|
|||||||
SetInCombatWith(victim);
|
SetInCombatWith(victim);
|
||||||
victim->SetInCombatWith(this);
|
victim->SetInCombatWith(this);
|
||||||
|
|
||||||
|
// Update leash timer when attacking creatures
|
||||||
|
if (victim->IsCreature())
|
||||||
|
victim->ToCreature()->UpdateLeashExtensionTime();
|
||||||
|
|
||||||
// Xinef: If pet started combat - put owner in combat
|
// Xinef: If pet started combat - put owner in combat
|
||||||
if (!alreadyInCombat && IsInCombat())
|
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
|
// Xinef: If pet started combat - put owner in combat
|
||||||
if (Unit* owner = GetOwner())
|
if (Unit* owner = GetOwner())
|
||||||
owner->SetInCombatWith(target, duration);
|
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();
|
Unit* who = target->GetCharmerOrOwnerOrSelf();
|
||||||
|
|||||||
Reference in New Issue
Block a user