stoneharry

Untitled

Apr 29th, 2011
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.37 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 -- TO DO - fix variable collision with these
  22. local Tirion = nil
  23. local Ready = false
  24. local i = 0]]
  25.  
  26. ICC = {}
  27. ICC.VAR = {}
  28.  
  29. ------------------------------------------------------------------
  30. -- The gossip used to start the encounter - Tirion ---------------
  31. -- Also set up events etc ----------------------------------------
  32. ------------------------------------------------------------------
  33.  
  34. function OnGossipTalk(pUnit, Event, player)
  35.     local menu = GossipMenu(pUnit, 2975252, 1)
  36.     menu:AddItem(9, "We are prepared, Highlord. Let us battle for the fate of Azeroth! For the light of dawn!", 1, false)
  37.     menu:AddItem(0, "We are not yet prepared, Highlord.", 2, false)
  38.     menu:Send(player)
  39. end
  40.  
  41. function OnGossipSelect(pUnit, Event, player, id, code)
  42.     if (id == 1) then
  43.         local id = MapMgr:GetInstanceID()
  44.         ICC[id].VAR.Tirion = pUnit
  45.         ICC[id].VAR.Ready = true
  46.         ICC[id].VAR.Tirion:SetUInt32Value(UNIT_NPC_FLAGS, 2) -- Quest flags disable gossip
  47.         ICC[id].VAR.Tirion:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable, used to prevent LK hitting him instead of players
  48.         -- Gossip complete
  49.     elseif (id == 2) then
  50.         -- Gossip complete
  51.     end
  52. end
  53.  
  54. RegisterUnitGossipEvent(TirionNPCID, 1, OnGossipTalk)
  55. RegisterUnitGossipEvent(TirionNPCID, 2, OnGossipSelect)
  56.  
  57. function OnSpawnHandleStart(pUnit, Event)
  58.     pUnit:SetUInt32Value(UNIT_NPC_FLAGS, 1) -- Gossip Flags, for when the fight resets
  59.     pUnit:RegisterEvent(CheckForStart, 2500, 1) -- Setting repeat to 0 only calls once for some reason
  60. end
  61.  
  62. RegisterUnitEvent(TirionNPCID, 18, OnSpawnHandleStart)
  63.  
  64. function OnSpawnHandleDefineAndBytes(pUnit, Event)
  65.     pUnit:RegisterEvent(SetBytesAndHandleVariable, 2000, 1)
  66. end
  67.  
  68. function SetBytesAndHandleVariable(pUnit)
  69.     local id = MapMgr:GetInstanceID()
  70.     ICC[id].VAR.Lich = pUnit
  71.     ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 1) -- Sit on the throne
  72.     ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable
  73. end
  74.  
  75. RegisterUnitEvent(LichKingNPCID, 18, OnSpawnHandleDefineAndBytes)
  76.  
  77. ------------------------------------------------------------------
  78. -- Mini-cinematic at the start -----------------------------------
  79. ------------------------------------------------------------------
  80.  
  81. function CheckForStart(pUnit)
  82.     local id = MapMgr:GetInstanceID()
  83.     if (ICC[id].VAR.Ready and ICC[id].VAR.Lich ~= nil) then
  84.         ICC[id].VAR.Ready = false
  85.         ICC[id].VAR.i = 0
  86.         ICC[id].VAR.Tirion:GetAIInterface():MoveTo(489.14, -2124.45, 1040.9, 0) -- Closer to LK
  87.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 7500, 1)
  88.     else
  89.         pUnit:RegisterEvent(CheckForStart, 2500, 1)
  90.     end
  91. end
  92.  
  93. function WalkTowardsLichKingThenEmotes(pUnit)
  94.     local id = MapMgr:GetInstanceID()
  95.     if (ICC[id].VAR.i == 0) then
  96.         ICC[id].VAR.Tirion:EventAddEmote(175, 4000)
  97.         ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- Stand up
  98.         PlaySoundToSet(Tirion, 17349) -- Voice of message - Tirion since players are closer to him
  99.         ICC[id].VAR.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)
  100.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 4000, 1)
  101.     elseif (ICC[id].VAR.i == 1) then
  102.         ICC[id].VAR.Lich:GetAIInterface():StopMovement(0) -- Resets bytes bug
  103.         ICC[id].VAR.Lich:GetAIInterface():MoveTo(462.01, -2124.146, 1040.9, 0) -- Down from throne to floor
  104.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 9500, 1)
  105.     elseif (ICC[id].VAR.i == 2) then
  106.         ICC[id].VAR.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)
  107.         PlaySoundToSet(Tirion, 17390)
  108.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 9000, 1)
  109.     elseif (ICC[id].VAR.i == 3) then
  110.         ICC[id].VAR.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)
  111.         PlaySoundToSet(Tirion, 17350)
  112.         ICC[id].VAR.Lich:EventAddEmote(397, 4000)
  113.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 4500, 1)
  114.     elseif (ICC[id].VAR.i == 4) then
  115.         ICC[id].VAR.Lich:EventAddEmote(1, 6000)
  116.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 12000, 1)
  117.     elseif (ICC[id].VAR.i == 5) then
  118.         ICC[id].VAR.Lich:EventAddEmote(392, 3500)
  119.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 7500, 1)
  120.     elseif (ICC[id].VAR.i == 6) then
  121.         ICC[id].VAR.Tirion:SendChatMessage(14,0,"So be it. Champions, attack!", 0)
  122.         PlaySoundToSet(Tirion, 17391)
  123.         ICC[id].VAR.Tirion:EventAddEmote(397, 2000)
  124.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 2000, 1)
  125.     elseif (ICC[id].VAR.i == 7) then
  126.         ICC[id].VAR.Tirion:GetAIInterface():setMoveRunFlag(true)
  127.         ICC[id].VAR.Tirion:GetAIInterface():MoveTo(472.88, -2124.2, 1040.9, 0) -- Run towards LK
  128.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 1000, 1)
  129.     elseif (ICC[id].VAR.i == 8) then
  130.         ICC[id].VAR.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)
  131.         PlaySoundToSet(Tirion, 17351)
  132.         ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 500, 1)
  133.     elseif (ICC[id].VAR.i == 9) then
  134.         ICC[id].VAR.Lich:CastSpell(Tirion, 71614, false) -- Freeze
  135.         ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
  136.     end
  137.     ICC[id].VAR.i = ICC[id].VAR.i + 1
  138. end
  139.  
  140. ------------------------------------------------------------------
  141. -- Handle the ICC debuff -----------------------------------------
  142. ------------------------------------------------------------------
  143.  
  144. function OnZoneChange(event, player, zone, oldzone)
  145.     local race = player:getRace()
  146.     if (zone == 4812) then
  147.         player:CastSpell(player, 69127, true) -- Chill of the Throne
  148.         player:CastSpell(player, 69127, true) -- Hack'y way of applying the correct aura types.
  149.         if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
  150.             player:CastSpell(player, 73828, true) -- Strength of Wyrn
  151.         else
  152.             player:CastSpell(player, 73822, true) -- Hellscreem's warsong
  153.         end
  154.     elseif (oldzone == 4812) then
  155.         player:RemoveAura(69127) -- Chill of the Throne
  156.         if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
  157.             player:RemoveAura(73828) -- Strength of Wyrn
  158.         else
  159.             player:RemoveAura(73822) -- Hellscreem's warsong
  160.         end
  161.     end
  162. end
  163.  
  164. RegisterServerHook(15, OnZoneChange)
  165.  
  166. -- Playing sounds to set
  167.  
  168. function PlaySoundToSet(object, ID)
  169.     local pack = LuaPacket(722, 4)
  170.     pack:WriteUint32(ID)
  171.     object:SendMessageToSet(pack, true)
  172. end
  173.  
  174. ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment