diff options
author | acidmanifesto <joshua.lee.betts@gmail.com> | 2021-10-13 10:32:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 11:32:01 -0300 |
commit | 430157f71d8a90da0a376efa33fc0cc53c327d21 (patch) | |
tree | 7eb072e5602bcd0801dcf27c3c9630e46f4d1065 /src | |
parent | b5f8b485a8e4408e776783218c97ba069b5f7f79 (diff) |
feat(Core): GetDeadCreatureListInGrid helper added, for aoe loot (#8445)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 5 | ||||
-rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedCreature.h | 1 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.h | 1 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 24 |
5 files changed, 38 insertions, 0 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index fa77c2fa9b..277f91bc50 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<GameObject*>& list, WorldObject* { source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange); } + + void GetDeadCreatureListInGrid(std::list<Creature*>& 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 2b1fe9ae64..6e12ea01a7 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<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange); void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange); +void GetDeadCreatureListInGrid(std::list<Creature*>& 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 d20cce0fd4..a53d9618bf 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<Creature*>& creatureL Cell::VisitGridObjects(this, searcher, maxSearchRange); } +void WorldObject::GetDeadCreatureListInGrid(std::list<Creature*>& creaturedeadList, float maxSearchRange, bool alive /*= false*/) const +{ + Acore::AllDeadCreaturesInRange check(this, maxSearchRange, alive); + Acore::CreatureListSearcher<Acore::AllDeadCreaturesInRange> 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 881820a0b2..a620651f95 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<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const; void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const; + void GetDeadCreatureListInGrid(std::list<Creature*>& 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 384d380472..44cdee243b 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: |