diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2018-03-08 18:41:46 +0100 |
|---|---|---|
| committer | Treeston <treeston.mmoc@gmail.com> | 2018-03-08 18:41:46 +0100 |
| commit | df639d85e4e82add71432ea0a4cba91f238a30ba (patch) | |
| tree | 6fffc85dae24ae1a71db094231a928c5da41609c /src/server/game | |
| parent | 5df0a020fa54cc658ec6ae8e5df1cecd2cf3d3dc (diff) | |
Core/CreatureAI: CheckBoundary -> IsInBoundary, better reflects what it does. Also moved to public so spellscript can use it.
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 12 | ||||
| -rw-r--r-- | src/server/game/AI/CreatureAI.h | 3 | ||||
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 4 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index fec1166481a..22e2226af50 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -258,13 +258,13 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con std::unordered_set<coordinate> outOfBounds; Position startPosition = owner->GetPosition(); - if (!CheckBoundary(&startPosition)) + if (!IsInBoundary(&startPosition)) { // fall back to creature position startPosition = me->GetPosition(); - if (!CheckBoundary(&startPosition)) + if (!IsInBoundary(&startPosition)) { // fall back to creature home position startPosition = me->GetHomePosition(); - if (!CheckBoundary(&startPosition)) + if (!IsInBoundary(&startPosition)) return LANG_CREATURE_NO_INTERIOR_POINT_FOUND; } } @@ -287,7 +287,7 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con if (alreadyChecked.find(next) == alreadyChecked.end()) // never check a coordinate twice { Position nextPos(startPosition.GetPositionX() + next.first*BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + next.second*BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionZ()); - if (CheckBoundary(&nextPos)) + if (IsInBoundary(&nextPos)) Q.push(next); else { @@ -314,7 +314,7 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con return boundsWarning ? LANG_CREATURE_MOVEMENT_MAYBE_UNBOUNDED : 0; } -bool CreatureAI::CheckBoundary(Position const* who) const +bool CreatureAI::IsInBoundary(Position const* who) const { if (!_boundary) return true; @@ -336,7 +336,7 @@ bool CreatureAI::IsInBounds(CreatureBoundary const& boundary, Position const* po bool CreatureAI::CheckInRoom() { - if (CheckBoundary()) + if (IsInBoundary()) return true; else { diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 94244445587..78b276325de 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -80,8 +80,6 @@ class TC_GAME_API CreatureAI : public UnitAI Creature* DoSummon(uint32 entry, WorldObject* obj, float radius = 5.0f, uint32 despawnTime = 30000, TempSummonType summonType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); Creature* DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius = 5.0f, uint32 despawnTime = 30000, TempSummonType summonType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); - bool CheckBoundary(Position const* who = nullptr) const; - public: enum EvadeReason { @@ -224,6 +222,7 @@ class TC_GAME_API CreatureAI : public UnitAI void SetBoundary(CreatureBoundary const* boundary, bool negativeBoundaries = false); static bool IsInBounds(CreatureBoundary const& boundary, Position const* who); + bool IsInBoundary(Position const* who = nullptr) const; protected: virtual void MoveInLineOfSight(Unit* /*who*/); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index d3aba9f9a04..414e86a3e1e 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -523,7 +523,7 @@ void BossAI::TeleportCheaters() for (auto const& pair : me->GetCombatManager().GetPvECombatRefs()) { Unit* target = pair.second->GetOther(me); - if (target->IsControlledByPlayer() && !CheckBoundary(target)) + if (target->IsControlledByPlayer() && !IsInBoundary(target)) target->NearTeleportTo(x, y, z, 0); } } @@ -562,7 +562,7 @@ void BossAI::UpdateAI(uint32 diff) bool BossAI::CanAIAttack(Unit const* target) const { - return CheckBoundary(target); + return IsInBoundary(target); } void BossAI::_DespawnAtEvade(Seconds delayToRespawn, Creature* who) |
