From a0cfbd417b6b3fdffb51142b4fd7e411d10791da Mon Sep 17 00:00:00 2001 From: Manmadedrummer <140130825+Manmadedrummer@users.noreply.github.com> Date: Thu, 12 Jun 2025 19:47:57 -0400 Subject: [PATCH] Add files via upload --- LUA/DespawnRespawnScourgeQuestGivers.lua | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 LUA/DespawnRespawnScourgeQuestGivers.lua diff --git a/LUA/DespawnRespawnScourgeQuestGivers.lua b/LUA/DespawnRespawnScourgeQuestGivers.lua new file mode 100644 index 0000000..375bcf8 --- /dev/null +++ b/LUA/DespawnRespawnScourgeQuestGivers.lua @@ -0,0 +1,68 @@ +local GAME_EVENT_ID = 17 -- Set the game event ID +local npcIds = {16478, 16484, 16495, 16493, 16494, 16490, 16281} -- Quest Givers +local BROADCAST_MESSAGE = "The Scourge are attacking the people of Azeroth. Quickly adventurers, prepare yourselves!" +local SOUND_ID = 13363 +local excludedZones = {44} -- Zone ID for Redridge Mountains + +local YELL_MESSAGES = { + "The Scourge have come!", + "Beware, the Scourge approaches!", + "Defend our home, the Scourge is upon us!", + "To arms, the Scourge is here!", + "All fighters ready the assault against the Scourge.", + "The Scourge invasion has begun!", + "The Lich Kings minions have come! Rally against the Scourge!", + "The Scourge dares to attack us!", + "Show the Scourge the might of the people of Azeroth!" +} + +local function YellRandomMessage(npc) + local messageIndex = math.random(1, #YELL_MESSAGES) + npc:SendUnitYell(YELL_MESSAGES[messageIndex], 0) +end + +local function valueExists(tbl, value) + for _, v in ipairs(tbl) do + if v == value then + return true + end + end + return false +end + +local function DespawnAndRespawnNpcs(event, gameEventId) + if gameEventId == GAME_EVENT_ID then + local players = GetPlayersInWorld() -- Get all players in the world + if event == 34 then -- Game Event Start + SendWorldMessage(BROADCAST_MESSAGE, 2) -- Broadcast the message with chat type 2 (SYSTEM) + for _, player in ipairs(players) do + local playerZoneId = player:GetZoneId() + if not valueExists(excludedZones, playerZoneId) then + player:PlayDirectSound(SOUND_ID) -- Play the sound for each player + end + end + for _, player in ipairs(players) do + for _, npcId in ipairs(npcIds) do + local npcs = player:GetCreaturesInRange(1000, npcId) -- Get creatures within a radius of 1000 units + for _, npc in ipairs(npcs) do + YellRandomMessage(npc) + npc:DespawnOrUnsummon() + npc:Respawn() + end + end + end + elseif event == 35 then -- Game Event End + for _, player in ipairs(players) do + for _, npcId in ipairs(npcIds) do + local npcs = player:GetCreaturesInRange(1000, npcId) + for _, npc in ipairs(npcs) do + npc:DespawnOrUnsummon() -- Only despawn, no respawn + end + end + end + end + end +end + +RegisterServerEvent(34, DespawnAndRespawnNpcs) -- Game Event Start +RegisterServerEvent(35, DespawnAndRespawnNpcs) -- Game Event End \ No newline at end of file