mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/CreatureAI: CheckBoundary -> IsInBoundary, better reflects what it does. Also moved to public so spellscript can use it.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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*/);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -767,7 +767,7 @@ class npc_halion_controller : public CreatureScript
|
||||
Map::PlayerList const& players = me->GetMap()->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||
if (Player* player = i->GetSource())
|
||||
if (player->IsAlive() && CheckBoundary(player) && !player->IsGameMaster())
|
||||
if (player->IsAlive() && IsInBoundary(player) && !player->IsGameMaster())
|
||||
return;
|
||||
|
||||
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
|
||||
|
||||
@@ -1245,7 +1245,7 @@ class npc_thorim_arena_phase : public CreatureScript
|
||||
if (_isInArena && HeightPositionCheck(true)(who))
|
||||
return false;
|
||||
|
||||
return CheckBoundary(who);
|
||||
return IsInBoundary(who);
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
@@ -1338,7 +1338,7 @@ struct npc_thorim_minibossAI : public ScriptedAI
|
||||
|
||||
bool CanAIAttack(Unit const* who) const final override
|
||||
{
|
||||
return CheckBoundary(who);
|
||||
return IsInBoundary(who);
|
||||
}
|
||||
|
||||
void JustSummoned(Creature* summon) final override
|
||||
|
||||
@@ -1072,7 +1072,7 @@ class instance_ulduar : public InstanceMapScript
|
||||
void AddDoor(GameObject* door, bool add) override
|
||||
{
|
||||
// Leviathan doors are South except the one it uses to enter the room
|
||||
// which is North and should not be used for boundary checks in BossAI::CheckBoundary()
|
||||
// which is North and should not be used for boundary checks in BossAI::IsInBoundary()
|
||||
if (door->GetEntry() == GO_LEVIATHAN_DOOR && door->GetPositionX() > 400.f)
|
||||
{
|
||||
if (add)
|
||||
|
||||
@@ -685,7 +685,7 @@ struct boss_illidan_stormrage : public BossAI
|
||||
Map::PlayerList const& players = me->GetMap()->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||
if (Player* player = i->GetSource())
|
||||
if (player->IsAlive() && !player->IsGameMaster() && CheckBoundary(player))
|
||||
if (player->IsAlive() && !player->IsGameMaster() && IsInBoundary(player))
|
||||
return;
|
||||
|
||||
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
|
||||
|
||||
@@ -288,7 +288,7 @@ struct boss_shade_of_akama : public BossAI
|
||||
Map::PlayerList const& players = me->GetMap()->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||
if (Player* player = i->GetSource())
|
||||
if (player->IsAlive() && !player->IsGameMaster() && CheckBoundary(player))
|
||||
if (player->IsAlive() && !player->IsGameMaster() && IsInBoundary(player))
|
||||
return;
|
||||
|
||||
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
|
||||
|
||||
Reference in New Issue
Block a user