mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-07 21:01:37 +00:00
fix(Core/Pets): Always check pet Line of Sight before attacking (#24257)
This commit is contained in:
@@ -231,19 +231,20 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
|||||||
if (!creaturePet->CanCreatureAttack(TargetUnit))
|
if (!creaturePet->CanCreatureAttack(TargetUnit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Not let attack through obstructions
|
// Don't bother if pet is already attacking target
|
||||||
bool checkLos = !sDisableMgr->IsPathfindingEnabled(pet->GetMap()) ||
|
if (pet->GetVictim() == TargetUnit && pet->GetCharmInfo()->IsCommandAttack())
|
||||||
(TargetUnit->IsCreature() && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss()));
|
return;
|
||||||
|
|
||||||
if (checkLos && !pet->IsWithinLOSInMap(TargetUnit))
|
// Check line of sight either from pet or owner depending if pet is charmed
|
||||||
{
|
Unit* seer = pet;
|
||||||
WorldPacket data(SMSG_CAST_FAILED, 1 + 4 + 1);
|
if (Unit* owner = pet->GetOwner())
|
||||||
data << uint8(0);
|
if (owner->IsPlayer() && owner->ToPlayer()->GetCharm() != pet && owner->ToPlayer()->GetVehicleBase() != pet)
|
||||||
data << uint32(7389);
|
if (sDisableMgr->IsPathfindingEnabled(pet->GetMap()))
|
||||||
data << uint8(SPELL_FAILED_LINE_OF_SIGHT);
|
seer = owner;
|
||||||
SendPacket(&data);
|
|
||||||
|
// Fail on LoS
|
||||||
|
if (seer && !seer->IsWithinLOSInMap(TargetUnit, VMAP::ModelIgnoreFlags::M2))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
pet->ClearUnitState(UNIT_STATE_FOLLOW);
|
pet->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||||
// This is true if pet has no target or has target but targets differs.
|
// This is true if pet has no target or has target but targets differs.
|
||||||
@@ -428,7 +429,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
|||||||
// This is true if pet has no target or has target but targets differs.
|
// This is true if pet has no target or has target but targets differs.
|
||||||
if (pet->GetVictim() != unit_target)
|
if (pet->GetVictim() != unit_target)
|
||||||
{
|
{
|
||||||
if (pet->ToCreature()->IsAIEnabled)
|
if (pet->ToCreature()->IsAIEnabled && pet->IsWithinLOSInMap(unit_target, VMAP::ModelIgnoreFlags::M2))
|
||||||
pet->ToCreature()->AI()->AttackStart(unit_target);
|
pet->ToCreature()->AI()->AttackStart(unit_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -510,6 +511,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
|||||||
charmInfo->SetIsCommandFollow(false);
|
charmInfo->SetIsCommandFollow(false);
|
||||||
charmInfo->SetIsReturning(false);
|
charmInfo->SetIsReturning(false);
|
||||||
|
|
||||||
|
if (pet->IsWithinLOSInMap(TargetUnit, VMAP::ModelIgnoreFlags::M2))
|
||||||
pet->ToCreature()->AI()->AttackStart(TargetUnit);
|
pet->ToCreature()->AI()->AttackStart(TargetUnit);
|
||||||
|
|
||||||
if (pet->IsPet() && pet->ToPet()->getPetType() == SUMMON_PET && pet != TargetUnit && roll_chance_i(10))
|
if (pet->IsPet() && pet->ToPet()->getPetType() == SUMMON_PET && pet != TargetUnit && roll_chance_i(10))
|
||||||
|
|||||||
Reference in New Issue
Block a user