From 762a32cb65ea7cd9d802f9621e701afce9709303 Mon Sep 17 00:00:00 2001 From: Teleqraph Date: Sun, 30 Oct 2022 22:29:03 +0100 Subject: Core/Object: Implement FindNearestCreatureWithAura (#28410) * Game/Object: Implement NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck class and FindNearestCreatureWithAura method * moved arguments (cherry picked from commit 9a3e29d416162a84dd6a11c5e248f5f65e98a604) --- src/server/game/Entities/Object/Object.cpp | 9 +++++++++ src/server/game/Entities/Object/Object.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/server/game/Entities/Object') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 31ba39d5a23..b944d94a666 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2126,6 +2126,15 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive return creature; } +Creature* WorldObject::FindNearestCreatureWithAura(uint32 entry, uint32 spellId, float range, bool alive) const +{ + Creature* creature = nullptr; + Trinity::NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck checker(*this, entry, spellId, alive, range); + Trinity::CreatureLastSearcher searcher(this, creature, checker); + Cell::VisitAllObjects(this, searcher, range); + return creature; +} + GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range, bool spawnedOnly) const { GameObject* go = nullptr; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index b3cd579df89..ac9a4dae5ee 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -426,6 +426,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation void SummonCreatureGroup(uint8 group, std::list* list = nullptr); Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const; + Creature* FindNearestCreatureWithAura(uint32 entry, uint32 spellId, float range, bool alive = true) const; GameObject* FindNearestGameObject(uint32 entry, float range, bool spawnedOnly = true) const; GameObject* FindNearestUnspawnedGameObject(uint32 entry, float range) const; GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const; -- cgit v1.2.3