diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.h | 1 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 33 |
3 files changed, 43 insertions, 0 deletions
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<Trinity::NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck> 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<TempSummon*>* 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; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 3603c2667e2..ef473e63e9d 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1398,6 +1398,39 @@ namespace Trinity NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&) = delete; }; + class NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck + { + public: + NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck(WorldObject const& obj, uint32 entry, uint32 spellId, bool alive, float range) + : i_obj(obj), i_entry(entry), i_spellId(spellId), i_alive(alive), i_range(range) { } + + bool operator()(Creature* u) + { + if (u->getDeathState() != DEAD + && u->GetEntry() == i_entry + && u->HasAura(i_spellId) + && u->IsAlive() == i_alive + && u->GetGUID() != i_obj.GetGUID() + && i_obj.IsWithinDistInMap(u, i_range) + && u->CheckPrivateObjectOwnerVisibility(&i_obj)) + { + i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check + return true; + } + return false; + } + + private: + WorldObject const& i_obj; + uint32 i_entry; + uint32 i_spellId; + bool i_alive; + float i_range; + + // prevent clone this object + NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck(NearestCreatureEntryWithLiveStateAndAuraInObjectRangeCheck const&) = delete; + }; + class AnyPlayerInObjectRangeCheck { public: |