stoneharry

Untitled

Jun 15th, 2011
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.40 KB | None | 0 0
  1.  
  2. -- By Stoneharry
  3.  
  4. local Ready = true
  5. local Lore = nil
  6. local MoleA = nil
  7. local MoleB = nil
  8. local i = 0
  9. local Spawned = {}
  10. local BeamA = nil
  11. local BeamB = nil
  12. local Players = {}
  13. local Visuals = nil
  14. local Boss = nil
  15.  
  16. local OBJECT_END = 0x0006
  17. --local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044 -- Size: 1, Type: BYTES, Flags: PUBLIC
  18. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  19. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  20. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  21.  
  22.  
  23. SetDBCSpellVar(54119, "c_is_flags", 0x01000) -- The Mist
  24.  
  25. function Lorestone_spawn(pUnit, Event)
  26.     pUnit:CastSpell(54119) -- The mist
  27.     Lore = pUnit
  28. end
  29.  
  30. RegisterUnitEvent(203120, 18, "Lorestone_spawn")
  31.  
  32. function Elf_channel_spawn(pUnit, Event)
  33.     pUnit:CastSpell(54119) -- The mist
  34.     pUnit:RegisterEvent("Check_For_Ready_Elf", 5000, 0)
  35. end
  36.  
  37. RegisterUnitEvent(203121, 18, "Elf_channel_spawn")
  38.  
  39. function zzzWolly_On_Gossip(pUnit, event, player)
  40.     pUnit:GossipCreateMenu(738, player, 0)
  41.     if Ready then
  42.         pUnit:GossipMenuAddItem(9, "We are ready, begin.", 246, 0)
  43.     end
  44.     pUnit:GossipMenuAddItem(0, "Nevermind.", 250, 0)
  45.     pUnit:GossipSendMenu(player)
  46. end
  47.  
  48. function zzzWolly_Gossip_Submenus(pUnit, event, player, id, intid, code)
  49.     if(intid == 246) then
  50.         Ready = false
  51.         pUnit:SetNPCFlags(2)
  52.         player:GossipComplete()
  53.     elseif(intid == 250) then
  54.         player:GossipComplete()
  55.     end
  56. end
  57.  
  58. RegisterUnitGossipEvent(203121, 1, "zzzWolly_On_Gossip")
  59. RegisterUnitGossipEvent(203121, 2, "zzzWolly_Gossip_Submenus")
  60.  
  61. function Check_For_Ready_Elf(pUnit)
  62.     if Ready == false then
  63.         pUnit:CastSpell(54119) -- For effect
  64.         Lore:CastSpell(54119) -- For effect
  65.         pUnit:SendChatMessage(12,0,"This is our final stand, make every blow count!")
  66.         pUnit:PlaySoundToSet(11062)
  67.         Lore:ChannelSpell(48316, pUnit) -- soul sucker
  68.         pUnit:ChannelSpell(13540, Lore) -- Green channel
  69.         pUnit:RemoveEvents()
  70.         i = 0
  71.         pUnit:RegisterEvent("EventFunction_Handler", 3500, 1)
  72.     end
  73. end
  74.  
  75. function EventFunction_Handler(pUnit)
  76.     if i == 0 then
  77.         MoleA = pUnit:GetGameObjectNearestCoords(-517, 2232.7, 539.3, 188478)
  78.         MoleA:SetByte(0x0006+0x000B,0,0) -- Open
  79.         pUnit:RegisterEvent("EventFunction_Handler", 700, 1)
  80.     elseif i == 1 then
  81.         MoleB = pUnit:GetGameObjectNearestCoords(-515.8, 2187.9, 539.3, 188478)
  82.         MoleB:SetByte(0x0006+0x000B,0,0) -- Open
  83.         pUnit:RegisterEvent("EventFunction_Handler", 3000, 1)
  84.     elseif i == 2 then
  85.         pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 7945, 3450, 0)
  86.         pUnit:SpawnCreature(203122, -519.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
  87.         pUnit:RegisterEvent("EventFunction_Handler", 3000, 1)
  88.     elseif i == 3 then
  89.         MoleA:SetByte(0x0006+0x000B,0,1) -- Close
  90.         MoleB:SetByte(0x0006+0x000B,0,1) -- Close
  91.         pUnit:SendChatMessage(12,0,"Fight! Fight till your dying breath!")
  92.         pUnit:PlaySoundToSet(11063)
  93.         pUnit:RegisterEvent("EventFunction_Handler", 22000, 1)
  94.     elseif i == 4 then
  95.         MoleA:SetByte(0x0006+0x000B,0,0) -- Open
  96.         MoleB:SetByte(0x0006+0x000B,0,0) -- Open
  97.         pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
  98.     elseif i == 5 then
  99.         pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 23171, 0, 0)
  100.         pUnit:SpawnCreature(203122, -520, 2230.6, 542, 4.394675, 21, 120000, 7945, 3450, 0)
  101.         pUnit:SpawnCreature(203122, -519.44, 2191, 542, 2.004, 21, 120000, 23171, 0, 0)
  102.         pUnit:SpawnCreature(203122, -518.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
  103.         pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
  104.     elseif i == 6 then
  105.         MoleA:SetByte(0x0006+0x000B,0,1) -- Close
  106.         MoleB:SetByte(0x0006+0x000B,0,1) -- Close
  107.         pUnit:SendChatMessage(12,0,"Give every ounce of strength, do not despair!")
  108.         pUnit:PlaySoundToSet(11064)
  109.         for place,creature in pairs(Spawned) do
  110.             if creature ~= nil then
  111.                 if creature:IsInWorld() then
  112.                     if creature:IsAlive() == false then
  113.                         creature:Despawn(1000,0)
  114.                     end
  115.                 end
  116.             end
  117.         end
  118.         pUnit:RegisterEvent("EventFunction_Handler", 30000, 1)
  119.     elseif i == 7 then
  120.         pUnit:SendChatMessage(42,0,"Stay out of the red lights!")
  121.         local plr = pUnit:GetRandomPlayer(0)
  122.         if plr ~= nil then
  123.             if plr:HasAura(54119) then
  124.                 BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  125.             else
  126.                 plr = pUnit:GetRandomPlayer(0)
  127.                 if plr ~= nil then
  128.                     BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  129.                 end
  130.             end
  131.         end
  132.         plr = pUnit:GetRandomPlayer(0)
  133.         if plr ~= nil then
  134.             if plr:HasAura(54119) then
  135.                 BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  136.             else
  137.                 plr = pUnit:GetRandomPlayer(0)
  138.                 if plr ~= nil then
  139.                     BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  140.                 end
  141.             end
  142.         end
  143.         BeamA:SetUnitToFollow(BeamA:GetClosestPlayer(), 0.2, 1)
  144.         BeamB:SetUnitToFollow(BeamB:GetClosestPlayer(), 0.2, 1)
  145.         BeamA:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  146.         BeamB:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  147.         pUnit:RegisterEvent("EventFunction_Handler", 2000, 1)
  148.     elseif i == 8 then
  149.         for place,creature in pairs(Spawned) do
  150.             if creature ~= nil then
  151.                 if creature:IsInWorld() then
  152.                     if creature:IsAlive() == false then
  153.                         creature:Despawn(1500,0)
  154.                     end
  155.                 end
  156.             end
  157.             Spawned[place] = nil
  158.         end
  159.         BeamA:CastSpell(32839) -- Red beam
  160.         BeamB:CastSpell(32839)
  161.         pUnit:RegisterEvent("CheckForNearbyPlayers_Beams", 1500, 0)
  162.         pUnit:RegisterEvent("EventFunction_Handler", 45000, 1)
  163.     elseif i == 9 then
  164.         pUnit:RemoveEvents()
  165.         BeamA:RemoveAura(32839) -- Red Beam
  166.         BeamB:RemoveAura(32839)
  167.         BeamA:Despawn(2000, 0)
  168.         BeamB:Despawn(2000, 0)
  169.         BeamA = nil
  170.         BeamB = nil
  171.         pUnit:SendChatMessage(12,0,"We can not hold them off for long!")
  172.         pUnit:PlaySoundToSet(11065)
  173.         pUnit:RegisterEvent("EventFunction_Handler", 5000, 1)
  174.     elseif i == 10 then
  175.         pUnit:SendChatMessage(42,0,"Stay within the blue light!")
  176.         pUnit:CastSpell(32840) -- Blue beam
  177.         pUnit:RegisterEvent("EventFunction_Handler", 8000, 1)
  178.     elseif i == 11 then
  179.         for a, plrs in pairs(pUnit:GetInRangePlayers()) do
  180.             if plrs:HasAura(54119) then
  181.                 if pUnit:GetDistanceYards(plrs) > 7.5 then
  182.                     plrs:CastSpell(39180)
  183.                     table.insert(Players, plrs)
  184.                 end
  185.             end
  186.         end
  187.         pUnit:RemoveAura(32840)
  188.         pUnit:RegisterEvent("EventFunction_Handler", 700, 1)
  189.     elseif i == 12 then
  190.         for a, plrs in pairs(Players) do
  191.             plrs:CastSpell(7)
  192.             Players[a] = nil
  193.         end
  194.         pUnit:StopChannel()
  195.         Lore:StopChannel()
  196.         Visuals = pUnit:SpawnCreature(203124, Lore:GetX(), Lore:GetY(), Lore:GetZ(), 0, 35, 0)
  197.         Visuals:ChannelSpell(56571, pUnit)
  198.         pUnit:RegisterEvent("EventFunction_Handler", 4000, 1)
  199.     elseif i == 13 then
  200.         pUnit:SendChatMessage(12,0,"It is finished then. This is the end - for all of us.")
  201.         pUnit:PlaySoundToSet(11067)
  202.         pUnit:RegisterEvent("EventFunction_Handler", 7500, 1)
  203.     elseif i == 14 then
  204.         Visuals:StopChannel()
  205.         Visuals:CastSpell(59084) -- boom visual
  206.         Visuals:Despawn(5500, 0)
  207.         Visuals = nil
  208.         pUnit:RegisterEvent("EventFunction_Handler", 2750, 1)
  209.     elseif i == 15 then
  210.         if Boss == nil then
  211.             Boss = pUnit:SpawnCreature(203125, Lore:GetX(), Lore:GetY(), Lore:GetZ(), Lore:GetO(), 21, 0, 4548, 0, 0)
  212.             Boss:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  213.             Boss:CastSpell(54119) -- mist
  214.         else
  215.             if Boss:IsAlive() then
  216.                 i = i - 1
  217.             end
  218.         end
  219.         pUnit:RegisterEvent("EventFunction_Handler", 5000, 1) -- Remove soon, register on boss death
  220.     elseif i == 16 then
  221.         i = -1
  222.         if Boss ~= nil then
  223.             Boss:Despawn(1500, 0)
  224.             Boss = nil
  225.         end
  226.         Ready = true
  227.         pUnit:RemoveEvents()
  228.         Lore:StopChannel()
  229.         pUnit:StopChannel()
  230.         pUnit:SetNPCFlags(3)
  231.         pUnit:RegisterEvent("Check_For_Ready_Elf", 5000, 0)
  232.     end
  233.     i = i + 1
  234. end
  235.  
  236. function CheckForNearbyPlayers_Beams(pUnit)
  237.     local plr = BeamA:GetClosestPlayer()
  238.     if plr ~= nil then
  239.         if plr:GetDistanceYards(BeamA) < 7 then
  240.             if plr:HasAura(54119) then
  241.                 plr:CastSpell(43418) -- impact
  242.                 BeamA:Strike(plr, 0, 38043, 890, 990, 2)
  243.             end
  244.         end
  245.     end
  246.     plr = BeamB:GetClosestPlayer()
  247.     if plr ~= nil then
  248.         if plr:GetDistanceYards(BeamB) < 7 then
  249.             if plr:HasAura(54119) then
  250.                 plr:CastSpell(43418) -- impact
  251.                 BeamB:Strike(plr, 0, 38043, 890, 990, 2)
  252.             end
  253.         end
  254.     end
  255. end
  256.  
  257. ------------------------------------------------------------------------------
  258.  
  259. function random_npc_onspawn(pUnit, Event)
  260.     pUnit:RegisterEvent("travel_spawn_lag", 1000, 1)
  261. end
  262.  
  263. function travel_spawn_lag(pUnit)
  264.     table.insert(Spawned, pUnit)
  265.     local plr = pUnit:GetRandomPlayer(0)
  266.     if plr ~= nil then
  267.         if plr:HasAura(54119) then
  268.             pUnit:CastSpell(54119) -- mist
  269.             pUnit:SetMovementFlags(1)
  270.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  271.             pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  272.         else
  273.             plr = pUnit:GetRandomPlayer(0)
  274.             if plr ~= nil then
  275.                 if plr:HasAura(54119) then
  276.                     pUnit:CastSpell(54119) -- mist
  277.                     pUnit:SetMovementFlags(1)
  278.                     pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  279.                     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  280.                 end
  281.             end    
  282.         end
  283.     else
  284.         plr = pUnit:GetRandomPlayer(0)
  285.         if plr ~= nil then
  286.             if plr:HasAura(54119) then
  287.                 pUnit:CastSpell(54119) -- mist
  288.                 pUnit:SetMovementFlags(1)
  289.                 pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  290.                 pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  291.             end
  292.         end
  293.     end
  294. end
  295.  
  296. RegisterUnitEvent(203122, 18, "random_npc_onspawn")
  297.  
  298. --
Advertisement
Add Comment
Please, Sign In to add comment