Core/Misc: Add new function for selection nearest player in given distance

This commit is contained in:
Lopin
2011-07-11 16:17:21 +02:00
parent e35e4d6e23
commit a233e7b9d8
4 changed files with 65 additions and 0 deletions
@@ -1817,6 +1817,17 @@ Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
return target;
}
Player* Creature::SelectNearestPlayer(float distance) const
{
Player* target = NULL;
Trinity::NearestPlayerInObjectRangeCheck checker(this, distance);
Trinity::PlayerLastSearcher<Trinity::NearestPlayerInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyObject(distance, searcher);
return target;
}
void Creature::SendAIReaction(AiReaction reactionType)
{
WorldPacket data(SMSG_AI_REACTION, 12);
@@ -584,6 +584,7 @@ class Creature : public Unit, public GridObject<Creature>
Unit* SelectNearestTarget(float dist = 0) const;
Unit* SelectNearestTargetInAttackDistance(float dist = 0) const;
Player* SelectNearestPlayer(float distance = 0) const;
void DoFleeToGetAssistance();
void CallForHelp(float fRadius);