Core/AI: AreaBoundary refactor

- Added an auxiliary function IsInBounds to base CreatureAI
- Changed container to vector. Set had no sense because we're storing new pointers, they have different addresses even if the boundary is the same

(cherry picked from commit 2f99fa09c9)
This commit is contained in:
ariel-
2017-03-28 01:52:49 -03:00
committed by funjoker
parent 124b014f40
commit 3f79c9f696
7 changed files with 70 additions and 61 deletions

View File

@@ -483,15 +483,6 @@ class npc_anubarak_anub_ar_assassin : public CreatureScript
{
npc_anubarak_anub_ar_assassinAI(Creature* creature) : npc_anubarak_pet_template(creature, false), _backstabTimer(6 * IN_MILLISECONDS) { }
bool IsInBounds(Position const& jumpTo, CreatureBoundary const* boundary)
{
if (!boundary)
return true;
for (AreaBoundary const* it : *boundary)
if (!it->IsWithinBoundary(&jumpTo))
return false;
return true;
}
Position GetRandomPositionAround(Creature* anubarak)
{
static float DISTANCE_MIN = 10.0f;
@@ -508,7 +499,7 @@ class npc_anubarak_anub_ar_assassin : public CreatureScript
Position jumpTo;
do
jumpTo = GetRandomPositionAround(anubarak);
while (!IsInBounds(jumpTo, boundary));
while (!CreatureAI::IsInBounds(boundary, &jumpTo));
me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f);
DoCastSelf(SPELL_ASSASSIN_VISUAL, true);
}