diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index fa77c2fa9..277f91bc5 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -714,3 +714,8 @@ void GetGameObjectListWithEntryInGrid(std::list& list, WorldObject* { source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange); } + + void GetDeadCreatureListInGrid(std::list& list, WorldObject* source, float maxSearchRange, bool alive /*= false*/) +{ + source->GetDeadCreatureListInGrid(list, maxSearchRange, alive); +} diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 2b1fe9ae6..6e12ea01a 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -505,5 +505,6 @@ Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float m GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange); void GetCreatureListWithEntryInGrid(std::list& list, WorldObject* source, uint32 entry, float maxSearchRange); void GetGameObjectListWithEntryInGrid(std::list& list, WorldObject* source, uint32 entry, float maxSearchRange); +void GetDeadCreatureListInGrid(std::list& list, WorldObject* source, float maxSearchRange, bool alive = false); #endif // SCRIPTEDCREATURE_H_ diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index d20cce0fd..a53d9618b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2503,6 +2503,13 @@ void WorldObject::GetCreatureListWithEntryInGrid(std::list& creatureL Cell::VisitGridObjects(this, searcher, maxSearchRange); } +void WorldObject::GetDeadCreatureListInGrid(std::list& creaturedeadList, float maxSearchRange, bool alive /*= false*/) const +{ + Acore::AllDeadCreaturesInRange check(this, maxSearchRange, alive); + Acore::CreatureListSearcher searcher(this, creaturedeadList, check); + Cell::VisitGridObjects(this, searcher, maxSearchRange); +} + /* namespace Acore { diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 881820a0b..a620651f9 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -1007,6 +1007,7 @@ public: [[nodiscard]] Player* SelectNearestPlayer(float distance = 0) const; void GetGameObjectListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) const; void GetCreatureListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) const; + void GetDeadCreatureListInGrid(std::list& lList, float maxSearchRange, bool alive = false) const; void DestroyForNearbyPlayers(); virtual void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 384d38047..44cdee243 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1327,6 +1327,30 @@ namespace Acore float m_fRange; }; + class AllDeadCreaturesInRange + { + public: + AllDeadCreaturesInRange(WorldObject const* obj, float range, bool reqAlive = true) : _obj(obj), _range(range), _reqAlive(reqAlive) {} + + bool operator()(Unit* unit) const + { + if (_reqAlive && unit->IsAlive()) + { + return false; + } + if (!_obj->IsWithinDistInMap(unit, _range)) + { + return false; + } + return true; + } + + private: + WorldObject const* _obj; + float _range; + bool _reqAlive; + }; + class PlayerAtMinimumRangeAway { public: