mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
fix(Core/Scripts): Fix DK pets not correctly attacking (#25128)
Co-authored-by: blinkysc <blinkysc@users.noreply.github.com> Co-authored-by: Treeston <treeston.mmoc@gmail.com> Co-authored-by: Malcrom <malcromdev@gmail.com> Co-authored-by: Aqua Deus <95978183+aquadeus@users.noreply.github.com>
This commit is contained in:
@@ -1840,44 +1840,39 @@ bool Creature::IsAlwaysDetectableFor(WorldObject const* seer) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Creature::CanStartAttack(Unit const* who) const
|
||||
bool Creature::CanStartAttack(Unit const* who, bool force) const
|
||||
{
|
||||
if (IsCivilian())
|
||||
return false;
|
||||
|
||||
// This set of checks is should be done only for creatures
|
||||
if ((IsImmuneToNPC() && !who->IsPlayer()) || // flag is valid only for non player characters
|
||||
(IsImmuneToPC() && who->IsPlayer())) // immune to PC and target is a player, return false
|
||||
{
|
||||
if ((IsImmuneToNPC() && !who->IsPlayer()) ||
|
||||
(IsImmuneToPC() && who->IsPlayer()))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Unit* owner = who->GetOwner())
|
||||
if (owner->IsPlayer() && IsImmuneToPC()) // immune to PC and target has player owner
|
||||
if (owner->IsPlayer() && IsImmuneToPC())
|
||||
return false;
|
||||
|
||||
// Do not attack non-combat pets
|
||||
if (who->IsCreature() && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
||||
return false;
|
||||
|
||||
if (!CanFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + m_CombatDistance)) // too much Z difference, skip very costy vmap calculations here
|
||||
if (!CanFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + m_CombatDistance))
|
||||
return false;
|
||||
|
||||
if (!_IsTargetAcceptable(who))
|
||||
return false;
|
||||
if (!force)
|
||||
{
|
||||
if (!_IsTargetAcceptable(who))
|
||||
return false;
|
||||
|
||||
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false, false)) // pussywizard: +m_combatDistance for turrets and similar
|
||||
return false;
|
||||
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false, false))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanCreatureAttack(who))
|
||||
return false;
|
||||
|
||||
if (HasUnitState(UNIT_STATE_STUNNED))
|
||||
return false;
|
||||
|
||||
if (!IsHostileTo(who))
|
||||
return false;
|
||||
|
||||
return IsWithinLOSInMap(who);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user