Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------
- -- By Stoneharry --
- -------------------
- -- Variable Decleration
- -- Configuration
- local HANDLER_CREATURE = 780000
- local AddA = 780002 -- 4 of them Gate A
- local AddB = 780003 -- 10 of them Gate A
- local AddC = 780004 -- 2 of them Gate A and B
- local AddD = 780005 -- 20 of them Gate A and B
- local AddE = 780006 -- 6 of them Gate A
- local AddF = 780007 -- 15 of them Gate B
- local AddG = 780008 -- 4 of them Gate A and B
- local AddH = 780009 -- 20 of them no gate
- local BossID = 780001
- local locA, locB, locC = 4523, 2778, 404 -- Randomly moves to one of these two coords on spawn (make near middle)
- local locX, locY, locZ = 4522, 2760, 404
- local gateAX, gateAY, gateAZ, gateAID = 4522.24, 2740.8, 403.984, 201374 -- The coords then ID of each gate on each side of the room
- local gateBX, gateBY, gateBZ, gateBID = 4522.21, 2797.87, 403.984, 201374
- local behindGateAX, behindGateAY, behindGateAZ = 4522, 2734, 404 -- The coords behind gate A to spawn mobs
- local behindGateBX, behindGateBY, behindGateBZ = 4522, 2804, 404 -- The coords behind gate B to spawn mobs
- -- Do not touch below unless you are not using 3.3.5a
- local OBJECT_END = 0x0006
- local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
- local SMSG_INIT_WORLD_STATES = 0x2C2
- local SMSG_UPDATE_WORLD_STATE = 0x2C3
- -- Do not touch below
- local CanStart = false
- local Wave = 1
- local Dead = 0
- local gateA = nil
- local gateB = nil
- local Open = false
- local pack = nil
- ---------------------------------------------------------
- -- Wave Handler -----------------------------------------
- ---------------------------------------------------------
- function Invisible_NpcDEFENDMALL(pUnit, Event)
- pUnit:RegisterEvent("Check_For_EventDEFENDMALL", 5000, 0)
- end
- function Check_For_EventDEFENDMALL(pUnit)
- if CanStart then
- pUnit:RemoveEvents()
- CanStart = false
- Wave = 1
- gateA = pUnit:GetGameObjectNearestCoords(gateAX, gateAY, gateAZ, gateAID)
- gateB = pUnit:GetGameObjectNearestCoords(gateBX, gateBY, gateBZ, gateBID)
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pUnit:SendChatMessageToPlayer(42,0,"The event has begun! Defend the room for all 8 waves.", plrs)
- pack = LuaPacket:CreatePacket(SMSG_INIT_WORLD_STATES, 18) -- Waves remaining
- pack:WriteULong(534) -- Map
- pack:WriteULong(3606) -- Zone
- pack:WriteULong(0)
- pack:WriteUShort(2)
- pack:WriteULong(2842) -- ID
- pack:WriteULong(1) -- Value
- plrs:SendPacketToPlayer(pack)
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 1
- end
- end
- pUnit:PlaySoundToSet(8887) -- Scary music
- pUnit:RegisterEvent("Spawn_Adds_DEFENDMALL", 7000, 1)
- end
- end
- RegisterUnitEvent(HANDLER_CREATURE, 18, "Invisible_NpcDEFENDMALL")
- function Spawn_Adds_DEFENDMALL(pUnit)
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- local i = 0
- while i ~= 4 do
- i = i + 1
- pUnit:SpawnCreature(AddA, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 180000)
- end
- pUnit:RegisterEvent("CheckForDeadAddsOhLol", 5000, 0)
- end
- function CheckForDeadAddsOhLol(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 3 then
- Wave = Wave + 1
- pUnit:RemoveEvents()
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 2
- end
- end
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- local i = 0
- while i ~= 10 do
- i = i + 1
- pUnit:SpawnCreature(AddB, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 300000)
- end
- pUnit:RegisterEvent("Check_For_All_DeadDEFENDMALL", 5000, 0)
- end
- end
- function Check_For_All_DeadDEFENDMALL(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 11 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 3
- end
- end
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- pUnit:SpawnCreature(AddC, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 320000)
- pUnit:SpawnCreature(AddC, behindGateBX, behindGateBY, behindGateBZ, 0, 15, 320000)
- pUnit:RegisterEvent("Check_For_ADDCDEATHS_DEFENDMALL", 5000, 0)
- end
- end
- function Check_For_ADDCDEATHS_DEFENDMALL(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 13 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 4
- end
- end
- --pUnit:PlaySoundToSet(10763)
- pUnit:RegisterEvent("Break_Break_GiveBreak_DEFENDMALL", 8000, 1)
- end
- end
- function Break_Break_GiveBreak_DEFENDMALL(pUnit)
- local i = 0
- while i ~= 20 do
- i = i + 1
- if math.random(1,2) == 1 then
- pUnit:SpawnCreature(AddD, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 180000)
- else
- pUnit:SpawnCreature(AddD, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 180000)
- end
- end
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- pUnit:RegisterEvent("Check_For_mobDDeaths_Yarp", 7500, 0)
- end
- function Check_For_mobDDeaths_Yarp(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 35 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 5
- end
- end
- pUnit:PlaySoundToSet(15119)
- pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALL", 7500, 1)
- end
- end
- function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALL(pUnit)
- local i = 0
- while i ~= 6 do
- i = i + 1
- pUnit:SpawnCreature(AddE, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 380000)
- end
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- pUnit:RegisterEvent("CHECK_FOR_DEAD_MALLEVENTgtoustwo", 7500, 0)
- end
- function CHECK_FOR_DEAD_MALLEVENTgtoustwo(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 40 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 6
- end
- end
- pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLtwo", 7500, 1)
- end
- end
- function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLtwo(pUnit)
- local i = 0
- while i ~= 15 do
- i = i + 1
- pUnit:SpawnCreature(AddF, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 280000)
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- pUnit:RegisterEvent("CHECK_FOR_DEAD_MALLEVENTaaassssffff", 7500, 0)
- end
- function CHECK_FOR_DEAD_MALLEVENTaaassssffff(pUnit)
- if Open then
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 54 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 7
- end
- end
- pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLgaga", 7500, 1)
- end
- end
- function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLgaga(pUnit)
- local i = 0
- while i ~= 4 do
- i = i + 1
- if math.random(1,2) == 1 then
- pUnit:SpawnCreature(AddG, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 480000)
- else
- pUnit:SpawnCreature(AddG, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 480000)
- end
- end
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
- Open = true
- end
- pUnit:RegisterEvent("Check_For_mobDDeaths_Yarpgggggh", 7500, 0)
- end
- function Check_For_mobDDeaths_Yarpgggggh(pUnit)
- if Open then
- if gateA ~= nil then
- gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- if gateB ~= nil then
- gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
- Open = false
- end
- end
- if Dead > 59 then
- pUnit:RemoveEvents()
- Wave = Wave + 1
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(2842) -- ID, total
- pack:WriteULong(Wave) -- Value
- plrs:SendPacketToPlayer(pack)
- pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 8
- end
- end
- pUnit:RegisterEvent("FINALWAVE_DEFENDMALL", 8000, 1)
- end
- end
- function FINALWAVE_DEFENDMALL(pUnit)
- local i = 0
- local pla = nil
- while i ~= 20 do
- i = i + 1
- pla = pUnit:GetRandomPlayer(0)
- if pla ~= nil then
- pUnit:SpawnCreature(AddH, pla:GetX(), pla:GetY(), pla:GetZ(), 0, 15, 300000)
- end
- end
- pUnit:RegisterEvent("WAVES_COMPLETE_BOSS_DUNDUN", 8000, 0)
- end
- function WAVES_COMPLETE_BOSS_DUNDUN(pUnit)
- if Dead > 62 then
- pUnit:RemoveEvents()
- Wave = 1
- local Grill = pUnit:GetGameObjectNearestCoords(4522, 2769, 404, 201755) -- x,y,z,id
- if Grill ~= nil then
- Grill:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open Trap
- pUnit:PlaySoundToSet(16541)
- Grill:Despawn(30000, 10000)
- end
- for place, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:GetPhase() == 2 then
- pUnit:SendChatMessageToPlayer(42, 0, "The way to the boss is clear!", plrs)
- end
- end
- pUnit:SpawnCreature(BossID, 4575, 2768, 361.3, 3.121345, 35, 0)
- pUnit:RegisterEvent("Check_For_EventDEFENDMALL", 10000, 0) -- CanStart is not true yet
- end
- end
- ---------------------------------------------------------
- -- Add Scripts ------------------------------------------
- ---------------------------------------------------------
- function Adds_OnSpawn_ohlol(pUnit, Event)
- pUnit:SetPhase(2)
- pUnit:SetMovementFlags(1)
- pUnit:RegisterEvent("SetFaction_Hostile_After_Gate", 2500, 1)
- if pUnit:GetEntry() == AddC then
- pUnit:RegisterEvent("Cast_ADDC_DEFENDMALL", math.random(6000, 12000), 0)
- elseif pUnit:GetEntry() == AddG then
- pUnit:RegisterEvent("CastSoekks_DEFENDMALL", math.random(2000, 12000), 1)
- elseif pUnit:GetEntry() == AddH then
- pUnit:RegisterEvent("SPawnVisual_teoaj", math.random(750, 1500), 1)
- end
- end
- function SetFaction_Hostile_After_Gate(pUnit)
- pUnit:SetPhase(2) -- Just in case
- pUnit:SetMovementFlags(1)
- pUnit:SetFaction(21)
- if math.random(1,2) == 1 then
- pUnit:MoveTo(locA+math.random(0,2),locB-math.random(0,2),locC,0)
- else
- pUnit:MoveTo(locX-math.random(0,2),locY+math.random(0,2),locZ,0)
- end
- end
- function Adds_OnDead_Ohlol(pUnit)
- pUnit:RemoveEvents()
- Dead = Dead + 1
- end
- function Cast_ADDC_DEFENDMALL(pUnit)
- pUnit:FullCastSpell(36132) -- Normal damage + 300 for two strong adds
- end
- function CastSoekks_DEFENDMALL(pUnit)
- pUnit:CastSpell(15636) -- Avatar of flame
- end
- function SPawnVisual_teoaj(pUnit)
- pUnit:CastSpell(64446) -- Teleport visual
- end
- RegisterUnitEvent(AddA, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddB, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddC, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddD, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddE, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddF, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddG, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddH, 18, "Adds_OnSpawn_ohlol")
- RegisterUnitEvent(AddA, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddB, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddC, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddD, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddE, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddF, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddG, 4, "Adds_OnDead_Ohlol")
- RegisterUnitEvent(AddH, 4, "Adds_OnDead_Ohlol")
- ---------------------------------------------------------
- -- Boss -------------------------------------------------
- ---------------------------------------------------------
- function BOSS_ONDEATH_HURPDURP(pUnit)
- pUnit:RemoveEvents()
- CanStart = true
- pUnit:SendChatMessage(12,0,"Death... Is only the beginning.")
- end
- function BOSS_ONLEAVE_HURPDURP(pUnit)
- pUnit:RemoveEvents()
- pUnit:Despawn(5000, 0)
- CanStart = true
- end
- function Boss_ONSPAWN_DEFENDMALL(pUnit)
- pUnit:SetPhase(2)
- pUnit:RegisterEvent("CheckFOrPlayers_HUtoayp", 2500, 0)
- end
- function CheckFOrPlayers_HUtoayp(pUnit)
- local plr = pUnit:GetClosestPlayer()
- if plr ~= nil then
- if plr:GetPhase() == 2 then
- if pUnit:GetDistanceYards(plr) < 8 then
- pUnit:RemoveEvents()
- pUnit:SendChatMessage(12,0,"Welcome all, salutations are in order. My name is Arugal and unfortunately, you appear to be on tonights menu.")
- pUnit:MoveTo(4552.8, 2769.2, 351.4, 3)
- pUnit:EquipWeapons(18842, 0, 0)
- pUnit:RegisterEvent("WalkingDownStairs_DEFENDMALL", 11000, 1)
- end
- end
- end
- end
- function WalkingDownStairs_DEFENDMALL(pUnit)
- pUnit:SendChatMessage(12,0,"Let me tenderise you all.")
- pUnit:Emote(1,3000)
- pUnit:RegisterEvent("Delay_A_Moment_GPOAJ", 4000, 1)
- end
- function Delay_A_Moment_GPOAJ(pUnit)
- pUnit:CastSpell(29880) -- Mana shield
- pUnit:Root()
- pUnit:SetFaction(21)
- local plr = nil
- local i = 0
- while i ~= 10 do
- i = i + 1
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:GetPhase() == 2 then
- pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
- pUnit:CastSpellOnTarget(7124, plr) -- Damage
- end
- end
- end
- pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
- pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
- end
- function Shadowbolt_Spam_Three_Argual(pUnit)
- local plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:GetPhase() == 2 then
- if math.random(1,2) == 1 then
- pUnit:FullCastSpellOnTarget(12739, plr) -- shadowbolt
- else
- pUnit:FullCastSpell(39082) -- shadowfury
- end
- end
- end
- end
- function VolleyOfShadowbolts(pUnit)
- local plr = nil
- local i = 0
- while i ~= 10 do
- i = i + 1
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:GetPhase() == 2 then
- pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
- pUnit:CastSpellOnTarget(7124, plr) -- Damage
- end
- end
- end
- end
- RegisterUnitEvent(BossID, 18, "Boss_ONSPAWN_DEFENDMALL")
- RegisterUnitEvent(BossID, 4, "BOSS_ONDEATH_HURPDURP")
- RegisterUnitEvent(BossID, 2, "BOSS_ONLEAVE_HURPDURP")
- ---------------------------------------------------------
- --[[
- Debug Below
- Comment out later
- ]]
- function OnChat_Hook_ToJoinBG(event, plr, message, pType, pLanguage, pMisc)
- local message = string.lower(message)
- --[[if message == "test" then
- local object = plr:GetGameObjectNearestCoords(4522, 2769, 404, 201755) -- x,y,z,id
- if object ~= nil then
- object:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open WORKSSSSS
- plr:PlaySoundToSet(16541)
- end
- end
- if message == "fix" then
- local object = plr:GetGameObjectNearestCoords(4522, 2769, 404, 201755) -- x,y,z,id
- if object ~= nil then
- object:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close, buggy
- end
- end]]
- if message == "#start" then
- CanStart = true
- end
- end
- RegisterServerHook(16, "OnChat_Hook_ToJoinBG")
- ---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment