From 89f4c1c444b9a0b090d71667c26f05165394a594 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 29 May 2009 16:49:28 -0500 Subject: *Add function FindNearestCreature and FindNearestGameObject to replace old FindCreature and FindGameObject --HG-- branch : trunk --- src/game/Object.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/game/Object.cpp') diff --git a/src/game/Object.cpp b/src/game/Object.cpp index dd6b23e458f..99f2c0d8417 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -2041,6 +2041,24 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } +Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) +{ + Creature *creature = NULL; + Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); + Trinity::CreatureLastSearcher searcher(this, creature, checker); + VisitNearbyObject(range, searcher); + return creature; +} + +GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) +{ + GameObject *go = NULL; + Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); + Trinity::GameObjectLastSearcher searcher(this, go, checker); + VisitNearbyGridObject(range, searcher); + return go; +} + /* namespace MaNGOS { -- cgit v1.2.3