Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: None | Size: 31.29 KB | Hits: 51 | Expires: Never
Copy text to clipboard
  1. ------------------------------------------------------------------
  2. --[[
  3. This script was made by Stoneharry of www.MMOwned.com
  4. This script may be edited and changed at will, but credits must be provided.
  5. Thank you.
  6.  
  7. Please note the following has not been included within this script:
  8. - 25man version
  9. - Defile
  10. - Frostmourne Chamber
  11. ]]
  12. ------------------------------------------------------------------
  13.  
  14. local Lich = nil
  15. local Tirion = nil
  16. local package = nil
  17. local Terenas = nil
  18. local Count = 0
  19. local Phase = 0
  20. local Players_Wiped = 0
  21.  
  22. ---- Checkers ----------------------------------------------------
  23.  
  24. if GetLuaEngine() ~= "LuaHypArc" then -- Make sure we are using LuaHypArc
  25.         print("-------------------------------------------------------------------")
  26.         print("LuaHypArc is not installed. This script may not function correctly.")
  27.         print("LuaHypArc comes with ArcEmu by default.")
  28.         print("-------------------------------------------------------------------")
  29.         else
  30.         print("-------------------------------------------------------")
  31.         print("-- The Lich King - Made by Stoneharry of MMOwned.com --")
  32.         print("--                     Enjoy                         --")
  33.         print("-------------------------------------------------------")
  34. end
  35.  
  36. ---- Lich King ---------------------------------------------------
  37.  
  38. function LichKing_OnSpawn(pUnit, Event)
  39.         pUnit:RegisterEvent("LichKing_OnSpawn_Go", 1000, 1)
  40. end
  41.  
  42. function LichKing_OnSpawn_Go(pUnit, Event)
  43.         if Lich ~= nil then -- Do a check
  44.         Lich:RemoveFromWorld()
  45.         end
  46.         Lich = pUnit
  47.         Lich:SetFaction(35)
  48. end
  49.  
  50. RegisterUnitEvent(3072111, 18, "LichKing_OnSpawn")
  51.  
  52. ---- Tirion ------------------------------------------------------
  53.  
  54. function TirionFordring_OnSpawn(pUnit, Event)
  55.         pUnit:RegisterEvent("TirionFordring_OnSpawn_Go", 5000, 0)
  56. end
  57.  
  58. function TirionFordring_OnSpawn_Go(pUnit, Event)
  59.         if Lich ~= nil then -- If theres no lich king we can't start the event
  60.                 local plr = pUnit:GetClosestPlayer()
  61.                 if plr ~= nil then -- we need a player
  62.                         if pUnit:GetDistanceYards(plr) < 5 then -- we are close enough to start
  63.                                 local PlayersAllAround = pUnit:GetInRangePlayers()
  64.                                 for a, players in pairs(PlayersAllAround) do
  65.                                 players:CastSpell(69127)
  66.                                 end
  67.                         pUnit:PlaySoundToSet(17458)
  68.                         pUnit:RemoveEvents() -- Stop repeating
  69.                         Lich:MoveTo(461.47, -2123.73, 1572.1, 0)
  70.                         pUnit:Emote(375, 60000)
  71.                         pUnit:PlaySoundToSet(17349) -- pUnit since players are closer to him
  72.                         Lich:SendChatMessage(14, 0, "So...the Light's vaunted justice has finally arrived. Shall I lay down Frostmourne and throw myself at your mercy, Fordring?")
  73.                         pUnit:RegisterEvent("TirionFordring_OnSpawn_Goz", 13500, 1)
  74.                         end
  75.                 end
  76.         end
  77. end
  78.  
  79. RegisterUnitEvent(26529762, 18, "TirionFordring_OnSpawn")
  80.  
  81. function TirionFordring_OnSpawn_Goz(pUnit, Event)
  82.         pUnit:SendChatMessage(14,0,"We will grant you a swift death, Arthas. More than can be said for the thousands you've tortured and slain.")
  83.         pUnit:PlaySoundToSet(17390)
  84.         local PlayersAllAround = pUnit:GetInRangePlayers()
  85.         for a, players in pairs(PlayersAllAround) do
  86.         players:CastSpell(69127)
  87.         end
  88.         pUnit:RegisterEvent("TirionFordring_OnSpawn_Gozz", 9000, 1)
  89. end
  90.  
  91. function TirionFordring_OnSpawn_Gozz(pUnit, Event)
  92.         Lich:SendChatMessage(14,0,"You will learn of that first hand. When my work is complete, you will beg for mercy -- and I will deny you. Your anguished cries will be testament to my unbridled power.")
  93.         pUnit:PlaySoundToSet(17350)
  94.         Lich:Emote(397, 4000)
  95.         pUnit:RegisterEvent("zTirionFordring_OnSpawn_Gozzz", 4500, 1)
  96.         pUnit:RegisterEvent("zzTirionFordring_OnSpawn_Gozzz", 12000, 1)
  97.         pUnit:RegisterEvent("TirionFordring_OnSpawn_Gozzz", 22000, 1)
  98. end
  99.  
  100. function zTirionFordring_OnSpawn_Gozzz(pUnit, Event)
  101.         Lich:Emote(1, 6000)
  102. end
  103.  
  104. function zzTirionFordring_OnSpawn_Gozzz(pUnit, Event)
  105.         Lich:Emote(392, 3500)
  106. end
  107.  
  108. function TirionFordring_OnSpawn_Gozzz(pUnit, Event)
  109.         Lich:SendChatMessage(14,0,"So be it. Champions, attack!")
  110.         pUnit:PlaySoundToSet(17391)
  111.         pUnit:Emote(397, 2000)
  112.         pUnit:RegisterEvent("PATHETIC_RUN_TIRION", 2000, 1)
  113.         pUnit:RegisterEvent("TirionFordring_OnSpawn_Gozzzz", 3000, 1)
  114.         pUnit:RegisterEvent("TirionFordring_zzz_Gozzzz", 4500, 1)
  115. end
  116.  
  117. function PATHETIC_RUN_TIRION(pUnit, Event)
  118.         pUnit:SetMovementFlags(1)
  119.         pUnit:MoveTo(485.92, -2123.2, 1572.1, 3.17)
  120. end
  121.  
  122. function TirionFordring_OnSpawn_Gozzzz(pUnit, Event)
  123.         Lich:SendChatMessage(14,0,"I'll keep you alive to witness the end, Fordring. I would not want the Light's greatest champion to miss seeing this wretched world remade in my image.")
  124.         pUnit:PlaySoundToSet(17351)
  125.         local PlayersAllAround = pUnit:GetInRangePlayers()
  126.         for a, players in pairs(PlayersAllAround) do
  127.         players:CastSpell(69127)
  128.         end
  129.         Tirion = pUnit
  130. end
  131.  
  132. function TirionFordring_zzz_Gozzzz(pUnit, Event)
  133. Tirion:CastSpell(71614)
  134. Lich:SetFaction(22)
  135. end
  136.  
  137. -------- Rage Counter ---------------------------------------------
  138.  
  139. function Rage_Counter_Lich_King(pUnit, Event)
  140.         if Lich == nil then
  141.         pUnit:RemoveEvents()
  142.         else
  143.                 if Count == 300 then
  144.                         if Phase == 2 then
  145.                         Count = 0
  146.                         Phase = 0
  147.                         Lich:RemoveEvents()
  148.                         Lich:SendChatMessage(14,0,"Face now your tragic end!")
  149.                         Lich:PlaySoundToSet(17365)
  150.                         else
  151.                         Lich:FullCastSpell(72143) -- Enrage, dunno real spell so we use this method :3
  152.                         Phase = Phase + 1
  153.                         end
  154.                 else
  155.                 Count = Count + 5
  156.                 end
  157.         end
  158. end
  159.  
  160. -------- Fight ----------------------------------------------------
  161.  
  162. function LichKingHasEnteredCombatLawl_Phase_One(pUnit, Event)
  163.         if Tirion == nil then
  164.         pUnit:Despawn(1, 10000) -- Where the F is he
  165.         Lich = nil -- Reset
  166.         else
  167.                 if Players_Wiped == 1 then
  168.                 Players_Wiped = 0
  169.                 Lich:SetHealthPct(10)
  170.                 else
  171.                 Lich:SetCombatCapable(0)
  172.                 Lich:RegisterEvent("Rage_Counter_Lich_King", 5000, 0)
  173.                 Lich:RegisterEvent("Adds_Spawning_Incoming_Dredge_Ghouls", 19000, 0) -- Every 20 seconds (19 + 1 for next)
  174.                 Lich:RegisterEvent("Adds_Spawning_Incoming_Shambling_Horror", math.random(60000,70000), 0) -- Every 60-70 seconds (changes each match)
  175.                 Lich:RegisterEvent("Necrotic_Plague_Incoming", 20000, 0)
  176.                 Lich:RegisterEvent("Infest_Big_AOE_Incoming", 30000, 0)
  177.                 Lich:RegisterEvent("Phase_Two_Checker", 2500, 0)
  178.                 end
  179.         end
  180. end
  181.  
  182. function Adds_Spawning_Incoming_Dredge_Ghouls(pUnit, Event)
  183.         Lich:RegisterEvent("Adds_Spawning_Incoming_Dredge_Ghoulsz", 1000, 3) -- 3 times
  184. end
  185.  
  186. function Adds_Spawning_Incoming_Dredge_Ghoulsz(pUnit, Event)
  187.         local x = Lich:GetX()
  188.         local y = Lich:GetY()
  189.         local z = Lich:GetZ()
  190.         local o = Lich:GetO()
  191.         if math.random(1,2) == 1 then -- Spawn in different locations basically
  192.         Lich:SpawnCreature(3769511, x+math.random(1,6), y+math.random(1,6), z, o, 15, 360000)
  193.         else
  194.         Lich:SpawnCreature(3769511, x-math.random(1,6), y-math.random(1,6), z, o, 15, 360000)
  195.         end
  196. end
  197.  
  198. function Adds_Spawning_Incoming_Shambling_Horror(pUnit, Event)
  199.         local x = Lich:GetX()
  200.         local y = Lich:GetY()
  201.         local z = Lich:GetZ()
  202.         local o = Lich:GetO()
  203.         if math.random(1,2) == 1 then -- Spawn in different locations basically
  204.         Lich:SpawnCreature(3769811, x+math.random(1,6), y+math.random(1,6), z, o, 15, 360000)
  205.         else
  206.         Lich:SpawnCreature(3769811, x-math.random(1,6), y-math.random(1,6), z, o, 15, 360000)
  207.         end
  208. end
  209.  
  210. function Necrotic_Plague_Incoming(pUnit, Event)
  211.         local plr = Lich:GetRandomPlayer(0) -- I think this is correct
  212.         if plr ~= nil then
  213.         Lich:FullCastSpellOnTarget(70337, plr) -- ^ ^ ^ ^ ^ ^ ^ ^ ^
  214.         end
  215. end
  216.  
  217. function Infest_Big_AOE_Incoming(pUnit, Event)
  218.         Lich:FullCastSpell(70541)
  219. end
  220.  
  221. RegisterUnitEvent(3072111, 1, "LichKingHasEnteredCombatLawl_Phase_One")
  222.  
  223. function Phase_Two_Checker(pUnit, Event)
  224.         if Lich:GetHealthPct() < 71 then
  225.         Lich:RemoveEvents()
  226.         Lich:MoveTo(512.7, -2120.5, 1572.1, 0)
  227.         Lich:SetMovementFlags(1)
  228.         Lich:SetCombatCapable(1)
  229.         Lich:RegisterEvent("Test_Debug_MoveToCentreOfRoom", 100, 0)
  230.         Lich:RegisterEvent("Test_Debug_MoveToCentreOfRoom_z", 4005, 1)
  231.         end
  232. end
  233.  
  234. function Test_Debug_MoveToCentreOfRoom(pUnit, Event)
  235.         Lich:MoveTo(512.7, -2120.5, 1572.1, 0)
  236.         Lich:SetMovementFlags(1)
  237. end
  238.  
  239. function Test_Debug_MoveToCentreOfRoom_z(pUnit, Event)
  240.         Lich:RemoveEvents()
  241.         Lich:Root()
  242.         Lich:FullCastSpell(68981)
  243.         Lich:SendChatMessage(14,0,"I will freeze you from within until all that remains is an icy husk!")
  244.         Lich:PlaySoundToSet(17369)
  245.         Lich:RegisterEvent("weaiyhoahg_delay", 6000, 1)
  246. end
  247.  
  248. function weaiyhoahg_delay(pUnit, Event)
  249.         local x = Lich:GetX()
  250.         local y = Lich:GetY()
  251.         Lich:SpawnCreature(3769812, x+math.random(3,6), y+math.random(3,6), Lich:GetZ(), Lich:GetZ(), 21, 10000)
  252.         Lich:RegisterEvent("Spam_Of_Lightning_That_Looks_Crap_But_Is_Blizzlike", 1500, 0)
  253.         Lich:RegisterEvent("NeedToWaitBecauseAddsBreakAndShizzleOrSomething", 3005, 1)
  254.         Lich:RegisterEvent("RandomRagingSpiritAddsThatAreNotRandom", 19990, 3) -- So we can get 3 in a minute without removing events
  255.         Lich:RegisterEvent("Test_Despawn_Outer_Shell", 59000, 0)
  256. end
  257.  
  258. function NeedToWaitBecauseAddsBreakAndShizzleOrSomething(pUnit,Event)
  259.         local x = Lich:GetX()
  260.         local y = Lich:GetY()
  261.         Lich:SpawnCreature(3769812, x-math.random(3,6), y-math.random(3,6), Lich:GetZ(), Lich:GetZ(), 21, 10000)
  262. end
  263.  
  264. function RandomRagingSpiritAddsThatAreNotRandom(pUnit, Event)
  265.         local plr = Lich:GetRandomPlayer(0)
  266.         if plr ~= nil then
  267.         local x,y,z,o = plr:GetX(),plr:GetY(),plr:GetZ(),plr:GetO()
  268.         Lich:SpawnCreature(3769813, x,y,z,o , 21, 360000)
  269.         end
  270. end
  271.  
  272. function Spam_Of_Lightning_That_Looks_Crap_But_Is_Blizzlike(pUnit, Event)
  273.         local plr = Lich:GetRandomPlayer(0)
  274.         if plr ~= nil then
  275.         Lich:FullCastSpellOnTarget(72133, plr)
  276.         end    
  277. end
  278.        
  279. function Test_Despawn_Outer_Shell(pUnit, Event)
  280.         Lich:RemoveEvents()
  281.         Lich:SendChatMessage(14,0,"Watch as the world around you collapses!")
  282.         Lich:PlaySoundToSet(17370)
  283.         --Lich:CastSpell(59084) -- temporary solution to no destructable object support on ArcEmu
  284.         Lich:SpawnCreature(2626262, 476.2, -2083.56, 1573.1, 0, 814, 20000)
  285.         Lich:SpawnCreature(2626262, 505.1, -2074.47, 1573.1, 0, 814, 20000)
  286.         Lich:SpawnCreature(2626262, 523.35, -2077.77, 1573.1, 0, 814, 20000)
  287.         Lich:SpawnCreature(2626262, 541, -2086.36, 1573.1, 0, 814, 20000)
  288.         Lich:SpawnCreature(2626262, 552.7, -2111.2, 1573.1, 0, 814, 20000)
  289.         Lich:SpawnCreature(2626262, 554, -2137, 1573.1, 0, 814, 20000)
  290.         Lich:SpawnCreature(2626262, 545.9, -2153.1, 1573.1, 0, 814, 20000)
  291.         Lich:SpawnCreature(2626262, 528, -2164, 1573.1, 0, 814, 20000)
  292.         Lich:SpawnCreature(2626262, 508.25, -2169.5, 1573.1, 0, 814, 20000)
  293.         Lich:SpawnCreature(2626262, 488.2, -2168, 1573.1, 0, 814, 20000)
  294.         Lich:RegisterEvent("DelayForDespawnSinceVisualTakesSomeTimeTehe_Zieghoszho", 1000, 1)
  295.         Lich:RegisterEvent("DelayForDespawnSinceVisualTakesSomeTimeTehe", 2500, 1)
  296. end
  297.  
  298. function DelayForDespawnSinceVisualTakesSomeTimeTehe_Zieghoszho(pUnit, Event)
  299.         Lich:FullCastSpell(72262) -- Epic shit I got working :D
  300. end
  301.  
  302. function DelayForDespawnSinceVisualTakesSomeTimeTehe(pUnit, Event)
  303.         local Object = Lich:GetGameObjectNearestCoords(pUnit:GetX(),pUnit:GetY(),pUnit:GetZ(), 2957197)
  304.         if Object ~= nil then
  305.         Object:Despawn(1,0)
  306.         --Lich:CastSpell(46853) -- Shakes camera
  307.         end
  308.         Lich:SetCombatCapable(0)
  309.         Lich:Unroot()
  310.         -- Phase 2
  311.         Lich:RegisterEvent("Infest_Big_AOE_Incoming", 22000, 0)
  312.         Lich:RegisterEvent("Summon_Valkyr_Shadowguard", 19500, 0)
  313.         Lich:RegisterEvent("Soul_Reaper_On_Main_Tank", 30000, 0)
  314.         Lich:RegisterEvent("Phase_TwoPointFive_Checker", 2500, 0)
  315.         -- I cba to script defile :3
  316. end
  317.  
  318. function Soul_Reaper_On_Main_Tank(pUnit, Event)
  319.         local tank = Lich:GetMainTank()
  320.         if tank ~= nil then
  321.         Lich:FullCastSpellOnTarget(69409, tank)
  322.         end
  323. end
  324.  
  325. function Summon_Valkyr_Shadowguard(pUnit, Event)
  326.         local x, y, z, o = Lich:GetX()+3, Lich:GetY(), Lich:GetZ(), Lich:GetO()
  327.         Lich:SpawnCreature(25452151, x, y, z, o, 22, 0)
  328.         Lich:SendChatMessage(14,0,"Val'kyr, your master calls!")
  329.         Lich:PlaySoundToSet(17373)
  330. end
  331.  
  332. function Phase_TwoPointFive_Checker(pUnit, Event)
  333.         if Lich:GetHealthPct() < 41 then
  334.         Lich:RemoveEvents()
  335.         Lich:MoveTo(512.7, -2120.5, 1572.1, 0)
  336.         Lich:SetMovementFlags(1)
  337.         Lich:SetCombatCapable(1)
  338.         Lich:RegisterEvent("hhTest_Debug_MoveToCentreOfRoom", 100, 0)
  339.         Lich:RegisterEvent("hhTest_Debug_MoveToCentreOfRoom_z", 4005, 1)
  340.         end
  341. end
  342.  
  343. function hhTest_Debug_MoveToCentreOfRoom(pUnit, Event)
  344.         Lich:MoveTo(512.7, -2120.5, 1572.1, 0)
  345.         Lich:SetMovementFlags(1)
  346. end
  347.  
  348. function hhTest_Debug_MoveToCentreOfRoom_z(pUnit, Event)
  349.         Lich:RemoveEvents()
  350.         Lich:Root()
  351.         Lich:FullCastSpell(68981)
  352.         Lich:SendChatMessage(14,0,"I will freeze you from within until all that remains is an icy husk!")
  353.         Lich:PlaySoundToSet(17369)
  354.         Lich:RegisterEvent("jjweaiyhoahg_delay", 6000, 1)
  355. end
  356.  
  357. function jjweaiyhoahg_delay(pUnit, Event)
  358.         local x = Lich:GetX()
  359.         local y = Lich:GetY()
  360.         Lich:SpawnCreature(3769812, x+math.random(3,6), y+math.random(3,6), Lich:GetZ(), Lich:GetZ(), 21, 10000)
  361.         Lich:RegisterEvent("Spam_Of_Lightning_That_Looks_Crap_But_Is_Blizzlike", 1500, 0)
  362.         Lich:RegisterEvent("NeedToWaitBecauseAddsBreakAndShizzleOrSomething", 3005, 1)
  363.         Lich:RegisterEvent("RandomRagingSpiritAddsThatAreNotRandom", 14000, 3)
  364.         Lich:RegisterEvent("zzzTest_Despawn_Outer_Shell", 59000, 0)
  365. end
  366.  
  367. function zzzTest_Despawn_Outer_Shell(pUnit, Event)
  368.         Lich:RemoveEvents()
  369.         Lich:SendChatMessage(14,0,"Watch as the world around you collapses!")
  370.         Lich:PlaySoundToSet(17370)
  371.         --Lich:CastSpell(59084) -- temporary solution to no destructable object support on ArcEmu
  372.         Lich:SpawnCreature(2626262, 476.2, -2083.56, 1573.1, 0, 814, 20000)
  373.         Lich:SpawnCreature(2626262, 505.1, -2074.47, 1573.1, 0, 814, 20000)
  374.         Lich:SpawnCreature(2626262, 523.35, -2077.77, 1573.1, 0, 814, 20000)
  375.         Lich:SpawnCreature(2626262, 541, -2086.36, 1573.1, 0, 814, 20000)
  376.         Lich:SpawnCreature(2626262, 552.7, -2111.2, 1573.1, 0, 814, 20000)
  377.         Lich:SpawnCreature(2626262, 554, -2137, 1573.1, 0, 814, 20000)
  378.         Lich:SpawnCreature(2626262, 545.9, -2153.1, 1573.1, 0, 814, 20000)
  379.         Lich:SpawnCreature(2626262, 528, -2164, 1573.1, 0, 814, 20000)
  380.         Lich:SpawnCreature(2626262, 508.25, -2169.5, 1573.1, 0, 814, 20000)
  381.         Lich:SpawnCreature(2626262, 488.2, -2168, 1573.1, 0, 814, 20000)
  382.         Lich:RegisterEvent("DelayForDespawnSinceVisualTakesSomeTimeTehe_Zieghoszho", 1000, 1)
  383.         Lich:RegisterEvent("zzzDelayForDespawnSinceVisualTakesSomeTimeTehe", 2500, 1)
  384. end
  385.  
  386. function zzzDelayForDespawnSinceVisualTakesSomeTimeTehe(pUnit, Event)
  387.         -- No object to despawn this time - Outer shell part already there
  388.         Lich:SetCombatCapable(0)
  389.         Lich:Unroot()
  390.         -- Phase 3
  391.         Lich:RemoveEvents()
  392.         Lich:RegisterEvent("Soul_Reaper_On_Main_Tank", 30000, 0)
  393.         Lich:RegisterEvent("Harvest_Soul_Random_Raid_Member", 66000, 0)
  394.         Lich:RegisterEvent("Vile_Spirits_Spawning_Inc", 28000, 0)
  395.         Lich:RegisterEvent("Phase_Four_The_Ending_tehe", 1500, 0)
  396. end
  397.  
  398. function Harvest_Soul_Random_Raid_Member(pUnit, Event)
  399.         local plr = Lich:GetRandomPlayer(0)
  400.         if plr ~= nil then
  401.         Lich:SendChatMessage(14,0,"Frostmourne hungers...")
  402.         Lich:PlaySoundToSet(17366)
  403.         Lich:FullCastSpellOnTarget(68980, plr)
  404.         end
  405. end
  406.  
  407. function Vile_Spirits_Spawning_Inc(pUnit, Event)
  408.         Lich:RegisterEvent("Spawning_The_Vile_spirits_NoW", 1000, 10)
  409. end
  410.  
  411. function Spawning_The_Vile_spirits_NoW(pUnit, Event)
  412.         local pla = Lich:GetRandomPlayer(0)
  413.         if pla ~= nil then
  414.         local x, y, z, o = pla:GetX(), pla:GetY(), pla:GetZ(), pla:GetO()
  415.         Lich:SpawnCreature(5078151, x, y, z, o, 22, 60000)
  416.         end
  417. end
  418.  
  419. function Phase_Four_The_Ending_tehe(pUnit, Event)
  420.         if Lich:GetHealthPct() < 11 then
  421.         Count = 0
  422.         Phase = 0
  423.         Lich:RemoveEvents()
  424.         Lich:SendChatMessage(14,0,"You gnats actually hurt me! Perhaps I've toyed with you long enough, now taste the vengeance of the grave!")
  425.         Lich:PlaySoundToSet(17359)
  426.         Lich:MoveTo(512.7, -2120.5, 1572.1, 0)
  427.         Lich:SetMovementFlags(1)
  428.         Lich:SetCombatCapable(1)
  429.         Lich:RegisterEvent("hhTest_Debug_MoveToCentreOfRoom", 100, 0)
  430.         Lich:RegisterEvent("hggzhTest_Debug_MoveToCentreOfRoom_z", 5005, 1)
  431.         end
  432. end
  433.  
  434. function hggzhTest_Debug_MoveToCentreOfRoom_z(pUnit, Event)
  435.         Lich:RemoveEvents()
  436.         Lich:FullCastSpell(70063)
  437.         Players_Wiped = 1
  438.         -- Most of the visuals needed are not in game due to ArcEmu's screwed up extractors
  439.         Lich:RegisterEvent("Debug_Send_Next_Message_LichKing", 10000, 1)
  440. end
  441.  
  442. function Debug_Send_Next_Message_LichKing(pUnit, Event)
  443.         Lich:SendChatMessage(14,0,"No question remains unanswered. No doubts linger. You are Azeroth's greatest champions! You overcame every challenge I laid before you. My mightiest servants have fallen before your relentless onslaught, your unbridled fury...")
  444.         Lich:PlaySoundToSet(17353)
  445.         Lich:RegisterEvent("zzDebug_Send_Next_Message_LichKing", 25000, 1)
  446. end
  447.  
  448. function zzDebug_Send_Next_Message_LichKing(pUnit, Event)
  449.         Lich:SendChatMessage(14,0,"You trained them well, Fordring. You delivered the greatest fighting force this world has ever known... right into my hands -- exactly as I intended. You shall be rewarded for your unwitting sacrifice.")
  450.         Lich:PlaySoundToSet(17355)
  451.                 local plr = Lich:GetRandomPlayer(0)
  452.                 if plr ~= nil then
  453.         Lich:ChannelSpell(71769, plr)
  454. end
  455. Lich:RegisterEvent("zzzzDebug_Send_Next_Message_LichKing", 24000, 1)
  456. end
  457.  
  458. function zzzzDebug_Send_Next_Message_LichKing(pUnit, Event)
  459.         Lich:SendChatMessage(14,0,"Watch now as I raise them from the dead to become masters of the Scourge. They will shroud this world in chaos and destruction. Azeroth's fall will come at their hands -- and you will be the first to die.")
  460.         Lich:PlaySoundToSet(17356)
  461.         Lich:RegisterEvent("zzzzDebug_Send_Next_Message_LichKingzz", 26000, 1)
  462. end
  463.  
  464. function zzzzDebug_Send_Next_Message_LichKingzz(pUnit, Event)
  465.         Lich:PlaySoundToSet(17357)
  466.         Lich:SendChatMessage(14,0,"I delight in the irony.")
  467.         Lich:RegisterEvent("zzzzDebug_Send_Next_Message_LichKingzzzz", 6000, 1)
  468.         --Lich:StopChannel()
  469. end
  470.  
  471. function zzzzDebug_Send_Next_Message_LichKingzzzz(pUnit, Event)
  472.                 if Tirion == nil then
  473.         Lich:Despawn(1,0)
  474.         else
  475.         Tirion:SendChatMessage(14,0,"LIGHT, GRANT ME ONE FINAL BLESSING. GIVE ME THE STRENGTH... TO SHATTER THESE BONDS!")
  476.         Tirion:PlaySoundToSet(17392)
  477.         Lich:RegisterEvent("Breakoutofice", 9000, 1)
  478. end
  479. end
  480.  
  481. function Breakoutofice(pUnit, Event)
  482. Tirion:RemoveAura(71614) (Remove IceBlock, to cast the Spell under this Line :>)
  483. Tirion:CastSpell(71797) (Look under this Quote, i'll post a Screnshoot)
  484. Tirion:CastSpell(71614) (Get the IceBlock Again :>, You cannot see that he was out :>)
  485. Lich:RegisterEvent("zzzzDebug_Send_Next_Message_LichKingzzzzgg", 5000, 1)
  486. end
  487.  
  488. function zzzzDebug_Send_Next_Message_LichKingzzzzgg(pUnit, Event)
  489. Tirion:RemoveAura(71614) -- Ice Block
  490. Tirion:CastSpell(71773) (Look under this Quote, i'll post a Screnshoot)
  491. Lich:RegisterEvent("zzzzDebug_Send_Next_Message_LichKingzzzzgzg", 1500, 1)
  492. -- jumps and destroys frostmourne
  493. end
  494.  
  495. function zzzzDebug_Send_Next_Message_LichKingzzzzgzg(pUnit, Event)
  496.         local x, y, z, o = Lich:GetX(), Lich:GetY(), Lich:GetZ(), Lich:GetO()
  497.         Tirion:SetMovementFlags(1)
  498.         Tirion:MoveTo(x, y, z, o)
  499.         Lich:StopChannel()
  500.         Lich:RegisterEvent("zagazzzDebug_Send_Next_Message_LichKingzzzzgzg", 3000, 1)
  501. end
  502.  
  503. function zagazzzDebug_Send_Next_Message_LichKingzzzzgzg(pUnit, Event)
  504.         Lich:CastSpell(37592) -- Knockdown
  505.         Lich:CastSpell(72726) -- Boom visual
  506.         Lich:EquipWeapons(0,0,0)
  507.         Tirion:SetMovementFlags(1)
  508.         Lich:Emote(473, 120000)
  509.         Lich:CastSpell(73107)
  510.         Lich:CastSpell(72405)
  511.         Tirion:MoveTo(536.5, -2121, 1572.1, 3.15)
  512.         Lich:RegisterEvent("zagazzzDebug_Send_Next_Message_LichKingzgeazzzzgzg", 1000, 1)
  513. end
  514.  
  515. function zagazzzDebug_Send_Next_Message_LichKingzgeazzzzgzg(pUnit, Event)
  516.         Lich:SendChatMessage(14,0,"Impossible...")
  517.         Lich:PlaySoundToSet(17358)
  518.         Lich:RegisterEvent("zagazzzDebug_Send_Next_Message_LichKingzgeazzzzedhezgzg", 1500, 1)
  519. end
  520.  
  521. function zagazzzDebug_Send_Next_Message_LichKingzgeazzzzedhezgzg(pUnit, Event)
  522.         Tirion:SendChatMessage(14,0,"No more, Arthas! No more lives will be consumed by your hatred!")
  523.         Tirion:PlaySoundToSet(17393)
  524.         Tirion:SetMovementFlags(1)
  525.         Lich:Emote(473, 120000)
  526.         Lich:SpawnCreature(31021151, 518.8, -2115.8, 1572.1, 3.780169, 35, 0)
  527.         Tirion:MoveTo(526, -2120.5, 1572.1, 3)
  528.         Lich:RegisterEvent("zagazzzDebug_Send_Next_Message_LichKingzgeazzzzedhezgzzzzsay", 5500, 1)
  529. end
  530.  
  531. function zagazzzDebug_Send_Next_Message_LichKingzgeazzzzedhezgzzzzsay(pUnit, Event)
  532.         if Terenas == nil then -- Dunno why this would happen
  533.         Lich:Despawn(1,0)
  534.         Lich = nil
  535.         Tirion:Despawn(1,0)
  536.         Tirion = nil
  537.         else
  538.         Lich:Emote(473, 120000)
  539.         Terenas:SendChatMessage(14,0,"Free at last! It is over, my son. This is the moment of reckoning.")
  540.         Terenas:PlaySoundToSet(17397)
  541.         Terenas:ChannelSpell(51361, Terenas)
  542.         Lich:RegisterEvent("epiashgyophopapea_Lich_King_Is_Not_A_Happy_Bunny", 10000, 1)
  543.         end
  544. end
  545.  
  546. function epiashgyophopapea_Lich_King_Is_Not_A_Happy_Bunny(pUnit, Event)
  547.         Terenas:SendChatMessage(14,0,"Rise up, champions of the Light!")
  548.         Terenas:PlaySoundToSet(17398)
  549.         Terenas:StopChannel()
  550.         Terenas:CastSpell(37755)
  551.         Lich:Emote(473, 120000)
  552.         local PlayersAllAround = Terenas:GetInRangePlayers()
  553.         for a, players in pairs(PlayersAllAround) do
  554.         players:ResurrectPlayer(players)
  555.         players:CastSpell(24171)
  556.         end
  557.         Lich:RegisterEvent("zLich_King_Is_Not_A_Happy_Bunny", 5000, 1)
  558. end
  559.  
  560. function zLich_King_Is_Not_A_Happy_Bunny(pUnit, Event)
  561.         Terenas:Despawn(1,0)
  562.         Lich:Emote(473, 120000)
  563.         Lich:SendChatMessage(14,0,"Now I stand, the lion before the lambs... and they do not fear.")
  564.         Lich:PlaySoundToSet(17361)
  565.         Lich:RegisterEvent("zLich_King_Is_Not_A_Happy_Bunnyz", 8000, 1)
  566. end
  567.  
  568. function zLich_King_Is_Not_A_Happy_Bunnyz(pUnit, Event)
  569.         Lich:SendChatMessage(14,0,"They cannot fear.")
  570.         Lich:PlaySoundToSet(17362)
  571.         Lich:Emote(473, 120000)
  572.         Lich:SetHealthPct(10)
  573.         -- The end, poor arthas, Q_Q, lets all go do a rain dance, ~Stoneharry
  574. end
  575.  
  576. ---- Terenas -----------------------------------------------------
  577.  
  578. function Terenas_Spawned_root_Hes_the_realm_of_My_RETAIL_Char(pUnit, Event)
  579.         if Tirion == nil or Lich == nil then
  580.         pUnit:Despawn(1,0)
  581.         else
  582.         Terenas = pUnit
  583.         end
  584. end
  585.  
  586. RegisterUnitEvent(31021151, 18, "Terenas_Spawned_root_Hes_the_realm_of_My_RETAIL_Char")
  587.  
  588. -------------------------------------------------------------------
  589.  
  590. function LichKingHasDiedSoWePlayMovie(pUnit, Event)
  591.         Lich = nil
  592.         pUnit:RemoveEvents()
  593.         pUnit:PlaySoundToSet(17374) -- Freak makes dying sound
  594.         pUnit:SpawnCreature(3072110, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), pUnit:GetO(), 35, 10000)
  595. end
  596.  
  597. RegisterUnitEvent(3072111, 4, "LichKingHasDiedSoWePlayMovie")
  598.  
  599. function TriggerHasSpawnedSoPlayMovie(pUnit, Event)
  600.         pUnit:RegisterEvent("PlayMovieOnceDeathAnimationHasPlayed", 9000, 1)
  601. end
  602.  
  603. function PlayMovieOnceDeathAnimationHasPlayed(pUnit, Event)
  604.         -- Reset Fight
  605.         Tirion = nil
  606.         Lich = nil
  607.         Terenas = nil
  608.         package = nil
  609.         Phase = 0
  610.         Count = 0
  611.         -- Movie
  612.         Players_Wiped = 0
  613.         local PlayersAllAround = pUnit:GetInRangePlayers()
  614.         for a, players in pairs(PlayersAllAround) do
  615.         --SMSG_TRIGGER_MOVIE = 0x464
  616.         local packet = LuaPacket:CreatePacket(0x464, 4) -- Move type 4
  617.         packet:WriteULong(16) -- Id 16
  618.         players:SendPacketToPlayer(packet) -- Send to players
  619.         end
  620.         -- Bolvar
  621.         local Bolvar = pUnit:GetGameObjectNearestCoords(428.758, -2124.4, 1594.69, 2508221) -- Bolvar in chains
  622.         if Bolvar ~= nil then
  623.         Bolvar:Despawn(1,0)
  624.         pUnit:SpawnGameObject(2508220, 428.758, -2124.4, 1594.69, 0, 360000) -- Chains
  625.         pUnit:SpawnGameObject(2508219, 430.103, -2124, 1595.93, 3.3, 360000) -- Bolvar
  626.         end
  627. end
  628.  
  629. RegisterUnitEvent(3072110, 18, "TriggerHasSpawnedSoPlayMovie")
  630.        
  631. ------- Adds ------------------------------------------------------
  632.  
  633. function Dredge_Ghouls_OnSpawn(pUnit, Event)
  634.         pUnit:RegisterEvent("TestRootFunctionNextSecond", 1, 1)
  635. end
  636.  
  637. function TestRootFunctionNextSecond(pUnit, Event)
  638.         if Lich == nil then -- This way when the ghoul spawns, if the fight is not happening for some reason it will just disapear again instantly as if nothing happened ;)
  639.         pUnit:RemoveFromWorld()
  640.         else -- Well if he is here
  641.         pUnit:Emote(449, 4000) -- spawn animation
  642.         pUnit:Root() -- Root him while he spawns
  643.         pUnit:RegisterEvent("Delay_A_Second_And_See_WhatHappens_Tehe", math.random(1,1000), 1)
  644.         pUnit:RegisterEvent("SetFactionToHostileForTheEmote", 4500, 1)
  645.         end
  646. end
  647.  
  648. function Delay_A_Second_And_See_WhatHappens_Tehe(pUnit, Event)
  649.         pUnit:CastSpell(55719)
  650. end
  651.  
  652. function SetFactionToHostileForTheEmote(pUnit, Event)
  653.         pUnit:Unroot() -- let him run free
  654.         pUnit:SetFaction(21) -- hostile
  655. end
  656.  
  657. RegisterUnitEvent(3769511, 18, "Dredge_Ghouls_OnSpawn")
  658.  
  659. ---------------------------------------------------------------------
  660.  
  661. function Shambling_Horrors_OnSpawn(pUnit, Event)
  662.         pUnit:RegisterEvent("zzTestRootFunctionNextSecond", 1, 1)
  663. end
  664.  
  665. function zzTestRootFunctionNextSecond(pUnit, Event)
  666.         if Lich == nil then -- This way when the ghoul spawns, if the fight is not happening for some reason it will just disapear again instantly as if nothing happened ;)
  667.         pUnit:RemoveFromWorld()
  668.         else -- Well if he is here
  669.         pUnit:Emote(449, 4000) -- spawn animation
  670.         pUnit:Root() -- Root him while he spawns
  671.         pUnit:CastSpell(55719)
  672.         pUnit:RegisterEvent("zzSetFactionToHostileForTheEmote", 4500, 1)
  673.         end
  674. end
  675.  
  676. function zzSetFactionToHostileForTheEmote(pUnit, Event)
  677.         pUnit:Unroot() -- let him run free
  678.         pUnit:SetFaction(21) -- hostile
  679. end
  680.  
  681. RegisterUnitEvent(3769811, 18, "Shambling_Horrors_OnSpawn")
  682.  
  683. function Shambling_Horrors_OnCombat(pUnit, Event)
  684.         if Lich == nil then -- This way when the ghoul spawns, if the fight is not happening for some reason it will just disapear again instantly as if nothing happened ;)
  685.         pUnit:RemoveFromWorld()
  686.         else -- Well if he is here
  687.         pUnit:RegisterEvent("Enrage_Spam_Incoming_Varied_Time", math.random(20000,25000), 0) -- Varied time depending on add
  688.         pUnit:RegisterEvent("Shockwave_thingy_time_notsure_on_timer", 15000, 0)
  689.         end
  690. end
  691.  
  692. function Enrage_Spam_Incoming_Varied_Time(pUnit, Event)
  693.         pUnit:FullCastSpell(72143)
  694. end
  695.  
  696. function Shockwave_thingy_time_notsure_on_timer(pUnit, Event)
  697.         pUnit:FullCastSpell(72149)
  698. end
  699.  
  700. function Shambling_Horrors_OnLeave(pUnit, Event)
  701.         pUnit:RemoveEvents()
  702. end
  703.  
  704. function Shambling_Horrors_OnDead(pUnit, Event)
  705.         pUnit:RemoveEvents()
  706. end
  707.  
  708. RegisterUnitEvent(3769811, 1, "Shambling_Horrors_OnCombat")
  709. RegisterUnitEvent(3769811, 2, "Shambling_Horrors_OnLeave")
  710. RegisterUnitEvent(3769811, 4, "Shambling_Horrors_OnDead")
  711.  
  712. ----- Ice Sphere --------------------------------------------------
  713.  
  714. -- 69090 on spawn -- only 2 on phase 1.5, head towards player and explode if hit
  715.  
  716. function IceShard_OnSpawn(pUnit, Event)
  717.         pUnit:RegisterEvent("rage_rage_rage_rage_Rage_rage", 1, 1)
  718. end
  719.  
  720. function rage_rage_rage_rage_Rage_rage(pUnit, Event)
  721.         if Lich == nil then
  722.         pUnit:RemoveFromWorld() -- may cause crash if he tries to despawn but variable broke
  723.         else
  724.                 pUnit:FullCastSpell(69090) -- Visual
  725.                 local pla = pUnit:GetRandomPlayer(0)
  726.                 if pla ~= nil then
  727.                 pUnit:MoveTo(pla:GetX(), pla:GetY(), pla:GetZ(), pla:GetO())
  728.                 pUnit:SetMovementFlags(1)
  729.                 pUnit:RegisterEvent("rage_rage_rage_rage_Rage_rage_r", 1000, 8)
  730.                 else
  731.                 pUnit:RemoveFromWorld()
  732.                 end
  733.         end
  734. end
  735.  
  736. function rage_rage_rage_rage_Rage_rage_r(pUnit, Event)
  737.         local plm = pUnit:GetClosestPlayer()
  738.         if plm ~= nil then
  739.                 pUnit:FullCastSpell(69090) -- Visual
  740.                 if pUnit:GetDistanceYards(plm) < 4 then
  741.                 --pUnit:FullCastSpellOnTarget(70827, plm) -- May be buggy if player dies, maybe not knockbacked and players try to exploit by ressing?
  742.                 pUnit:FullCastSpellOnTarget(11027, plm) -- Knockback
  743.                 pUnit:CastSpell(56135)
  744.                 pUnit:RemoveEvents()
  745.                 end
  746.         end
  747. end
  748.  
  749. RegisterUnitEvent(3769812, 18, "IceShard_OnSpawn")
  750.  
  751. ---- Raging Spirit ------------------------------------------------
  752.  
  753. function RagingSpirit_OnCombat(pUnit, Event)
  754.         if Lich == nil then
  755.         pUnit:RemoveFromWorld()
  756.         else
  757.         pUnit:RegisterEvent("Soul_Shriek_Random_Time_Depending_On_Mob", math.random(7500, 15000), 0)
  758.         pUnit:RegisterEvent("Soul_Shriek_Random_Visual", 1000, 1)
  759.         end
  760. end
  761.  
  762. function Soul_Shriek_Random_Visual(pUnit, Event)
  763.         pUnit:FullCastSpell(69198) -- Visual
  764. end
  765.  
  766. function Soul_Shriek_Random_Time_Depending_On_Mob(pUnit, Event)
  767.         pUnit:FullCastSpell(69242) -- Shriek
  768. end
  769.  
  770. function RagingSpirit_OnLeave(pUnit, Event)
  771.         pUnit:RemoveEvents()
  772. end
  773.  
  774. function RagingSpirit_OnDead(pUnit, Event)
  775.         pUnit:RemoveEvents()
  776. end
  777.  
  778. RegisterUnitEvent(3769813, 1, "RagingSpirit_OnCombat")
  779. RegisterUnitEvent(3769813, 2, "RagingSpirit_OnLeave")
  780. RegisterUnitEvent(3769813, 4, "RagingSpirit_OnDead")
  781.  
  782. ---- Flying Dudes ------------------------------------------------------
  783.  
  784. function zhgzFlying_Dude_OnCombat(pUnit, Event)
  785.         if Lich == nil then
  786.         pUnit:RemoveFromWorld()
  787.         else
  788.         pUnit:RegisterEvent("zhgzFlying_Dude_Find_Player", 1, 1)
  789.         end
  790. end
  791.  
  792. function zhgzFlying_Dude_Find_Player(pUnit, Event)
  793.         package = pUnit:GetClosestPlayer()
  794.         if package ~= nil then
  795.         pUnit:SetCombatCapable(1) -- Stop npc running around
  796.         package:SetPlayerLock(1) -- Stop player doing stuff :3
  797.         pUnit:SetMovementFlags(2) -- Flying Mode On
  798.         pUnit:ChannelSpell(55520, package) -- visual
  799.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+6, pUnit:GetO(), 12288)
  800.         package:MovePlayerTo(package:GetX(), package:GetY(), package:GetZ()+6, package:GetO(), 12288)
  801.         pUnit:RegisterEvent("now_we_have_loaded_preset_We_can_move_on", 2000, 1)
  802.         else
  803.         pUnit:RemoveFromWorld()
  804.         end
  805. end
  806.  
  807. function now_we_have_loaded_preset_We_can_move_on(pUnit, Event)
  808.         if package ~= nil then
  809.         package:CastSpell(52241) -- Choke visual
  810.         package:CastSpell(53658) -- Bubble to stop stupid animations
  811.         pUnit:ChannelSpell(29172, package) -- visual
  812.         pUnit:RegisterEvent("now_we_have_loaded_preset_We_can_move_on_two", 1500, 0)
  813.         else
  814.         pUnit:RemoveEvents()
  815.         pUnit:RemoveFromWorld()
  816.         end
  817. end
  818.  
  819. function now_we_have_loaded_preset_We_can_move_on_two(pUnit, Event)
  820.         if package ~= nil then
  821.                 if pUnit:GetX() == 572 and pUnit:GetY() == -2121.5 then -- Don't use Z, blizzard don't, POI's don't, why should we? It will just screw up and we don't need it :)
  822.                 pUnit:RemoveEvents()
  823.                 pUnit:StopChannel()
  824.                 package:RemoveAura(52241) -- choke
  825.                 package:RemoveAura(53658) -- buble
  826.                 package:SetPlayerLock(0)
  827.                 package = nil
  828.                 --pUnit:RemoveFromWorld() -- Causes crash :(
  829.                 else   
  830.                 pUnit:SetMovementFlags(2)
  831.                 package:ModifyFlySpeed(2.5)
  832.                 pUnit:MoveTo(572, -2121.5, 1577.2, 0, 12288, 2.5)
  833.                 package:MovePlayerTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ() ,pUnit:GetO(), 12288)
  834.                 end
  835.         else
  836.         pUnit:RemoveEvents()
  837.         pUnit:RemoveFromWorld()
  838.         end
  839. end
  840.  
  841. function zhgzFlying_Dude_OnDead(pUnit, Event)
  842.         pUnit:RemoveEvents()
  843.         pUnit:StopChannel()
  844.         package:RemoveAura(52241) -- choke
  845.         package:RemoveAura(53658) -- buble
  846.         package:SetPlayerLock(0)
  847.         package = nil
  848.         --pUnit:RemoveFromWorld() -- Causes crash :(
  849. end
  850.  
  851. RegisterUnitEvent(25452151, 1, "zhgzFlying_Dude_OnCombat")
  852. RegisterUnitEvent(25452151, 4, "zhgzFlying_Dude_OnDead")
  853.  
  854. ---- Vile Spirits ------------------------------------------------------
  855.  
  856. function VileSpiirt_OnCombat(pUnit, Event)
  857.         if Lich == nil then
  858.         pUnit:RemoveFromWorld()
  859.         else
  860.         pUnit:RegisterEvent("deoaopighophgeoaugozh_delay", 500, 1)
  861.         end
  862. end
  863.  
  864. function deoaopighophgeoaugozh_delay(pUnit, Event)
  865.         pUnit:Root()
  866.         pUnit:SetCombatCapable(1)
  867.         pUnit:RegisterEvent("Tick_Tick_Tick_dot_dot_dot_BOOM", 29000, 1)
  868. end
  869.  
  870. function Tick_Tick_Tick_dot_dot_dot_BOOM(pUnit, Event)
  871.         pUnit:RemoveEvents()
  872.         pUnit:CastSpell(37106)
  873.         pUnit:RegisterEvent("Kill_Self_Suicide_Or_Whathaveyou_vile", 1000, 1)
  874. end
  875.  
  876. function Kill_Self_Suicide_Or_Whathaveyou_vile(pUnit, Event)
  877.         pUnit:Despawn(1,0)
  878. end
  879.  
  880. function VileSpiirt_OnLeave(pUnit, Event)
  881.         pUnit:RemoveEvents()
  882. end
  883.  
  884. function VileSpiirt_OnDead(pUnit, Event)
  885.         pUnit:RemoveEvents()
  886. end
  887.  
  888. RegisterUnitEvent(5078151, 1, "VileSpiirt_OnCombat")
  889. RegisterUnitEvent(5078151, 2, "VileSpiirt_OnLeave")
  890. RegisterUnitEvent(5078151, 4, "VileSpiirt_OnDead")
  891.  
  892. ------------------------------------------------------------------------