stoneharry

Untitled

Aug 20th, 2011
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.56 KB | None | 0 0
  1.  
  2. -- By Stoneharry
  3.  
  4. INS = {}
  5. INS.VAR = {}
  6.  
  7. local Spawned = {}
  8. local Players = {}
  9.  
  10. local OBJECT_END = 0x0006
  11. --local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044 -- Size: 1, Type: BYTES, Flags: PUBLIC
  12. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  13. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  14. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  15.  
  16. function INS.VAR.Lorestone_spawn(pUnit, Event)
  17.     local id = pUnit:GetInstanceID()
  18.     if id == nil then id = 1 end
  19.     INS[id] = INS[id] or {VAR={}}
  20.     INS[id].VAR.Lore = pUnit
  21. end
  22.  
  23. RegisterUnitEvent(203120, 18, "INS.VAR.Lorestone_spawn")
  24.  
  25. function INS.VAR.Elf_channel_spawn(pUnit, Event)
  26.     local id = pUnit:GetInstanceID()
  27.     if id == nil then id = 1 end
  28.     INS[id] = INS[id] or {VAR={}}
  29.     INS[id].VAR.Ready = true
  30.     INS[id].VAR.Phase = 0
  31.     pUnit:RegisterEvent("INS.VAR.Check_For_Ready_Elf", 5000, 0)
  32. end
  33.  
  34. RegisterUnitEvent(203121, 18, "INS.VAR.Elf_channel_spawn")
  35.  
  36. function INS.VAR.zzzWolly_On_Gossip(pUnit, event, player)
  37.     pUnit:GossipCreateMenu(738, player, 0)
  38.     local id = pUnit:GetInstanceID()
  39.     if id == nil then id = 1 end
  40.     INS[id] = INS[id] or {VAR={}}
  41.     if INS[id].VAR.Ready and INS[id].VAR.Phase == 0 then
  42.         pUnit:GossipMenuAddItem(9, "We are ready, begin.", 246, 0)
  43.     end
  44.     pUnit:GossipMenuAddItem(0, "Nevermind.", 250, 0)
  45.     pUnit:GossipSendMenu(player)
  46. end
  47.  
  48. function INS.VAR.zzzWolly_Gossip_Submenus(pUnit, event, player, id, intid, code)
  49.     local id = pUnit:GetInstanceID()
  50.     if id == nil then id = 1 end
  51.     INS[id] = INS[id] or {VAR={}}
  52.     if(intid == 246) then
  53.         INS[id].VAR.Ready = false
  54.         pUnit:SetNPCFlags(2)
  55.         player:GossipComplete()
  56.     elseif(intid == 250) then
  57.         player:GossipComplete()
  58.     end
  59. end
  60.  
  61. RegisterUnitGossipEvent(203121, 1, "INS.VAR.zzzWolly_On_Gossip")
  62. RegisterUnitGossipEvent(203121, 2, "INS.VAR.zzzWolly_Gossip_Submenus")
  63.  
  64. function INS.VAR.Check_For_Ready_Elf(pUnit)
  65.     local id = pUnit:GetInstanceID()
  66.     if id == nil then id = 1 end
  67.     INS[id] = INS[id] or {VAR={}}
  68.     if INS[id].VAR.Ready == false then
  69.         pUnit:SendChatMessage(12,0,"This is our final stand, make every blow count!")
  70.         pUnit:PlaySoundToSet(11062)
  71.         INS[id].VAR.Lore:ChannelSpell(48316, pUnit) -- soul sucker
  72.         pUnit:ChannelSpell(13540, INS[id].VAR.Lore) -- Green channel
  73.         pUnit:RemoveEvents()
  74.         INS[id].VAR.i = 0
  75.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 3500, 1)
  76.     end
  77. end
  78.  
  79. function INS.VAR.EventFunction_Handler(pUnit)
  80.     local id = pUnit:GetInstanceID()
  81.     if id == nil then id = 1 end
  82.     INS[id] = INS[id] or {VAR={}}
  83.     if INS[id].VAR.i == 0 then
  84.         INS[id].VAR.MoleA = pUnit:GetGameObjectNearestCoords(-517, 2232.7, 539.3, 188478)
  85.         INS[id].VAR.MoleA:SetByte(0x0006+0x000B,0,0) -- Open
  86.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 700, 1)
  87.     elseif INS[id].VAR.i == 1 then
  88.         INS[id].VAR.MoleB = pUnit:GetGameObjectNearestCoords(-515.8, 2187.9, 539.3, 188478)
  89.         INS[id].VAR.MoleB:SetByte(0x0006+0x000B,0,0) -- Open
  90.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 3000, 1)
  91.     elseif INS[id].VAR.i == 2 then
  92.         pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 7945, 3450, 0)
  93.         pUnit:SpawnCreature(203122, -519.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
  94.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 3000, 1)
  95.     elseif INS[id].VAR.i == 3 then
  96.         INS[id].VAR.MoleA:SetByte(0x0006+0x000B,0,1) -- Close
  97.         INS[id].VAR.MoleB:SetByte(0x0006+0x000B,0,1) -- Close
  98.         pUnit:SendChatMessage(12,0,"Fight! Fight till your dying breath!")
  99.         pUnit:PlaySoundToSet(11063)
  100.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 22000, 1)
  101.     elseif INS[id].VAR.i == 4 then
  102.         INS[id].VAR.MoleA:SetByte(0x0006+0x000B,0,0) -- Open
  103.         INS[id].VAR.MoleB:SetByte(0x0006+0x000B,0,0) -- Open
  104.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 2000, 1)
  105.     elseif INS[id].VAR.i == 5 then
  106.         pUnit:SpawnCreature(203122, -521, 2230.6, 540, 4.394675, 21, 120000, 23171, 0, 0)
  107.         pUnit:SpawnCreature(203122, -520, 2230.6, 542, 4.394675, 21, 120000, 7945, 3450, 0)
  108.         pUnit:SpawnCreature(203122, -519.44, 2191, 542, 2.004, 21, 120000, 23171, 0, 0)
  109.         pUnit:SpawnCreature(203122, -518.44, 2191, 540, 2.004, 21, 120000, 7945, 3450, 0)
  110.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 2000, 1)
  111.     elseif INS[id].VAR.i == 6 then
  112.         INS[id].VAR.MoleA:SetByte(0x0006+0x000B,0,1) -- Close
  113.         INS[id].VAR.MoleB:SetByte(0x0006+0x000B,0,1) -- Close
  114.         pUnit:SendChatMessage(12,0,"Give every ounce of strength, do not despair!")
  115.         pUnit:PlaySoundToSet(11064)
  116.         for place,creature in pairs(Spawned) do
  117.             if creature ~= nil then
  118.                 if creature:IsInWorld() then
  119.                     if creature:IsAlive() == false then
  120.                         creature:Despawn(1000,0)
  121.                     end
  122.                 end
  123.             end
  124.         end
  125.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 30000, 1)
  126.     elseif INS[id].VAR.i == 7 then
  127.         pUnit:SendChatMessage(42,0,"Stay out of the red lights!")
  128.         local plr = pUnit:GetRandomPlayer(0)
  129.         if plr ~= nil then
  130.             INS[id].VAR.BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  131.         end
  132.         plr = pUnit:GetRandomPlayer(0)
  133.         if plr ~= nil then
  134.             INS[id].VAR.BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
  135.         end
  136.         INS[id].VAR.BeamA:SetUnitToFollow(INS[id].VAR.BeamA:GetClosestPlayer(), 0.2, 1)
  137.         INS[id].VAR.BeamB:SetUnitToFollow(INS[id].VAR.BeamB:GetClosestPlayer(), 0.2, 1)
  138.         INS[id].VAR.BeamA:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  139.         INS[id].VAR.BeamB:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  140.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 2000, 1)
  141.     elseif INS[id].VAR.i == 8 then
  142.         for place,creature in pairs(Spawned) do
  143.             if creature ~= nil then
  144.                 if creature:IsInWorld() then
  145.                     if creature:IsAlive() == false then
  146.                         creature:Despawn(1500,0)
  147.                     end
  148.                 end
  149.             end
  150.             Spawned[place] = nil
  151.         end
  152.         INS[id].VAR.BeamA:CastSpell(32839) -- Red beam
  153.         INS[id].VAR.BeamB:CastSpell(32839)
  154.         pUnit:RegisterEvent("INS.VAR.CheckForNearbyPlayers_Beams", 1500, 0)
  155.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 45000, 1)
  156.     elseif INS[id].VAR.i == 9 then
  157.         pUnit:RemoveEvents()
  158.         INS[id].VAR.BeamA:RemoveAura(32839) -- Red Beam
  159.         INS[id].VAR.BeamB:RemoveAura(32839)
  160.         INS[id].VAR.BeamA:Despawn(2000, 0)
  161.         INS[id].VAR.BeamB:Despawn(2000, 0)
  162.         INS[id].VAR.BeamA = nil
  163.         INS[id].VAR.BeamB = nil
  164.         pUnit:SendChatMessage(12,0,"We can not hold them off for long!")
  165.         pUnit:PlaySoundToSet(11065)
  166.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 5000, 1)
  167.     elseif INS[id].VAR.i == 10 then
  168.         pUnit:SendChatMessage(42,0,"Stay within the blue light!")
  169.         pUnit:CastSpell(32840) -- Blue beam
  170.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 8000, 1)
  171.     elseif INS[id].VAR.i == 11 then
  172.         for a, plrs in pairs(pUnit:GetInRangePlayers()) do
  173.             if pUnit:GetDistanceYards(plrs) > 7.5 then
  174.                 plrs:CastSpell(39180)
  175.                 table.insert(Players, plrs)
  176.             end
  177.         end
  178.         pUnit:RemoveAura(32840)
  179.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 700, 1)
  180.     elseif INS[id].VAR.i == 12 then
  181.         for a, plrs in pairs(Players) do
  182.             plrs:CastSpell(7)
  183.             plrs:CastSpell(11)
  184.             plrs:CastSpell(11)
  185.             plrs:CastSpell(11)
  186.             Players[a] = nil
  187.         end
  188.         pUnit:StopChannel()
  189.         INS[id].VAR.Lore:StopChannel()
  190.         INS[id].VAR.Visuals = pUnit:SpawnCreature(203124, INS[id].VAR.Lore:GetX(), INS[id].VAR.Lore:GetY(), INS[id].VAR.Lore:GetZ(), 0, 35, 0)
  191.         INS[id].VAR.Visuals:ChannelSpell(56571, pUnit)
  192.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 4000, 1)
  193.     elseif INS[id].VAR.i == 13 then
  194.         pUnit:SendChatMessage(12,0,"It is finished then. This is the end - for all of us.")
  195.         pUnit:PlaySoundToSet(11067)
  196.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 7500, 1)
  197.     elseif INS[id].VAR.i == 14 then
  198.         INS[id].VAR.Visuals:StopChannel()
  199.         INS[id].VAR.Visuals:CastSpell(59084) -- boom visual
  200.         INS[id].VAR.Visuals:Despawn(5500, 0)
  201.         INS[id].VAR.Visuals = nil
  202.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 2750, 1)
  203.     elseif INS[id].VAR.i == 15 then
  204.         if INS[id].VAR.Boss == nil then
  205.             pUnit:PlaySoundToSet(17289) -- Epic music
  206.             INS[id].VAR.Boss = pUnit:SpawnCreature(203125, INS[id].VAR.Lore:GetX(), INS[id].VAR.Lore:GetY(), INS[id].VAR.Lore:GetZ(), INS[id].VAR.Lore:GetO(), 21, 0, 4548, 0, 0)
  207.             INS[id].VAR.Boss:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  208.             pUnit:ChannelSpell(27259, INS[id].VAR.Boss)
  209.             INS[id].VAR.i = INS[id].VAR.i - 1
  210.         else
  211.             if INS[id].VAR.Boss:IsAlive() then
  212.                 INS[id].VAR.i = INS[id].VAR.i - 1
  213.                 if INS[id].VAR.Boss:GetHealthPct() < 50 and INS[id].VAR.Phase == 0 then
  214.                     INS[id].VAR.Boss:EquipWeapons(0,0,0)
  215.                     INS[id].VAR.Boss:CastSpell(70590) -- Drop weapon visual
  216.                     INS[id].VAR.Boss:CastSpell(35426) -- arcane explosion visual
  217.                     INS[id].VAR.Boss:CastSpell(18501) -- enrage
  218.                     INS[id].VAR.Phase = 1
  219.                 elseif INS[id].VAR.Boss:GetHealthPct() < 25 and INS[id].VAR.Phase == 1 then
  220.                     INS[id].VAR.Phase = 2
  221.                     INS[id].VAR.Boss:FullCastSpell(34807)
  222.                 end
  223.             end
  224.         end
  225.         pUnit:RegisterEvent("INS.VAR.EventFunction_Handler", 5000, 1) -- Remove soon, register on boss death
  226.     elseif INS[id].VAR.i == 16 then
  227.         pUnit:StopChannel()
  228.         INS[id].VAR.i = -1
  229.         if INS[id].VAR.Boss ~= nil then
  230.             INS[id].VAR.Boss:Despawn(120000, 0)
  231.             INS[id].VAR.Boss = nil
  232.         end
  233.         INS[id].VAR.Ready = true
  234.         pUnit:RemoveEvents()
  235.         INS[id].VAR.Lore:StopChannel()
  236.         pUnit:StopChannel()
  237.         pUnit:SetNPCFlags(3)
  238.         pUnit:RegisterEvent("INS.VAR.Check_For_Ready_Elf", 5000, 0)
  239.     end
  240.     INS[id].VAR.i = INS[id].VAR.i + 1
  241. end
  242.  
  243. function INS.VAR.CheckForNearbyPlayers_Beams(pUnit)
  244.     local id = pUnit:GetInstanceID()
  245.     if id == nil then id = 1 end
  246.     INS[id] = INS[id] or {VAR={}}
  247.     local plr = INS[id].VAR.BeamA:GetClosestPlayer()
  248.     if plr ~= nil then
  249.         if plr:GetDistanceYards(INS[id].VAR.BeamA) < 7 then
  250.             plr:CastSpell(43418) -- impact
  251.             INS[id].VAR.BeamA:Strike(plr, 0, 38043, 520, 530, 2)
  252.         end
  253.     end
  254.     plr = INS[id].VAR.BeamB:GetClosestPlayer()
  255.     if plr ~= nil then
  256.         if plr:GetDistanceYards(INS[id].VAR.BeamB) < 7 then
  257.             plr:CastSpell(43418) -- impact
  258.             INS[id].VAR.BeamB:Strike(plr, 0, 38043, 520, 530, 2)
  259.         end
  260.     end
  261. end
  262.  
  263. ------------------------------------------------------------------------------
  264.  
  265. function INS.VAR.random_npc_onspawn(pUnit, Event)
  266.     pUnit:RegisterEvent("INS.VAR.travel_spawn_lag", 1000, 1)
  267. end
  268.  
  269. function INS.VAR.travel_spawn_lag(pUnit)
  270.     table.insert(Spawned, pUnit)
  271.     local plr = pUnit:GetRandomPlayer(0)
  272.     if plr ~= nil then
  273.         pUnit:SetMovementFlags(1)
  274.         pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  275.         pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  276.     end
  277. end
  278.  
  279. RegisterUnitEvent(203122, 18, "INS.VAR.random_npc_onspawn")
  280.  
  281. --
Add Comment
Please, Sign In to add comment