aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-04-26 04:19:01 -0300
committerariel- <ariel-@users.noreply.github.com>2017-04-26 04:20:38 -0300
commit6892404b270f57380ffdc9ad084e0f43d94134e0 (patch)
tree1845f3c9f19037b566c41dbbccb7eeaa2f53eb85 /src
parent3a2ecaa05f0a3da96b3d4a0bec44175d6a7dda6a (diff)
Core/AI: some tweaks on boundary functionality:
- Moved SetBoundary to public scope to allow for greater flexibility (ie set from external script) - Extended to allow checking inverted boundaries
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAI.cpp24
-rw-r--r--src/server/game/AI/CreatureAI.h9
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp2
3 files changed, 19 insertions, 16 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 11f6f8d0f36..06c8f60a1fb 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -354,23 +354,18 @@ 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;
@@ -388,6 +383,13 @@ bool CreatureAI::CheckInRoom()
}
}
+void CreatureAI::SetBoundary(CreatureBoundary const* boundary, bool negateBoundaries /*= false*/)
+{
+ _boundary = boundary;
+ _negateBoundary = negateBoundaries;
+ me->DoImmediateBoundaryCheck();
+}
+
Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType)
{
return me->SummonCreature(entry, pos, summonType, despawnTime);
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index 7e0f4142a6c..b4874e434d2 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -82,7 +82,6 @@ class TC_GAME_API CreatureAI : public UnitAI
bool CheckBoundary(Position const* who = nullptr) const;
- void SetBoundary(CreatureBoundary const* boundary) { _boundary = boundary; me->DoImmediateBoundaryCheck(); }
public:
enum EvadeReason
{
@@ -95,7 +94,7 @@ class TC_GAME_API CreatureAI : public UnitAI
void Talk(uint8 id, WorldObject const* whisperTarget = nullptr);
- explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), m_MoveInLineOfSight_locked(false) { }
+ explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), m_MoveInLineOfSight_locked(false) { }
virtual ~CreatureAI() { }
@@ -192,11 +191,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*/);
@@ -204,6 +204,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 aec3210763b..919f008c108 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
@@ -492,7 +492,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);
}