Skip to content

Commit

Permalink
NPCBots: Allow using master's invisibility detection in dungeons
Browse files Browse the repository at this point in the history
(cherry picked from commit c55c06c0adb1f1ad5293fc29615beb27c5d4efa4)
  • Loading branch information
trickerer committed May 2, 2024
1 parent 0de11a5 commit ae63427
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,9 +1655,26 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool implicitDetect, bool ch
{
WorldObject const* seer = this;

//npcbot: master's invisibility should not affect bots' sight
if (!IsNPCBot())
//npcbot: master's sight only partially affects bots
if (IsNPCBot())
{
Unit const* owner = ToCreature()->GetBotOwner();
if (!owner)
owner = ToUnit();

if (!obj->IsAlwaysDetectableFor(seer) && !obj->IsAlwaysDetectableFor(owner) && !implicitDetect)
{
if (!seer->CanDetectInvisibilityOf(obj) && !(owner->IsInWorld() && owner->GetMap()->IsDungeon() && owner->CanDetectInvisibilityOf(obj)))
return false;

if (!seer->CanDetectStealthOf(obj, checkAlert))
return false;
}

return true;
}
//end npcbot

// Pets don't have detection, they use the detection of their masters
if (Unit const* thisUnit = ToUnit())
{
Expand Down

0 comments on commit ae63427

Please sign in to comment.