stoneharry

Untitled

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