Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------
- --[[
- This script was made by Stoneharry of www.MMOwned.com
- This script may be edited and changed at will, but full credits must be provided.
- Please respect the original author, thank you.
- ]]
- -- Variable declaration and generally setting up the script
- --?!MAP= 631
- local TirionNPCID = 38995
- local LichKingNPCID = 36597
- -- For 3.3.5a
- local OBJECT_END = 0x0006
- local UNIT_NPC_FLAGS = OBJECT_END + 0x004C
- local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035
- local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
- local UNIT_FLAG_NOT_SELECTABLE = 0x02000000
- local SMSG_INIT_WORLD_STATES = 0x2C2
- local SMSG_UPDATE_WORLD_STATE = 0x2C3
- -- Unconfigurable Variables
- local CheckForStart
- local WalkTowardsLichKingThenEmotes
- local SetBytesAndHandleVariable
- local KeepMoving
- local KillAll
- local CheckForFinalPhase
- local DeathCinematic
- ICC = {}
- ICC.VAR = {}
- ------------------------------------------------------------------
- -- The gossip used to start the encounter - Tirion ---------------
- -- Also set up events etc ----------------------------------------
- ------------------------------------------------------------------
- local function OnGossipTalk(pUnit, Event, player)
- local menu = GossipMenu(pUnit, 2975252, 1)
- menu:AddItem(9, "We are prepared, Highlord. Let us battle for the fate of Azeroth! For the light of dawn!", 1, false)
- menu:AddItem(0, "We are not yet prepared, Highlord.", 2, false)
- menu:Send(player)
- end
- local function OnGossipSelect(pUnit, Event, player, id, code)
- if (id == 1) then
- local id = MapMgr:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- ICC[id].VAR.Tirion = pUnit
- ICC[id].VAR.Ready = true
- ICC[id].VAR.Tirion:SetUInt32Value(UNIT_NPC_FLAGS, 2) -- Quest flags disable gossip
- ICC[id].VAR.Tirion:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable, used to prevent LK hitting him instead of players
- -- Gossip complete
- elseif (id == 2) then
- -- Gossip complete
- end
- end
- RegisterUnitGossipEvent(TirionNPCID, 1, OnGossipTalk)
- RegisterUnitGossipEvent(TirionNPCID, 2, OnGossipSelect)
- local function OnSpawnHandleStart(pUnit, Event)
- pUnit:SetUInt32Value(UNIT_NPC_FLAGS, 1) -- Gossip Flags, for when the fight resets
- pUnit:RegisterEvent(CheckForStart, 2500, 1) -- Setting repeat to 0 only calls once for some reason
- end
- RegisterUnitEvent(TirionNPCID, 18, OnSpawnHandleStart)
- local function OnSpawnHandleDefineAndBytes(pUnit, Event)
- pUnit:RegisterEvent(SetBytesAndHandleVariable, 2000, 1)
- end
- function SetBytesAndHandleVariable(pUnit)
- local id = MapMgr:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- ICC[id].VAR.Lich = pUnit
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 1) -- Sit on the throne
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable
- end
- RegisterUnitEvent(LichKingNPCID, 18, OnSpawnHandleDefineAndBytes)
- ------------------------------------------------------------------
- -- Mini-cinematic at the start -----------------------------------
- ------------------------------------------------------------------
- function CheckForStart(pUnit)
- local id = MapMgr:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- if (ICC[id].VAR.Ready and ICC[id].VAR.Lich ~= nil) then
- ICC[id].VAR.Ready = false
- ICC[id].VAR.i = 0
- ICC[id].VAR.Tirion:GetAIInterface():MoveTo(489.14, -2124.45, 1040.9, 0) -- Closer to LK
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 7500, 1)
- else
- pUnit:RegisterEvent(CheckForStart, 2500, 1)
- end
- end
- function WalkTowardsLichKingThenEmotes(pUnit)
- local id = MapMgr:GetInstanceID()
- if (ICC[id].VAR.i == 0) then
- ICC[id].VAR.Tirion:EventAddEmote(375, 58500)
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- Stand up
- PlaySoundToSet(ICC[id].VAR.Tirion, 17349) -- Voice of message - Tirion since players are closer to him
- PlaySoundToSet(ICC[id].VAR.Tirion, 17457) -- The music for this point
- 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)
- ICC[id].VAR.Lich:GetAIInterface():StopMovement(0) -- Resets bytes bug
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 4000, 1)
- elseif (ICC[id].VAR.i == 1) then
- ICC[id].VAR.Lich:GetAIInterface():StopMovement(0) -- Resets bytes bug
- ICC[id].VAR.Lich:GetAIInterface():MoveTo(457.44, -2123.86, 1041.2, 0) -- Down from throne to floor
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 10000, 1)
- elseif (ICC[id].VAR.i == 2) then
- 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)
- PlaySoundToSet(ICC[id].VAR.Tirion, 17390)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 2000, 1)
- elseif (ICC[id].VAR.i == 3) then
- ICC[id].VAR.Lich:GetAIInterface():MoveTo(462.01, -2124.146, 1040.9, 0) -- Forwards slightly to correct position
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 8500, 1)
- elseif (ICC[id].VAR.i == 4) then
- 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)
- PlaySoundToSet(ICC[id].VAR.Tirion, 17350)
- ICC[id].VAR.Lich:EventAddEmote(397, 4000)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 4500, 1)
- elseif (ICC[id].VAR.i == 5) then
- ICC[id].VAR.Lich:EventAddEmote(1, 6000)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 12000, 1)
- elseif (ICC[id].VAR.i == 6) then
- ICC[id].VAR.Lich:EventAddEmote(392, 3500)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 7500, 1)
- elseif (ICC[id].VAR.i == 7) then
- ICC[id].VAR.Tirion:SendChatMessage(14,0,"So be it. Champions, attack!", 0)
- PlaySoundToSet(ICC[id].VAR.Tirion, 17391)
- ICC[id].VAR.Tirion:EventAddEmote(397, 2000)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 2000, 1)
- elseif (ICC[id].VAR.i == 8) then
- ICC[id].VAR.Tirion:GetAIInterface():setMoveRunFlag(true)
- ICC[id].VAR.Tirion:GetAIInterface():MoveTo(472.88, -2124.2, 1040.9, 0) -- Run towards LK
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 1000, 1)
- elseif (ICC[id].VAR.i == 9) then
- 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)
- PlaySoundToSet(ICC[id].VAR.Tirion, 17351)
- ICC[id].VAR.Tirion:RegisterEvent(WalkTowardsLichKingThenEmotes, 500, 1)
- elseif (ICC[id].VAR.i == 10) then
- ICC[id].VAR.Lich:CastSpell(ICC[id].VAR.Tirion, 71614, false) -- Freeze
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
- end
- ICC[id].VAR.i = ICC[id].VAR.i + 1
- end
- ------------------------------------------------------------------
- -- The Fight -----------------------------------------------------
- ------------------------------------------------------------------
- local function OnEnterCombatStuff(pUnit, Event)
- local id = MapMgr:GetInstanceID()
- -- This will only be nil if one enters combat with the lich king in less than 2.5 seconds of spawn
- ICC[id].VAR.Lich:RegisterEvent(CheckForFinalPhase, 2500, 1) -- Repeat 0 only checks once for some reason
- end
- function CheckForFinalPhase(pUnit)
- local id = MapMgr:GetInstanceID()
- if (ICC[id].VAR.Lich:GetHealthPct() < 11) then
- ICC[id].VAR.Lich:SendChatMessage(14,0,"You gnats actually hurt me! Perhaps I've toyed with you long enough, now taste the vengeance of the grave!", 0)
- PlaySoundToSet(ICC[id].VAR.Lich, 17359)
- ICC[id].VAR.Lich:GetAIInterface():setMoveRunFlag(true)
- ICC[id].VAR.Lich:GetAIInterface():MoveTo(505.212, -2124.35, 1040.95, 0) -- Center of the room
- ICC[id].VAR.Lich:GetAIInterface().disable_combat = true
- ICC[id].VAR.Lich:RegisterEvent(KeepMoving, 500, 10) -- Just to make sure he stays on the right tracks, though disabling combat above should work
- ICC[id].VAR.Lich:RegisterEvent(KillAll, 5005, 1)
- else
- ICC[id].VAR.Lich:RegisterEvent(CheckForFinalPhase, 2500, 1)
- end
- end
- function KeepMoving(pUnit)
- local id = MapMgr:GetInstanceID()
- ICC[id].VAR.Lich:GetAIInterface():MoveTo(505.212, -2124.35, 1040.95, 0) -- Center of the room
- end
- function KillAll(pUnit)
- local id = MapMgr:GetInstanceID()
- ICC[id].VAR.Lich:GetAIInterface().canmove = false
- ICC[id].VAR.Lich:CastSpell(ICC[id].VAR.Lich, 70063, false) -- Wipe the raid - fury of frostmourne
- ICC[id].VAR.i = 0
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 10000, 1)
- end
- RegisterUnitEvent(LichKingNPCID, 1, OnEnterCombatStuff)
- ------------------------------------------------------------------
- -- Death Cinematic -----------------------------------------------
- ------------------------------------------------------------------
- function DeathCinematic(pUnit)
- local id = MapMgr:GetInstanceID()
- if (ICC[id].VAR.i == 0) then
- ICC[id].VAR.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...", 0)
- PlaySoundToSet(ICC[id].VAR.Lich, 17353)
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 25000, 1)
- elseif (ICC[id].VAR.i == 1) then
- ICC[id].VAR.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.", 0)
- PlaySoundToSet(ICC[id].VAR.Lich, 17355)
- --ICC[id].VAR.Lich:ChannelSpell(ICC[id].VAR.Lich, 73823) -- Harvest souls (right visual ??) -- Method is not implemented into LuaBridge yet for some reason
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 24000, 1)
- elseif (ICC[id].VAR.i == 2) then
- ICC[id].VAR.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.", 0)
- PlaySoundToSet(ICC[id].VAR.Lich, 17356)
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 26000, 1)
- elseif (ICC[id].VAR.i == 3) then
- PlaySoundToSet(ICC[id].VAR.Lich, 17357)
- ICC[id].VAR.Lich:SendChatMessage(14,0,"I delight in the irony.", 0)
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 6000, 1)
- elseif (ICC[id].VAR.i == 4) then
- ICC[id].VAR.Tirion:SendChatMessage(14,0,"LIGHT, GRANT ME ONE FINAL BLESSING. GIVE ME THE STRENGTH... TO SHATTER THESE BONDS!", 0)
- PlaySoundToSet(ICC[id].VAR.Tirion, 17392)
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 9000, 1)
- elseif (ICC[id].VAR.i == 5) then
- ICC[id].VAR.Tirion:RemoveAura(71614) -- Ice block
- -- Will have to have invisible npc cast the light visual spell on tirion then tirion to cast end bit
- ICC[id].VAR.Tirion:CastSpell(ICC[id].VAR.Tirion, 71797, false) -- Light visual
- ICC[id].VAR.Tirion:CastSpell(ICC[id].VAR.Tirion, 71614, true) -- IceBlock visual
- ICC[id].VAR.Lich:RegisterEvent(DeathCinematic, 8000, 1)
- elseif (ICC[id].VAR.i == 6) then
- ICC[id].VAR.Tirion:RemoveAura(71614) -- Ice block
- -- ICC[id].VAR.Tirion:EquipWeapons(50442, 0, 0) -- Glowing Ashbringer - no yet added to LuaBridge
- end
- ICC[id].VAR.i = ICC[id].VAR.i + 1
- end
- ------------------------------------------------------------------
- -- Misc Stuff ----------------------------------------------------
- ------------------------------------------------------------------
- -- Handle the ICC buffs and when to change worldstates
- local function OnZoneChange(event, player, zone, oldzone)
- local race = player:getRace()
- if (zone == 4812) then
- UpdateWorldstatesUI(player)
- local id = MapMgr:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- UpdateAttempts(player, id)
- player:CastSpell(player, 69127, true) -- Chill of the Throne
- player:CastSpell(player, 69127, true) -- Hack'y way of applying the correct aura types.
- if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
- player:CastSpell(player, 73828, true) -- Strength of Wyrn
- else
- player:CastSpell(player, 73822, true) -- Hellscreem's warsong
- end
- elseif (oldzone == 4812) then
- ResetWorldstatesUI(player)
- player:RemoveAura(69127) -- Chill of the Throne
- if (race == 1 or race == 3 or race == 4 or race == 7 or race == 11) then
- player:RemoveAura(73828) -- Strength of Wyrn
- else
- player:RemoveAura(73822) -- Hellscreem's warsong
- end
- end
- end
- RegisterServerHook(15, OnZoneChange)
- -- Playing sounds to set
- function PlaySoundToSet(object, ID)
- local pack = LuaPacket(722, 4)
- pack:WriteUint32(ID)
- object:SendMessageToSet(pack, true)
- end
- -- Handle the worldstates
- function UpdateWorldstatesUI(player)
- local pack = LuaPacket(SMSG_INIT_WORLD_STATES, 18)
- pack:WriteUint32(631) -- Map
- pack:WriteUint32(4859) -- Zone
- pack:WriteUint32(0)
- pack:WriteUInt16(2)
- pack:WriteUint32(4940) -- ID
- pack:WriteUint32(1) -- Value
- TO_PLAYER(player):SendPacket(pack)
- end
- function UpdateAttempts(player, id)
- if ICC[id].VAR.Attempts == nil then
- ICC[id].VAR.Attempts = 20
- end
- local pack = LuaPacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteUint32(4941) -- ID, X/
- pack:WriteUint32(ICC[id].VAR.Attempts) -- Value
- player:SendPacket(pack)
- local pack = LuaPacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteUint32(4942) -- ID, /X
- pack:WriteUint32(ICC[id].VAR.Attempts) -- Value
- TO_PLAYER(player):SendPacket(pack)
- end
- function ResetWorldstatesUI(player)
- local pack = LuaPacket(SMSG_INIT_WORLD_STATES, 18)
- pack:WriteUint32(0) -- Map
- pack:WriteUint32(0) -- Zone
- pack:WriteUint32(0)
- pack:WriteUint16(0)
- pack:WriteUint32(0) -- ID
- pack:WriteUint32(0) -- Value
- TO_PLAYER(player):SendPacket(pack)
- end
- ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment