stoneharry

Untitled

Apr 29th, 2011
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.40 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 -- Bugs it, he can't move
  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 == true 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, 7000, 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, 30000)
  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.     end
  104.     i = i + 1
  105. end
  106.  
  107. ------------------------------------------------------------------
  108. -- Handle the ICC debuff -----------------------------------------
  109. ------------------------------------------------------------------
  110.  
  111. function OnZoneChange_ICC(event, player, zone, oldzone)
  112.     if (zone == 4812) then
  113.         player:CastSpell(player, 69127, true) -- Chill of the Throne
  114.         player:CastSpell(player, 69127, true) -- Hack'y way of applying the correct aura types.
  115.         if (player:GetTeam() == 0) then
  116.             player:CastSpell(player, 73828, true) -- Strength of Wyrn
  117.         else
  118.             player:CastSpell(player, 73822, true) -- Hellscreem's warsong
  119.         end
  120.     elseif (oldzone == 4812) then
  121.         player:RemoveAura(69127) -- Chill of the Throne
  122.         if (player:GetTeam() == 0) then
  123.             player:RemoveAura(73828) -- Strength of Wyrn
  124.         else
  125.             player:RemoveAura(73822) -- Hellscreem's warsong
  126.         end
  127.     end
  128. end
  129.  
  130. RegisterServerHook(15, OnZoneChange_ICC)
  131.  
  132. -- Playing sounds to set
  133.  
  134. function PlaySoundToSet(object, ID)
  135.     local pack = LuaPacket(722, 4)
  136.     pack:WriteUint32(ID)
  137.     object:SendMessageToSet(pack, true)
  138. end
  139.  
  140. ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment