Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- By Stoneharry
- local Ready = true
- local Lore = nil
- local MoleA = nil
- local MoleB = nil
- local i = 0
- local Spawned = {}
- local BeamA = nil
- local BeamB = nil
- local Players = {}
- local Visuals = nil
- local Boss = nil
- local OBJECT_END = 0x0006
- --local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044 -- Size: 1, Type: BYTES, Flags: PUBLIC
- local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
- local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
- local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26 33554432 cannot select the unit
- SetDBCSpellVar(54119, "c_is_flags", 0x01000) -- The Mist
- function Lorestone_spawn(pUnit, Event)
- pUnit:CastSpell(54119) -- The mist
- Lore = pUnit
- end
- RegisterUnitEvent(203120, 18, "Lorestone_spawn")
- function Elf_channel_spawn(pUnit, Event)
- pUnit:CastSpell(54119) -- The mist
- pUnit:RegisterEvent("Check_For_Ready_Elf", 5000, 0)
- end
- RegisterUnitEvent(203121, 18, "Elf_channel_spawn")
- function zzzWolly_On_Gossip(pUnit, event, player)
- pUnit:GossipCreateMenu(738, player, 0)
- if Ready then
- pUnit:GossipMenuAddItem(9, "We are ready, begin.", 246, 0)
- end
- pUnit:GossipMenuAddItem(0, "Nevermind.", 250, 0)
- pUnit:GossipSendMenu(player)
- end
- function zzzWolly_Gossip_Submenus(pUnit, event, player, id, intid, code)
- if(intid == 246) then
- Ready = false
- pUnit:SetNPCFlags(2)
- player:GossipComplete()
- elseif(intid == 250) then
- player:GossipComplete()
- end
- end
- RegisterUnitGossipEvent(203121, 1, "zzzWolly_On_Gossip")
- RegisterUnitGossipEvent(203121, 2, "zzzWolly_Gossip_Submenus")
- function Check_For_Ready_Elf(pUnit)
- if Ready == false then
- pUnit:CastSpell(54119) -- For effect
- Lore:CastSpell(54119) -- For effect
- pUnit:SendChatMessage(12,0,"This is our final stand, make every blow count!")
- pUnit:PlaySoundToSet(11062)
- Lore:ChannelSpell(48316, pUnit) -- soul sucker
- pUnit:ChannelSpell(13540, Lore) -- Green channel
- pUnit:RemoveEvents()
- i = 0
- pUnit:RegisterEvent("EventFunction_Handler", 3500, 1)
- end
- end
- function EventFunction_Handler(pUnit)
- if i == 0 then
- MoleA = pUnit:GetGameObjectNearestCoords(-517, 2232.7, 539.3, 188478)
- MoleA:SetByte(0x0006+0x000B,0,0) -- Open
- pUnit:RegisterEvent("EventFunction_Handler", 700, 1)
- elseif i == 1 then
- MoleB = pUnit:GetGameObjectNearestCoords(-515.8, 2187.9, 539.3, 188478)
- MoleB:SetByte(0x0006+0x000B,0,0) -- Open
- pUnit:RegisterEvent("EventFunction_Handler", 3000, 1)
- elseif i == 2 then
- pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 7945, 3450, 0)
- pUnit:SpawnCreature(203122, -519.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
- pUnit:RegisterEvent("EventFunction_Handler", 3000, 1)
- elseif i == 3 then
- MoleA:SetByte(0x0006+0x000B,0,1) -- Close
- MoleB:SetByte(0x0006+0x000B,0,1) -- Close
- pUnit:SendChatMessage(12,0,"Fight! Fight till your dying breath!")
- pUnit:PlaySoundToSet(11063)
- pUnit:RegisterEvent("EventFunction_Handler", 22000, 1)
- elseif i == 4 then
- MoleA:SetByte(0x0006+0x000B,0,0) -- Open
- MoleB:SetByte(0x0006+0x000B,0,0) -- Open
- pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
- elseif i == 5 then
- pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 23171, 0, 0)
- pUnit:SpawnCreature(203122, -520, 2230.6, 542, 4.394675, 21, 120000, 7945, 3450, 0)
- pUnit:SpawnCreature(203122, -519.44, 2191, 542, 2.004, 21, 120000, 23171, 0, 0)
- pUnit:SpawnCreature(203122, -518.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
- pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
- elseif i == 6 then
- MoleA:SetByte(0x0006+0x000B,0,1) -- Close
- MoleB:SetByte(0x0006+0x000B,0,1) -- Close
- pUnit:SendChatMessage(12,0,"Give every ounce of strength, do not despair!")
- pUnit:PlaySoundToSet(11064)
- for place,creature in pairs(Spawned) do
- if creature ~= nil then
- if creature:IsInWorld() then
- if creature:IsAlive() == false then
- creature:Despawn(1000,0)
- end
- end
- end
- end
- pUnit:RegisterEvent("EventFunction_Handler", 30000, 1)
- elseif i == 7 then
- pUnit:SendChatMessage(42,0,"Stay out of the red lights!")
- local plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:HasAura(54119) then
- BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
- else
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
- end
- end
- end
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:HasAura(54119) then
- BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
- else
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
- end
- end
- end
- BeamA:SetUnitToFollow(BeamA:GetClosestPlayer(), 0.2, 1)
- BeamB:SetUnitToFollow(BeamB:GetClosestPlayer(), 0.2, 1)
- BeamA:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
- BeamB:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
- pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
- elseif i == 8 then
- for place,creature in pairs(Spawned) do
- if creature ~= nil then
- if creature:IsInWorld() then
- if creature:IsAlive() == false then
- creature:Despawn(1500,0)
- end
- end
- end
- Spawned[place] = nil
- end
- BeamA:CastSpell(32839) -- Red beam
- BeamB:CastSpell(32839)
- pUnit:RegisterEvent("CheckForNearbyPlayers_Beams", 1500, 0)
- pUnit:RegisterEvent("EventFunction_Handler", 45000, 1)
- elseif i == 9 then
- pUnit:RemoveEvents()
- BeamA:RemoveAura(32839) -- Red Beam
- BeamB:RemoveAura(32839)
- BeamA:Despawn(2000, 0)
- BeamB:Despawn(2000, 0)
- BeamA = nil
- BeamB = nil
- pUnit:SendChatMessage(12,0,"We can not hold them off for long!")
- pUnit:PlaySoundToSet(11065)
- pUnit:RegisterEvent("EventFunction_Handler", 5000, 1)
- elseif i == 10 then
- pUnit:SendChatMessage(42,0,"Stay within the blue light!")
- pUnit:CastSpell(32840) -- Blue beam
- pUnit:RegisterEvent("EventFunction_Handler", 8000, 1)
- elseif i == 11 then
- for a, plrs in pairs(pUnit:GetInRangePlayers()) do
- if plrs:HasAura(54119) then
- if pUnit:GetDistanceYards(plrs) > 7.5 then
- plrs:CastSpell(39180)
- table.insert(Players, plrs)
- end
- end
- end
- pUnit:RemoveAura(32840)
- pUnit:RegisterEvent("EventFunction_Handler", 700, 1)
- elseif i == 12 then
- for a, plrs in pairs(Players) do
- plrs:CastSpell(7)
- Players[a] = nil
- end
- pUnit:StopChannel()
- Lore:StopChannel()
- Visuals = pUnit:SpawnCreature(203124, Lore:GetX(), Lore:GetY(), Lore:GetZ(), 0, 35, 0)
- Visuals:ChannelSpell(56571, pUnit)
- pUnit:RegisterEvent("EventFunction_Handler", 4000, 1)
- elseif i == 13 then
- pUnit:SendChatMessage(12,0,"It is finished then. This is the end - for all of us.")
- pUnit:PlaySoundToSet(11067)
- pUnit:RegisterEvent("EventFunction_Handler", 7500, 1)
- elseif i == 14 then
- Visuals:StopChannel()
- Visuals:CastSpell(59084) -- boom visual
- Visuals:Despawn(5500, 0)
- Visuals = nil
- pUnit:RegisterEvent("EventFunction_Handler", 2750, 1)
- elseif i == 15 then
- if Boss == nil then
- Boss = pUnit:SpawnCreature(203125, Lore:GetX(), Lore:GetY(), Lore:GetZ(), Lore:GetO(), 21, 0, 4548, 0, 0)
- Boss:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- Boss:CastSpell(54119) -- mist
- else
- if Boss:IsAlive() then
- i = i - 1
- end
- end
- pUnit:RegisterEvent("EventFunction_Handler", 5000, 1) -- Remove soon, register on boss death
- elseif i == 16 then
- i = -1
- if Boss ~= nil then
- Boss:Despawn(1500, 0)
- Boss = nil
- end
- Ready = true
- pUnit:RemoveEvents()
- Lore:StopChannel()
- pUnit:StopChannel()
- pUnit:SetNPCFlags(3)
- pUnit:RegisterEvent("Check_For_Ready_Elf", 5000, 0)
- end
- i = i + 1
- end
- function CheckForNearbyPlayers_Beams(pUnit)
- local plr = BeamA:GetClosestPlayer()
- if plr ~= nil then
- if plr:GetDistanceYards(BeamA) < 7 then
- if plr:HasAura(54119) then
- plr:CastSpell(43418) -- impact
- BeamA:Strike(plr, 0, 38043, 890, 990, 2)
- end
- end
- end
- plr = BeamB:GetClosestPlayer()
- if plr ~= nil then
- if plr:GetDistanceYards(BeamB) < 7 then
- if plr:HasAura(54119) then
- plr:CastSpell(43418) -- impact
- BeamB:Strike(plr, 0, 38043, 890, 990, 2)
- end
- end
- end
- end
- ------------------------------------------------------------------------------
- function random_npc_onspawn(pUnit, Event)
- pUnit:RegisterEvent("travel_spawn_lag", 1000, 1)
- end
- function travel_spawn_lag(pUnit)
- table.insert(Spawned, pUnit)
- local plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:HasAura(54119) then
- pUnit:CastSpell(54119) -- mist
- pUnit:SetMovementFlags(1)
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- else
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:HasAura(54119) then
- pUnit:CastSpell(54119) -- mist
- pUnit:SetMovementFlags(1)
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- end
- end
- end
- else
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- if plr:HasAura(54119) then
- pUnit:CastSpell(54119) -- mist
- pUnit:SetMovementFlags(1)
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- end
- end
- end
- end
- RegisterUnitEvent(203122, 18, "random_npc_onspawn")
- --
Advertisement
Add Comment
Please, Sign In to add comment