aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAI.cpp22
-rw-r--r--src/server/game/AI/CreatureAI.h7
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp2
3 files changed, 14 insertions, 17 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index af9104b6c09..835f5369c9f 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -44,7 +44,7 @@ void CreatureAI::OnCharmed(bool apply)
AISpellInfoType* UnitAI::AISpellInfo;
AISpellInfoType* GetAISpellInfo(uint32 i) { return &UnitAI::AISpellInfo[i]; }
-CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), m_MoveInLineOfSight_locked(false)
+CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), m_MoveInLineOfSight_locked(false)
{
}
@@ -364,32 +364,28 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con
bool CreatureAI::CheckBoundary(Position const* who) const
{
+ if (!_boundary)
+ return true;
+
if (!who)
who = me;
- if (_boundary)
- for (AreaBoundary const* areaBoundary : *_boundary)
- if (!areaBoundary->IsWithinBoundary(who))
- return false;
-
- return true;
+ return (CreatureAI::IsInBounds(*_boundary, who) != _negateBoundary);
}
-bool CreatureAI::IsInBounds(CreatureBoundary const* boundary, Position const* pos)
+bool CreatureAI::IsInBounds(CreatureBoundary const& boundary, Position const* pos)
{
- if (!boundary)
- return true;
-
- for (AreaBoundary const* areaBoundary : *boundary)
+ for (AreaBoundary const* areaBoundary : boundary)
if (!areaBoundary->IsWithinBoundary(pos))
return false;
return true;
}
-void CreatureAI::SetBoundary(CreatureBoundary const* boundary)
+void CreatureAI::SetBoundary(CreatureBoundary const* boundary, bool negateBoundaries /*= false*/)
{
_boundary = boundary;
+ _negateBoundary = negateBoundaries;
me->DoImmediateBoundaryCheck();
}
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index 5fe93e7675a..edc09a650c7 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -83,7 +83,6 @@ class TC_GAME_API CreatureAI : public UnitAI
bool CheckBoundary(Position const* who = nullptr) const;
- void SetBoundary(CreatureBoundary const* boundary);
public:
enum EvadeReason
{
@@ -211,11 +210,12 @@ class TC_GAME_API CreatureAI : public UnitAI
virtual PlayerAI* GetAIForCharmedPlayer(Player* /*who*/) { return nullptr; }
// intended for encounter design/debugging. do not use for other purposes. expensive.
- int32 VisualizeBoundary(uint32 duration, Unit* owner=nullptr, bool fill=false) const;
+ int32 VisualizeBoundary(uint32 duration, Unit* owner = nullptr, bool fill = false) const;
virtual bool CheckInRoom();
CreatureBoundary const* GetBoundary() const { return _boundary; }
+ void SetBoundary(CreatureBoundary const* boundary, bool negativeBoundaries = false);
- static bool IsInBounds(CreatureBoundary const* boundary, Position const* who);
+ static bool IsInBounds(CreatureBoundary const& boundary, Position const* who);
protected:
virtual void MoveInLineOfSight(Unit* /*who*/);
@@ -223,6 +223,7 @@ class TC_GAME_API CreatureAI : public UnitAI
bool _EnterEvadeMode(EvadeReason why = EVADE_REASON_OTHER);
CreatureBoundary const* _boundary;
+ bool _negateBoundary;
private:
bool m_MoveInLineOfSight_locked;
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
index 9112fd9ccd2..37aa313b662 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
@@ -499,7 +499,7 @@ class npc_anubarak_anub_ar_assassin : public CreatureScript
Position jumpTo;
do
jumpTo = GetRandomPositionAround(anubarak);
- while (!CreatureAI::IsInBounds(boundary, &jumpTo));
+ while (!CreatureAI::IsInBounds(*boundary, &jumpTo));
me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f);
DoCastSelf(SPELL_ASSASSIN_VISUAL, true);
}