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
This commit is contained in:
ariel-
2017-03-28 01:52:49 -03:00
parent 97e54fe458
commit 2f99fa09c9
6 changed files with 70 additions and 60 deletions

View File

@@ -476,15 +476,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 (CreatureBoundary::const_iterator it = boundary->cbegin(); it != boundary->cend(); ++it)
if (!(*it)->IsWithinBoundary(&jumpTo))
return false;
return true;
}
Position GetRandomPositionAround(Creature* anubarak)
{
static float DISTANCE_MIN = 10.0f;
@@ -501,7 +492,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);
}