stoneharry

Untitled

Apr 29th, 2011
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.70 KB | None | 0 0
  1. ------------------------------------------------------------------
  2. --[[
  3.     This script was made by Stoneharry of www.MMOwned.com
  4.     This script may be edited and changed at will, but full credits must be provided.
  5.     Please respect the original author, thank you.
  6. ]]
  7. -- Variable declaration and generally setting up the script
  8. --?!MAP= 631
  9.  
  10. local TirionNPCID = 38995
  11. local LichKingNPCID = 36597
  12.  
  13. -- For 3.3.5a
  14. local OBJECT_END = 0x0006
  15. local UNIT_NPC_FLAGS = OBJECT_END + 0x004C
  16. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035
  17. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
  18. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000
  19.  
  20. -- Unconfigurable Variables
  21. --[[local Lich = nil -- Global variables are automatically local to the script now
  22. local Tirion = nil]]
  23. local Ready = false
  24. local i = 0
  25.  
  26. ------------------------------------------------------------------
  27. -- The gossip used to start the encounter - Tirion ---------------
  28. -- Also set up events etc ----------------------------------------
  29. ------------------------------------------------------------------
  30.  
  31. function Tirion_OnGossipTalk(pUnit, Event, player)
  32.     local menu = GossipMenu(pUnit, 2975252, 1)
  33.     menu:AddItem(9, "We are prepared, Highlord. Let us battle for the fate of Azeroth! For the light of dawn!", 1, false)
  34.     menu:AddItem(0, "We are not yet prepared, Highlord.", 2, false)
  35.     menu:Send(player)
  36. end
  37.  
  38. function Tirion_OnGossipSelect(pUnit, Event, player, id, code)
  39.     if (id == 1) then
  40.         Tirion = pUnit
  41.         Ready = true
  42.         Tirion:SetUInt32Value(UNIT_NPC_FLAGS, 2) -- Quest flags disable gossip
  43.         -- Gossip complete
  44.     elseif (id == 2) then
  45.         pUnit:SetUInt32Value(UNIT_NPC_FLAGS, 1) -- Quest flags disable gossip
  46.         -- Gossip complete
  47.     end
  48. end
  49.  
  50. RegisterUnitGossipEvent(TirionNPCID, 1, Tirion_OnGossipTalk)
  51. RegisterUnitGossipEvent(TirionNPCID, 2, Tirion_OnGossipSelect)
  52.  
  53. function Tirion_OnSpawnHandleStart(pUnit, Event)
  54.     TO_CREATURE(pUnit):RegisterEvent(CheckForStart_Tirion, 2500, 1) -- Setting repeat to 0 only calls once for some reason
  55. end
  56.  
  57. RegisterUnitEvent(TirionNPCID, 18, Tirion_OnSpawnHandleStart)
  58.  
  59. function LichKing_OnSpawnHandleDefineAndBytes(pUnit, Event)
  60.     TO_CREATURE(pUnit):RegisterEvent(SetBytesAndHandleVariable_LichKing, 2000, 1)
  61. end
  62.  
  63. function SetBytesAndHandleVariable_LichKing(pUnit)
  64.     Lich = pUnit
  65.     Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 1) -- Sit on the throne
  66.     Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable
  67. end
  68.  
  69. RegisterUnitEvent(LichKingNPCID, 18, LichKing_OnSpawnHandleDefineAndBytes)
  70.  
  71. ------------------------------------------------------------------
  72. -- Mini-cinematic at the start -----------------------------------
  73. ------------------------------------------------------------------
  74.  
  75. function CheckForStart_Tirion(pUnit)
  76.     if (Ready and Lich ~= nil) then
  77.         Ready = false
  78.         Tirion:GetAIInterface():MoveTo(489.14, -2124.45, 1040.9, 0) -- Closer to LK
  79.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 7500, 1)
  80.     else
  81.         TO_CREATURE(pUnit):RegisterEvent(CheckForStart_Tirion, 2500, 1)
  82.     end
  83. end
  84.  
  85. function WalkTowardsLichKingThenEmotes(pUnit)
  86.     if (i == 0) then
  87.         Tirion:EventAddEmote(175, 4000)
  88.         Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- Stand up
  89.         PlaySoundToSet(Tirion, 17349) -- Voice of message - Tirion since players are closer to him
  90.         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?", 0)
  91.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 4000, 1)
  92.     elseif (i == 1) then
  93.         Lich:GetAIInterface():MoveTo(462.01, -2124.146, 1040.9, 0) -- Down from throne to floor
  94.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 9500, 1)
  95.     elseif (i == 2) then
  96.         Tirion:SendChatMessage(14,0,"We will grant you a swift death, Arthas. More than can be said for the thousands you've tortured and slain.", 0)
  97.         PlaySoundToSet(Tirion, 17390)
  98.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 9000, 1)
  99.     elseif (i == 3) then
  100.         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.", 0)
  101.         PlaySoundToSet(Tirion, 17350)
  102.         Lich:EventAddEmote(397, 4000)
  103.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 4500, 1)
  104.     elseif (i == 4) then
  105.         Lich:EventAddEmote(1, 6000)
  106.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 12000, 1)
  107.     elseif (i == 5) then
  108.         Lich:EventAddEmote(392, 3500)
  109.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 11000, 1)
  110.     elseif (i == 6) then
  111.         Tirion:SendChatMessage(14,0,"So be it. Champions, attack!", 0)
  112.         PlaySoundToSet(Tirion, 17391)
  113.         Tirion:EventAddEmote(397, 2000)
  114.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 2000, 1)
  115.     elseif (i == 7) then
  116.         Tirion:GetAIInterface():setMoveRunFlag(true)
  117.         Tirion:GetAIInterface():MoveTo(472.88, -2124.2, 1040.9, 0) -- Run towards LK
  118.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 1000, 1)
  119.     elseif (i == 8) then
  120.         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.", 0)
  121.         PlaySoundToSet(Tirion, 17351)
  122.         TO_CREATURE(Tirion):RegisterEvent(WalkTowardsLichKingThenEmotes, 1500, 1)
  123.     elseif (i == 9) then
  124.         Lich:CastSpell(Tirion, 71614, false) -- Freeze
  125.         Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
  126.     end
  127.     i = i + 1
  128. end
  129.  
  130. ------------------------------------------------------------------
  131. -- Handle the ICC debuff -----------------------------------------
  132. ------------------------------------------------------------------
  133.  
  134. function OnZoneChange_ICC(event, player, zone, oldzone)
  135.     local race = player:getRace()
  136.     if (zone == 4812) then
  137.         player:CastSpell(player, 69127, true) -- Chill of the Throne
  138.         player:CastSpell(player, 69127, true) -- Hack'y way of applying the correct aura types.
  139.         if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
  140.             player:CastSpell(player, 73828, true) -- Strength of Wyrn
  141.         else
  142.             player:CastSpell(player, 73822, true) -- Hellscreem's warsong
  143.         end
  144.     elseif (oldzone == 4812) then
  145.         player:RemoveAura(69127) -- Chill of the Throne
  146.         if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
  147.             player:RemoveAura(73828) -- Strength of Wyrn
  148.         else
  149.             player:RemoveAura(73822) -- Hellscreem's warsong
  150.         end
  151.     end
  152. end
  153.  
  154. RegisterServerHook(15, OnZoneChange_ICC)
  155.  
  156. -- Playing sounds to set
  157.  
  158. function PlaySoundToSet(object, ID)
  159.     local pack = LuaPacket(722, 4)
  160.     pack:WriteUint32(ID)
  161.     object:SendMessageToSet(pack, true)
  162. end
  163.  
  164. ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment