Skip to content

Commit

Permalink
AI/BossAI: Make creature never chase targets that are out of bounds
Browse files Browse the repository at this point in the history
- Add missing const attribute on CheckBoundary arg.
- Prevent AI from attacking a target that is out of bounds. This prevents exploids such as killing Gluth/Deathbringer from out of bounds.

(cherry picked from commit 19ed18c)
  • Loading branch information
Treeston authored and Shauren committed Apr 5, 2016
1 parent 7672ca1 commit 53722a8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/server/game/AI/CreatureAI.cpp
Expand Up @@ -350,7 +350,7 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con
return boundsWarning ? LANG_CREATURE_MOVEMENT_MAYBE_UNBOUNDED : 0;
}

bool CreatureAI::CheckBoundary(Position* who) const
bool CreatureAI::CheckBoundary(Position const* who) const
{
if (!who)
who = me;
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/CreatureAI.h
Expand Up @@ -79,7 +79,7 @@ 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* who = nullptr) const;
bool CheckBoundary(Position const* who = nullptr) const;
void SetBoundary(CreatureBoundary const* boundary) { _boundary = boundary; me->DoImmediateBoundaryCheck(); }
public:
enum EvadeReason
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/AI/ScriptedAI/ScriptedCreature.h
Expand Up @@ -357,6 +357,8 @@ class TC_GAME_API BossAI : public ScriptedAI
void JustDied(Unit* /*killer*/) override { _JustDied(); }
void JustReachedHome() override { _JustReachedHome(); }

bool CanAIAttack(Unit const* target) const override { return CheckBoundary(target); }

protected:
void _Reset();
void _EnterCombat();
Expand Down
Expand Up @@ -135,9 +135,9 @@ class boss_general_zarithrian : public CreatureScript
Talk(SAY_KILL);
}

bool CanAIAttack(Unit const* /*target*/) const override
bool CanAIAttack(Unit const* target) const override
{
return (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE);
return (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE && BossAI::CanAIAttack(target));
}

void UpdateAI(uint32 diff) override
Expand Down
Expand Up @@ -598,7 +598,7 @@ class boss_deathbringer_saurfang : public CreatureScript
if (target->GetTransport())
return false;

return true;
return BossAI::CanAIAttack(target);
}

static uint32 const FightWonValue;
Expand Down
Expand Up @@ -557,7 +557,7 @@ class boss_the_lich_king : public CreatureScript
bool CanAIAttack(Unit const* target) const override
{
// The Lich King must not select targets in frostmourne room if he killed everyone outside
return !target->HasAura(SPELL_IN_FROSTMOURNE_ROOM);
return !target->HasAura(SPELL_IN_FROSTMOURNE_ROOM) && BossAI::CanAIAttack(target);
}

void EnterEvadeMode(EvadeReason why) override
Expand Down

0 comments on commit 53722a8

Please sign in to comment.