local npc_id = 24575;
-- Range in yards for the creature to appear / dissapear.
local RANGE = 10;
-- Aura (Uber Stealth, makes the creature completely invisible).
local SPELL_STEALTH = 10032;
-- Events
local CREATURE_EVENT_ON_AIUPDATE = 7;
local function onAIUpdate(_, creature)
local players = creature:GetPlayersInRange(RANGE);
if #players > 0 and creature:HasAura(SPELL_STEALTH) then
creature:RemoveAura(SPELL_STEALTH);
elseif #players == 0 and not creature:HasAura(SPELL_STEALTH) then
creature:CastSpell(creature, SPELL_STEALTH, false);
end
end
RegisterCreatureEvent(npc_id, CREATURE_EVENT_ON_AIUPDATE, onAIUpdate);