Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------
- --[[
- SQL Queries used while creating this script:
- UPDATE `worldmap_info` SET `viewingDistance` = '900' WHERE `entry` = '631';
- ]]
- ------------------------------------------------------------------
- -- Variable declaration and generally setting up the script
- 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
- local GAMEOBJECT_FLAGS = OBJECT_END + 0x0003
- -- Unconfigurable Variables
- ICC = {}
- ICC.VAR = {}
- ------------------------------------------------------------------
- -- The gossip used to start the encounter - Tirion ---------------
- -- Also set up events etc ----------------------------------------
- ------------------------------------------------------------------
- function ICC.VAR.Tirion_OnGossipTalk(pUnit, Event, player)
- pUnit:GossipCreateMenu(2975252, player, 0)
- pUnit:GossipMenuAddItem(9, "We are prepared, Highlord. Let us battle for the fate of Azeroth! For the light of dawn!", 1, 0)
- pUnit:GossipMenuAddItem(0, "We are not yet prepared, Highlord.", 2, 0)
- pUnit:GossipSendMenu(player)
- end
- function ICC.VAR.Tirion_OnGossipSelect(pUnit, Event, player, id, code)
- if (id == 1) then
- local id = pUnit: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
- end
- player:GossipComplete()
- end
- RegisterUnitGossipEvent(TirionNPCID, 1, "ICC.VAR.Tirion_OnGossipTalk")
- RegisterUnitGossipEvent(TirionNPCID, 2, "ICC.VAR.Tirion_OnGossipSelect")
- function ICC.VAR.OnSpawnHandleStart(pUnit, Event)
- pUnit:SetUInt32Value(UNIT_NPC_FLAGS, 1) -- Gossip Flags, for when the fight resets
- -- This function does not seem to get all the objects required
- --[[for k,objects in pairs(pUnit:GetInRangeObjects()) do
- if objects ~= nil then
- local flags = objects:SetUInt32Value(GAMEOBJECT_FLAGS,0x1)
- if flags ~= nil then
- if(bit_and(flags,0x1) == 0 or bit_and(flags, 0x2) ~= 0) then
- objects:SetUInt32Value(GAMEOBJECT_FLAGS,0x1)
- end
- end
- end
- end]]
- pUnit:RegisterEvent("ICC.VAR.CheckForStart", 2500, 0)
- end
- RegisterUnitEvent(TirionNPCID, 18, "ICC.VAR.OnSpawnHandleStart")
- function ICC.VAR.OnSpawnHandleDefineAndBytes(pUnit, Event)
- pUnit:RegisterEvent("ICC.VAR.SetBytesAndHandleVariable", 2000, 1)
- end
- function ICC.VAR.SetBytesAndHandleVariable(pUnit)
- local id = pUnit: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, "ICC.VAR.OnSpawnHandleDefineAndBytes")
- ------------------------------------------------------------------
- -- Mini-cinematic at the start -----------------------------------
- ------------------------------------------------------------------
- function ICC.VAR.CheckForStart(pUnit)
- local id = pUnit: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:RemoveEvents()
- ICC[id].VAR.Tirion:MoveTo(489.14, -2124.45, 1040.9, 0) -- Closer to LK
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 7500, 1)
- end
- end
- function ICC.VAR.WalkTowardsLichKingThenEmotes(pUnit)
- local id = pUnit:GetInstanceID()
- if (ICC[id].VAR.i == 0) then
- ICC[id].VAR.Tirion:Emote(375, 58500)
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- Stand up
- ICC[id].VAR.Tirion:PlaySoundToSet(17349) -- Voice of message - Tirion since players are closer to him
- ICC[id].VAR.Tirion:PlaySoundToSet(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?")
- ICC[id].VAR.Lich:StopMovement(0) -- Resets bytes bug
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 4000, 1)
- elseif (ICC[id].VAR.i == 1) then
- ICC[id].VAR.Lich:StopMovement(0) -- Resets bytes bug
- ICC[id].VAR.Lich:MoveTo(457.44, -2123.86, 1041.2, 0) -- Down from throne to floor
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.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.")
- ICC[id].VAR.Tirion:PlaySoundToSet(17390)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 2000, 1)
- elseif (ICC[id].VAR.i == 3) then
- ICC[id].VAR.Lich:MoveTo(462.01, -2124.146, 1040.9, 0) -- Forwards slightly to correct position
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.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.")
- ICC[id].VAR.Tirion:PlaySoundToSet(17350)
- ICC[id].VAR.Lich:Emote(397, 4000)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 4500, 1)
- elseif (ICC[id].VAR.i == 5) then
- ICC[id].VAR.Lich:Emote(1, 6000)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 12000, 1)
- elseif (ICC[id].VAR.i == 6) then
- ICC[id].VAR.Lich:Emote(392, 3500)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 7500, 1)
- elseif (ICC[id].VAR.i == 7) then
- ICC[id].VAR.Tirion:SendChatMessage(14,0,"So be it. Champions, attack!")
- ICC[id].VAR.Tirion:PlaySoundToSet(17391)
- ICC[id].VAR.Tirion:Emote(397, 2000)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 2000, 1)
- elseif (ICC[id].VAR.i == 8) then
- ICC[id].VAR.Tirion:SetMovementFlags(1) -- Run
- ICC[id].VAR.Tirion:MoveTo(472.88, -2124.2, 1040.9, 0) -- Run towards LK
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.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.")
- ICC[id].VAR.Tirion:PlaySoundToSet(17351)
- ICC[id].VAR.Tirion:RegisterEvent("ICC.VAR.WalkTowardsLichKingThenEmotes", 500, 1)
- elseif (ICC[id].VAR.i == 10) then
- ICC[id].VAR.Lich:CastSpellOnTarget(71614, ICC[id].VAR.Tirion) -- Freeze
- ICC[id].VAR.Lich:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
- end
- ICC[id].VAR.i = ICC[id].VAR.i + 1
- end
- ------------------------------------------------------------------
- -- The Fight -----------------------------------------------------
- ------------------------------------------------------------------
- function ICC.VAR.OnEnterCombatStuff(pUnit, Event)
- local id = pUnit:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- if id == nil then id = 0 end
- -- This will only be nil if one enters combat with the lich king in less than 2.5 seconds of spawn
- if ICC[id].VAR.Lich then
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.CheckForFinalPhase", 2500, 0)
- end
- end
- function ICC.VAR.CheckForFinalPhase(pUnit)
- local id = pUnit:GetInstanceID()
- if (ICC[id].VAR.Lich:GetHealthPct() < 11) then
- ICC[id].VAR.Lich:RemoveEvents()
- 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!")
- ICC[id].VAR.Lich:PlaySoundToSet(17359)
- ICC[id].VAR.Lich:SetMovementFlags(1)
- ICC[id].VAR.Lich:MoveTo(505.212, -2124.35, 1040.95, 0) -- Center of the room
- ICC[id].VAR.Lich:AIDisableCombat(true) -- Requires custom patch to work
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.Lich_KeepMoving", 500, 2) -- Just to make sure he stays on the right tracks, though disabling combat above should work
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.Lich_KillAll", 5005, 1)
- end
- end
- function ICC.VAR.Lich_KeepMoving(pUnit)
- local id = pUnit:GetInstanceID()
- ICC[id].VAR.Lich:MoveTo(505.212, -2124.35, 1040.95, 0) -- Center of the room
- end
- function ICC.VAR.Lich_KillAll(pUnit)
- local id = pUnit:GetInstanceID()
- ICC[id].VAR.Lich:Root()
- ICC[id].VAR.ForceWiped = true
- ICC[id].VAR.Lich:FullCastSpell(70063) -- Wipe the raid - fury of frostmourne
- ICC[id].VAR.i = 0
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 10000, 1)
- end
- RegisterUnitEvent(LichKingNPCID, 1, "ICC.VAR.OnEnterCombatStuff")
- function ICC.VAR.OnWipeEvents(pUnit, Event)
- local id = pUnit:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- if not ICC[id].VAR.ForceWiped then -- it didn't wipe via fury of frostmourne
- ICC[id].VAR.Lich:RemoveEvents()
- if Event == 2 then
- pUnit:Despawn(2000, 10000)
- elseif Event == 4 then
- -- He died
- end
- end
- end
- RegisterUnitEvent(LichKingNPCID, 2, "ICC.VAR.OnWipeEvents")
- RegisterUnitEvent(LichKingNPCID, 4, "ICC.VAR.OnWipeEvents")
- ------------------------------------------------------------------
- -- Death Cinematic -----------------------------------------------
- ------------------------------------------------------------------
- function ICC.VAR.DeathCinematic_Lich(pUnit)
- local id = pUnit:GetInstanceID()
- if (ICC[id].VAR.i == 0) then
- ICC[id].VAR.Tirion:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unattackable, used to prevent Tirion hitting LK during the Dragonball Z moment
- ICC[id].VAR.Tirion:Root() -- Stop stop him resetting position
- 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...")
- ICC[id].VAR.Lich:PlaySoundToSet(17353)
- ICC[id].VAR.Lich:WipeTargetList() -- reset targets
- ICC[id].VAR.Lich:SetFacing(0.01745329)
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 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.")
- ICC[id].VAR.Lich:PlaySoundToSet(17355) -- text
- ICC[id].VAR.Lich:PlaySoundToSet(17460) -- final music
- ICC[id].VAR.Lich:FullCastSpell(71769) -- visual to raise players
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 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.")
- ICC[id].VAR.Lich:PlaySoundToSet(17356)
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 26000, 1)
- elseif (ICC[id].VAR.i == 3) then
- ICC[id].VAR.Lich:PlaySoundToSet(17357)
- ICC[id].VAR.Lich:SendChatMessage(14,0,"I delight in the irony.", 0)
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 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!")
- ICC[id].VAR.Tirion:PlaySoundToSet(17392)
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 9000, 1)
- elseif (ICC[id].VAR.i == 5) then
- --ICC[id].VAR.Tirion:RemoveAura(71614) -- Ice block
- ICC[id].VAR.Tirion:CastSpell(71797) -- Light visual
- --ICC[id].VAR.Tirion:CastSpell(71614) -- IceBlock visual
- ICC[id].VAR.Lich:RegisterEvent("ICC.VAR.DeathCinematic_Lich", 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
- end
- ICC[id].VAR.i = ICC[id].VAR.i + 1
- end
- ------------------------------------------------------------------
- -- Misc Stuff ----------------------------------------------------
- ------------------------------------------------------------------
- -- Handle the ICC buffs and when to change worldstates
- function ICC.VAR.OnZoneChange(event, player, zone, oldzone)
- local race = player:GetPlayerRace()
- if (zone == 4812) then
- UpdateWorldstatesUI(player)
- local id = player:GetInstanceID()
- ICC[id] = ICC[id] or {VAR={}}
- UpdateAttempts(player, id)
- player:CastSpell(69127) -- Chill of the Throne
- player:CastSpell(69127) -- 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(73828) -- Strength of Wyrn
- else
- player:CastSpell(73822) -- 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, "ICC.VAR.OnZoneChange")
- -- Handle the worldstates
- function UpdateWorldstatesUI(player)
- local pack = LuaPacket:CreatePacket(SMSG_INIT_WORLD_STATES, 18)
- pack:WriteULong(631) -- Map
- pack:WriteULong(4859) -- Zone
- pack:WriteULong(0)
- pack:WriteUShort(2)
- pack:WriteULong(4940) -- ID
- pack:WriteULong(1) -- Value
- player:SendPacketToPlayer(pack)
- end
- function UpdateAttempts(player, id)
- if ICC[id].VAR.Attempts == nil then
- ICC[id].VAR.Attempts = 20
- end
- local pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(4941) -- ID, X/
- pack:WriteULong(ICC[id].VAR.Attempts) -- Value
- player:SendPacketToPlayer(pack)
- local pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
- pack:WriteULong(4942) -- ID, /X
- pack:WriteULong(ICC[id].VAR.Attempts) -- Value
- player:SendPacketToPlayer(pack)
- end
- function ResetWorldstatesUI(player)
- local pack = LuaPacket:CreatePacket(SMSG_INIT_WORLD_STATES, 18)
- pack:WriteULong(0) -- Map
- pack:WriteULong(0) -- Zone
- pack:WriteULong(0)
- pack:WriteUShort(0)
- pack:WriteULong(0) -- ID
- pack:WriteULong(0) -- Value
- player:SendPacketToPlayer(pack)
- end
- ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment