mirror of
https://github.com/araxiaonline/ScourgeInvasion.git
synced 2026-06-13 03:02:21 -04:00
Add files via upload
This commit is contained in:
68
LUA/DespawnRespawnScourgeQuestGivers.lua
Normal file
68
LUA/DespawnRespawnScourgeQuestGivers.lua
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user