stoneharry

Untitled

Apr 17th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.16 KB | None | 0 0
  1.  
  2. -- By Stoneharry
  3.  
  4. -- 72313 -- nice visual -- cast on people
  5.  
  6. -- 65684 ground visual, player stand on it
  7. -- 70763 -- good portal
  8. -- 60285 -- dat visual
  9.  
  10. -- Variables
  11.  
  12. TOC = {}
  13. TOC.VAR = {}
  14.  
  15. local debugmode = false
  16.  
  17. local OBJECT_END = 0x0006
  18. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  19. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  20. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
  21. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  22.  
  23. -- Gossip to start
  24.  
  25. function TOC.VAR.Tournament_start_Gossipc(pUnit, event, player)
  26.     pUnit:GossipCreateMenu(12733, player, 0)
  27.     pUnit:GossipMenuAddItem(9, "Let us begin this tournament.", 424, 0)
  28.     pUnit:GossipMenuAddItem(0, "Nevermind.", 526, 0)
  29.     pUnit:GossipSendMenu(player)
  30. end
  31.  
  32.  
  33. function TOC.VAR.Tournament_start_Gossipm(pUnit, event, player, id, intid, code)
  34.     player:GossipComplete()
  35.     if(intid == 424) then
  36.         pUnit:SetNPCFlags(2)
  37.         pUnit:Emote(2, 0)
  38.         local id = pUnit:GetInstanceID()
  39.         if id == nil then id = 1 end
  40.         TOC[id] = TOC[id] or {VAR={}}
  41.         TOC[id].VAR.ready = true
  42.     end
  43. end
  44.  
  45. RegisterUnitGossipEvent(27060, 1, "TOC.VAR.Tournament_start_Gossipc")
  46. RegisterUnitGossipEvent(27060, 2, "TOC.VAR.Tournament_start_Gossipm")
  47.  
  48. function TOC.VAR.Tournament_starter_Spawn(pUnit, Event)
  49.     pUnit:SetNPCFlags(1)
  50.     pUnit:RegisterEvent("TOC.VAR.CheckToBegin_Tournament_Starter", 5000, 0)
  51. end
  52.  
  53. function TOC.VAR.CheckToBegin_Tournament_Starter(pUnit)
  54.     local id = pUnit:GetInstanceID()
  55.     if id == nil then id = 1 end
  56.     TOC[id] = TOC[id] or {VAR={}}
  57.     if TOC[id].VAR.ready then
  58.         pUnit:RemoveEvents()
  59.         pUnit:RegisterEvent("TOC.VAR.RunAwayEtc_LoL_Courier", 3000, 1)
  60.     end
  61. end
  62.  
  63. function TOC.VAR.RunAwayEtc_LoL_Courier(pUnit)
  64.     pUnit:SetMovementFlags(1)
  65.     pUnit:MoveTo(563, 86, 395.3, 0)
  66.     pUnit:Despawn(6000, 0)
  67. end
  68.  
  69. RegisterUnitEvent(27060, 18, "TOC.VAR.Tournament_starter_Spawn")
  70.  
  71. -- Tirion Fordwing
  72.  
  73. function TOC.VAR.Tirion_Spawn_Events(pUnit, Event)
  74.     pUnit:RegisterEvent("TOC.VAR.Tirion_CheckToStart_Tournament", 8000, 0)
  75. end
  76.  
  77. function TOC.VAR.Tirion_CheckToStart_Tournament(pUnit)
  78.     local id = pUnit:GetInstanceID()
  79.     if id == nil then id = 1 end
  80.     TOC[id] = TOC[id] or {VAR={}}
  81.     if TOC[id].VAR.ready then
  82.         pUnit:RemoveEvents()
  83.         TOC[id].VAR.count = 0
  84.         pUnit:PlaySoundToSet(15852)
  85.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 10000, 1)
  86.     end
  87. end
  88.  
  89. function TOC.VAR.TirionSendMessagesEtc(pUnit)
  90.     local id = pUnit:GetInstanceID()
  91.     if id == nil then id = 1 end
  92.     TOC[id].VAR.count = TOC[id].VAR.count + 1
  93.     if debugmode then
  94.         if TOC[id].VAR.count < 5 then
  95.             TOC[id].VAR.count = 18 -- 15 = boss 2, 18 = boss 3
  96.         end
  97.     end
  98.     if TOC[id].VAR.count == 1 then
  99.         pUnit:SendChatMessage(14,0,"Welcome to the trials of the crusader. Only the most powerful companions of Azeroth are allowed to undergo these trials. You are among the worthy few.")
  100.         pUnit:PlaySoundToSet(16053)
  101.         pUnit:Emote(1, 4000)
  102.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 12000, 1)
  103.     elseif TOC[id].VAR.count == 2 then
  104.         pUnit:SendChatMessage(14,0,"Grand Warlock Wilfred Fizzlebang will summon forth your next challenge. Stand by for his entry!")
  105.         pUnit:PlaySoundToSet(16043)
  106.         pUnit:Emote(1, 3000)
  107.         pUnit:SpawnCreature(35476, 563.7, 89.8, 395.3, 1.587163, 35, 0)
  108.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 1000, 1)
  109.     elseif TOC[id].VAR.count == 3 then
  110.         TOC[id].VAR.gnome = pUnit:GetCreatureNearestCoords(563.7, 89.8, 395.3, 35476)
  111.         TOC[id].VAR.gnome:SetMovementFlags(1)
  112.         TOC[id].VAR.gnome:MoveTo(563.52, 135, 394.3, 0)
  113.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 7500, 1)
  114.     elseif TOC[id].VAR.count == 4 then
  115.         TOC[id].VAR.gnome:SendChatMessage(14,0,"Thank you, Highlord! Now challengers, I will begin the ritual of summoning! When I am done, a fearsome Doomguard will appear!")
  116.         TOC[id].VAR.gnome:PlaySoundToSet(16268)
  117.         TOC[id].VAR.gnome:Emote(1,4000)
  118.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 7000, 1)
  119.     elseif TOC[id].VAR.count == 5 then
  120.         TOC[id].VAR.portal = pUnit:GetCreatureNearestCoords(563.9, 149, 394, 21862)
  121.         TOC[id].VAR.gnome:ChannelSpell(48185, TOC[id].VAR.portal)
  122.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 12000, 1)
  123.     elseif TOC[id].VAR.count == 6 then
  124.         TOC[id].VAR.gnome:PlaySoundToSet(16269)
  125.         TOC[id].VAR.gnome:StopChannel()
  126.         TOC[id].VAR.gnome:SendChatMessage(14,0,"Prepare for oblivion!")
  127.         TOC[id].VAR.portal:CastSpell(40280) -- visual
  128.         TOC[id].VAR.portal:SetScale(1.5)
  129.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 2000, 1)
  130.     elseif TOC[id].VAR.count == 7 then
  131.         TOC[id].VAR.Jarax = pUnit:SpawnCreature(34780, 564, 147.3, 394, 4.72, 21, 0, 29981)
  132.         TOC[id].VAR.Jarax:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  133.         pUnit:SendChatMessage(16, 0, "A portal opens, and Lord Jaraxxus - clearly not a doomguard - enters the arena.")
  134.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 3000, 1)
  135.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Visualc", 1500, 1)
  136.     elseif TOC[id].VAR.count == 8 then
  137.         TOC[id].VAR.gnome:Emote(4,0)
  138.         TOC[id].VAR.gnome:SendChatMessage(14,0,"Ah ha, I have done it! Behold the absolute power of Wilfred Fizzlebang, master summoner! You are bound to ME, demon!")
  139.         TOC[id].VAR.gnome:PlaySoundToSet(16270)
  140.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 12000, 1)
  141.     elseif TOC[id].VAR.count == 9 then
  142.         TOC[id].VAR.Jarax:SendChatMessage(14,0,"Trifling gnome, your arrogance will be your undoing!")
  143.         TOC[id].VAR.Jarax:PlaySoundToSet(16143)
  144.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 6500, 1)
  145.     elseif TOC[id].VAR.count == 10 then
  146.         TOC[id].VAR.gnome:SendChatMessage(14,0,"But I'm in charge her-")
  147.         TOC[id].VAR.gnome:PlaySoundToSet(16271)
  148.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 1000, 1)
  149.     elseif TOC[id].VAR.count == 11 then
  150.         TOC[id].VAR.Jarax:CastSpell(58538) -- visual
  151.         TOC[id].VAR.Jarax:StopChannel()
  152.         TOC[id].VAR.gnome:MoveKnockback(554.8, 85.4, 395.2, 3,4)
  153.         pUnit:SendChatMessage(16, 0, "Lord Jaraxxus kills the Grand Warlock - the gnome's last breath an agonized scream.")
  154.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 1000, 1)
  155.     elseif TOC[id].VAR.count == 12 then
  156.         TOC[id].VAR.gnome:CastSpell(11)
  157.         pUnit:SendChatMessage(14,0,"Quickly, heroes! Destroy the demon lord before it can open a portal to its twisted demonic realm!")
  158.         pUnit:PlaySoundToSet(16044)
  159.         TOC[id].VAR.portal:RemoveAura(40280)
  160.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 6000, 1)
  161.     elseif TOC[id].VAR.count == 13 then
  162.         TOC[id].VAR.Jarax:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  163.         TOC[id].VAR.Jarax:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  164.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 3000, 1)
  165.     elseif TOC[id].VAR.count == 14 then
  166.         if TOC[id].VAR.jaraxdead then
  167.             TOC[id].VAR.count = TOC[id].VAR.count + 1
  168.         end
  169.         TOC[id].VAR.count = TOC[id].VAR.count - 1
  170.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 6000, 1)
  171.     elseif TOC[id].VAR.count == 15 then
  172.         pUnit:Emote(1,4000)
  173.         pUnit:SendChatMessage(14,0,"The loss of Wilfred Fizzlebang, while unfortunate, should be a lesson to those that dare dabble in dark magic. Alas, you are victorious and must now face the next challenge.")
  174.         pUnit:SendChatMessage(42,0,"Warning : You can only attempt the next boss once. The vehicles that aid you do not respawn.")
  175.         pUnit:PlaySoundToSet(16045)
  176.         pUnit:SpawnCreature(33412, 563.6, 172.2, 394.6, 4.756226, 35, 0):SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  177.         local faction = nil
  178.         for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  179.             faction = plrs:GetFaction()
  180.             break
  181.         end
  182.         if faction ~= nil then
  183.             pUnit:SpawnCreature(280211, 563.6, 99, 394.7, 1.556860, faction, 0)
  184.             pUnit:SpawnCreature(280213, 563.6, 90, 395.3, 1.556860, faction, 0)
  185.             pUnit:SpawnCreature(280213, 556.5, 94.5, 395.3, 1.374647, faction, 0)
  186.             pUnit:SpawnCreature(280212, 551.5, 95.6, 395.3, 1.374647, faction, 0)
  187.             pUnit:SpawnCreature(280212, 545, 97, 395.3, 1.303961, faction, 0)
  188.         end
  189.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 6000, 1)
  190.     elseif TOC[id].VAR.count == 16 then
  191.         if TOC[id].VAR.xtdead then
  192.             TOC[id].VAR.count = TOC[id].VAR.count + 1
  193.         end
  194.         TOC[id].VAR.count = TOC[id].VAR.count - 1
  195.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 6000, 1)
  196.     elseif TOC[id].VAR.count == 17 then
  197.         pUnit:RegisterEvent("TOC.VAR.TirionSendMessagesEtc", 5000, 1)
  198.     elseif TOC[id].VAR.count == 18 then
  199.         local object = pUnit:GetGameObjectNearestCoords(563.4, 177.8, 398.8, 195527)
  200.         if object ~= nil then
  201.             object:SetUInt32Value(0x0006+0x0003,0x200) -- damaged
  202.         end
  203.         for _,units in pairs(pUnit:GetInRangeUnits()) do
  204.             if not units:IsPlayer() then
  205.                 units:RemoveEvents()
  206.                 units:Despawn(1,0)
  207.             end
  208.         end
  209.         pUnit:SpawnGameObject(195709, 616.3, 136.3, 139, 3.111200, 300000, 200) -- 2nd boss loot
  210.         --pUnit:SpawnCreature() -- 3rd boss
  211.     end
  212.    
  213. end
  214.  
  215. function TOC.VAR.Jaraxxus_Visualc(pUnit)
  216.     local id = pUnit:GetInstanceID()
  217.     if id == nil then id = 1 end
  218.     TOC[id].VAR.Jarax:ChannelSpell(67924, TOC[id].VAR.Jarax)
  219. end
  220.  
  221. -- 16037 -- Let the games begin!
  222.  
  223. RegisterUnitEvent(24232, 18, "TOC.VAR.Tirion_Spawn_Events")
  224.  
  225. -- Jaraxxus
  226.  
  227. function TOC.VAR.JaraxussEventsHandler(pUnit, Event)
  228.     if Event == 1 then
  229.         pUnit:PlaySoundToSet(16144) -- voice
  230.         pUnit:SendChatMessage(14,0,"You face Jaraxxus, eredar lord of the Burning Legion!")
  231.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Buffself", 6000, 1)
  232.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Cleave", 7000, 0)
  233.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Flamestrike", 11000, 0)
  234.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_RandomFelfireBolt", 8000, 0)
  235.         pUnit:RegisterEvent("TOC.VAR.Jaraxuss_PathOfFire", 15000, 0)
  236.         pUnit:RegisterEvent("TOC.VAR.Jaraxuss_FireEverywhere", 2000, 0)
  237.     elseif Event == 2 then
  238.         pUnit:RemoveEvents()
  239.         pUnit:PlaySoundToSet(16146)
  240.         pUnit:SendChatMessage(14,0,"Banished to the Nether!")
  241.     elseif Event == 4 then
  242.         pUnit:RemoveEvents()
  243.         pUnit:PlaySoundToSet(16147)
  244.         pUnit:SendChatMessage(14,0,"Another will take my place. Your world is doomed.")
  245.         local id = pUnit:GetInstanceID()
  246.         if id == nil then id = 1 end
  247.         TOC[id].VAR.jaraxdead = true
  248.     end
  249. end
  250.  
  251. function TOC.VAR.Jaraxuss_FireEverywhere(pUnit)
  252.     if pUnit:GetHealthPct() < 60 then
  253.         pUnit:RemoveEvents()
  254.         local id = pUnit:GetInstanceID()
  255.         if id == nil then id = 1 end
  256.         TOC[id].VAR.chaos = true
  257.         TOC[id].VAR.chaosplayers = {}
  258.         TOC[id].VAR.chaosid = 0
  259.         local count = 0
  260.         for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  261.             count = count + 1
  262.             table.insert(TOC[id].VAR.chaosplayers, plrs)
  263.         end
  264.         for i=1,count do
  265.             pUnit:SpawnCreature(68333, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 30000):SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  266.         end
  267.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_ResetChaos", 3000, 1)
  268.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Buffself", 6000, 1)
  269.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Cleave", 7000, 0)
  270.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Flamestrike", 5000, 0)
  271.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_RandomFelfireBolt", 8000, 0)
  272.         pUnit:RegisterEvent("TOC.VAR.Jaraxuss_PathOfFire", 15000, 0)
  273.         pUnit:RegisterEvent("TOC.VAR.Jaraxuss_FireEverywhere_PartTwo", 2000, 0)
  274.     end
  275. end
  276.  
  277. function TOC.VAR.Jaraxuss_FireEverywhere_PartTwo(pUnit)
  278.     if pUnit:GetHealthPct() < 20 then
  279.         pUnit:RemoveEvents()
  280.         local id = pUnit:GetInstanceID()
  281.         if id == nil then id = 1 end
  282.         TOC[id].VAR.chaos = true
  283.         TOC[id].VAR.chaosplayers = {}
  284.         TOC[id].VAR.chaosid = 0
  285.         local count = 0
  286.         for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  287.             count = count + 1
  288.             table.insert(TOC[id].VAR.chaosplayers, plrs)
  289.         end
  290.         for i=1,count do
  291.             pUnit:SpawnCreature(68333, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 30000):SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  292.         end
  293.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Chaos", 3000, 1)
  294.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_ResetChaos", 6000, 1)
  295.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Buffself", 1000, 1)
  296.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Cleave", 7000, 0)
  297.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Flamestrike", 5000, 0)
  298.         pUnit:RegisterEvent("TOC.VAR.Jaraxxus_RandomFelfireBolt", 8000, 0)
  299.         pUnit:RegisterEvent("TOC.VAR.Jaraxuss_PathOfFire", 10000, 0)
  300.     end
  301. end
  302.  
  303. function TOC.VAR.Jaraxxus_Chaos(pUnit)
  304.     local id = pUnit:GetInstanceID()
  305.     if id == nil then id = 1 end
  306.     TOC[id].VAR.chaosplayers = {}
  307.     TOC[id].VAR.chaosid = 0
  308.     local count = 0
  309.     for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  310.         count = count + 1
  311.         table.insert(TOC[id].VAR.chaosplayers, plrs)
  312.     end
  313.     for i=1,count do
  314.         pUnit:SpawnCreature(68333, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 30000):SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  315.     end
  316. end
  317.  
  318. function TOC.VAR.Jaraxxus_ResetChaos(pUnit)
  319.     local id = pUnit:GetInstanceID()
  320.     if id == nil then id = 1 end
  321.     TOC[id].VAR.chaos = false
  322.     TOC[id].VAR.chaosid = 0
  323.     TOC[id].VAR.chaosplayers = {}
  324. end
  325.  
  326. function TOC.VAR.Jaraxxus_Buffself(pUnit)
  327.     pUnit:FullCastSpell(67108) -- +20% spell damage, stacks
  328.     pUnit:RegisterEvent("TOC.VAR.Jaraxxus_Buffself", math.random(10000,50000), 1)
  329. end
  330.  
  331. function TOC.VAR.Jaraxxus_Cleave(pUnit)
  332.     local plr = pUnit:GetMainTank()
  333.     if plr ~= nil then
  334.         pUnit:FullCastSpellOnTarget(38742, plr)
  335.     end
  336. end
  337.  
  338. function TOC.VAR.Jaraxxus_Flamestrike(pUnit)
  339.     if math.random(1,2) == 1 then
  340.         local choice = math.random(1,2)
  341.         if choice == 1 then
  342.             pUnit:SendChatMessage(16,0,"Lord Jaraxxus laughs maniacally.")
  343.             pUnit:PlaySoundToSet(16148)
  344.         else
  345.             pUnit:SendChatMessage(14,0,"Inferno!")
  346.             pUnit:PlaySoundToSet(16151)
  347.         end
  348.     end
  349.     local plr = pUnit:GetRandomPlayer(0)
  350.     if plr ~= nil then
  351.         pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 39139)
  352.     end
  353. end
  354.  
  355. function TOC.VAR.Jaraxxus_RandomFelfireBolt(pUnit)
  356.     local plr = pUnit:GetRandomPlayer(0)
  357.     if plr ~= nil then
  358.         pUnit:CastSpellOnTarget(36404, plr)
  359.     end
  360. end
  361.  
  362. function TOC.VAR.Jaraxuss_PathOfFire(pUnit)
  363.     pUnit:SpawnCreature(68333, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 30000):SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  364. end
  365.  
  366. RegisterUnitEvent(34780, 1, "TOC.VAR.JaraxussEventsHandler")
  367. RegisterUnitEvent(34780, 2, "TOC.VAR.JaraxussEventsHandler")
  368. RegisterUnitEvent(34780, 4, "TOC.VAR.JaraxussEventsHandler")
  369.  
  370. -- path of fire
  371.  
  372. function TOC.VAR.Jaraxxus_PathOfFireSpawn(pUnit, Event)
  373.     local id = pUnit:GetInstanceID()
  374.     if id == nil then id = 1 end
  375.     if TOC[id].VAR.chaos then
  376.         TOC[id].VAR.chaosid = TOC[id].VAR.chaosid + 1
  377.         local plrs = TOC[id].VAR.chaosplayers[TOC[id].VAR.chaosid]
  378.         if plrs ~= nil then
  379.             pUnit:SetMovementFlags(1)
  380.             pUnit:MoveTo(plrs:GetX(), plrs:GetY(), plrs:GetZ(), 0)
  381.             pUnit:RegisterEvent("TOC.VAR.SpawnMoreStaticFiresJarax", 700, 14)
  382.         end
  383.     else
  384.         local range = 0
  385.         local target = nil
  386.         for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  387.             if plrs:GetDistanceYards(pUnit) > range then
  388.                 range = plrs:GetDistanceYards(pUnit)
  389.                 target = plrs
  390.             end
  391.         end
  392.         if target ~= nil then
  393.             pUnit:SetMovementFlags(1)
  394.             pUnit:MoveTo(target:GetX(), target:GetY(), target:GetZ(), 0)
  395.             pUnit:RegisterEvent("TOC.VAR.SpawnMoreStaticFiresJarax", 700, 14)
  396.         end
  397.     end
  398. end
  399.  
  400. function TOC.VAR.SpawnMoreStaticFiresJarax(pUnit)
  401.     if not pUnit:IsCreatureMoving() then
  402.         pUnit:RemoveEvents()
  403.     end
  404.     pUnit:SpawnCreature(68334, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 20000):SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  405. end
  406.  
  407. RegisterUnitEvent(68333, 18, "TOC.VAR.Jaraxxus_PathOfFireSpawn")
  408.  
  409. function TOC.VAR.Jaraxxus_DealDamageSpawn(pUnit, Event)
  410.     pUnit:RegisterEvent("TOC.VAR.FireVisualStuff", 1100, 1)
  411.     pUnit:RegisterEvent("TOC.VAR.FireVisualStuff_Damage", 1000, 19)
  412. end
  413.  
  414. function TOC.VAR.FireVisualStuff_Damage(pUnit)
  415.     for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  416.         if plrs:GetDistanceYards(pUnit) < 7 then
  417.             pUnit:Strike(plrs, 2, 67060, 75, 150, 1)
  418.         end
  419.     end
  420. end
  421.  
  422. function TOC.VAR.FireVisualStuff(pUnit)
  423.     pUnit:SetScale(5)
  424.     pUnit:FullCastSpell(36006)
  425. end
  426.  
  427. RegisterUnitEvent(68334, 18, "TOC.VAR.Jaraxxus_DealDamageSpawn")
  428.  
  429. -- Gossip to start 2nd boss
  430.  
  431. function TOC.VAR.Tournament_start_Gossipd(pUnit, event, player)
  432.     pUnit:GossipCreateMenu(12734, player, 0)
  433.     pUnit:GossipMenuAddItem(9, "We accept.", 424, 0)
  434.     pUnit:GossipMenuAddItem(0, "Nevermind.", 526, 0)
  435.     pUnit:GossipSendMenu(player)
  436. end
  437.  
  438.  
  439. function TOC.VAR.Tournament_start_Gossipg(pUnit, event, player, id, intid, code)
  440.     player:GossipComplete()
  441.     if(intid == 424) then
  442.         pUnit:SetNPCFlags(2)
  443.         local id = pUnit:GetInstanceID()
  444.         if id == nil then id = 1 end
  445.         TOC[id] = TOC[id] or {VAR={}}
  446.         TOC[id].VAR.readytwo = true
  447.         pUnit:SetFaction(21)
  448.     end
  449. end
  450.  
  451. RegisterUnitGossipEvent(33412, 1, "TOC.VAR.Tournament_start_Gossipd")
  452. RegisterUnitGossipEvent(33412, 2, "TOC.VAR.Tournament_start_Gossipg")
  453.  
  454. function TOC.VAR.TournamentSecondBoss(pUnit, Event)
  455.     pUnit:SetNPCFlags(1)
  456.     pUnit:SetFaction(15)
  457.     pUnit:RegisterEvent("TOC.VAR.CheckToStartsecondBoss", 5000, 0)
  458. end
  459.  
  460. function TOC.VAR.CheckToStartsecondBoss(pUnit)
  461.     local id = pUnit:GetInstanceID()
  462.     if id == nil then id = 1 end
  463.     TOC[id] = TOC[id] or {VAR={}}
  464.     if TOC[id].VAR.readytwo then
  465.         pUnit:RemoveEvents()
  466.         TOC[id].VAR.xt = pUnit:SpawnCreature(1133293, 563.844, 265.08, 395, 4.724016, 21, 0)
  467.         TOC[id].VAR.xt:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  468.         pUnit:RegisterEvent("TOC.VAR.LolSpawnXT200", 2000, 1)
  469.     end
  470. end
  471.  
  472. function TOC.VAR.LolSpawnXT200(pUnit)
  473.     local id = pUnit:GetInstanceID()
  474.     if id == nil then id = 1 end
  475.     TOC[id] = TOC[id] or {VAR={}}
  476.     TOC[id].VAR.xt:SetMovementFlags(1)
  477.     TOC[id].VAR.xt:MoveTo(563.38, 190.17, 394.62, 0)
  478.     pUnit:GetGameObjectNearestCoords(564.5, 213.3, 395.2, 195647):SetByte(0x0006+0x000B,0,0) -- Open
  479.     pUnit:RegisterEvent("TOC.VAR.LolOpenXT200", 11000, 1)
  480.     pUnit:RegisterEvent("TOC.VAR.LolGetInXT200", 14000, 1)
  481.     pUnit:RegisterEvent("TOC.VAR.LolGetGoingXT200", 17000, 1)
  482.     pUnit:RegisterEvent("TOC.VAR.LolGoGoGOXT", 21000, 1)
  483. end
  484.  
  485. function TOC.VAR.LolOpenXT200(pUnit)
  486.     local id = pUnit:GetInstanceID()
  487.     if id == nil then id = 1 end
  488.     TOC[id].VAR.xt:SetUInt32Value(UNIT_FIELD_BYTES_1, 9) -- kneel
  489.     pUnit:GetGameObjectNearestCoords(564.5, 213.3, 395.2, 195647):SetByte(0x0006+0x000B,0,1)
  490. end
  491.  
  492. function TOC.VAR.LolGetInXT200(pUnit)
  493.     local id = pUnit:GetInstanceID()
  494.     if id == nil then id = 1 end
  495.     pUnit:EnterVehicle(TOC[id].VAR.xt, 1000)
  496. end
  497.  
  498. function TOC.VAR.LolGetGoingXT200(pUnit)
  499.     local id = pUnit:GetInstanceID()
  500.     if id == nil then id = 1 end
  501.     TOC[id].VAR.xt:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- get up
  502. end
  503.  
  504. function TOC.VAR.LolGoGoGOXT(pUnit)
  505.     local id = pUnit:GetInstanceID()
  506.     if id == nil then id = 1 end
  507.     TOC[id].VAR.xt:MoveCharge(564, 155.31, 394.4)
  508.     pUnit:RegisterEvent("TOC.VAR.BeginXTFight", 2000, 1)
  509. end
  510.  
  511. function TOC.VAR.BeginXTFight(pUnit)
  512.     local id = pUnit:GetInstanceID()
  513.     if id == nil then id = 1 end
  514.     --TOC[id].VAR.xt:SetPosition(563, 141, 393.909, 4.711210)
  515.     TOC[id].VAR.xt:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  516. end
  517.  
  518. RegisterUnitEvent(33412, 18, "TOC.VAR.TournamentSecondBoss")
  519.  
  520. -- 2nd Boss
  521.  
  522. local TopSpawns = {
  523.     [1] = { -- alliance flag
  524.         {33350, 606.15, 170.5, 417.5, 3.829799, 21, 300000},
  525.         {33350, 617.63, 145.7, 416.5, 3.327062, 21, 300000},
  526.         {33350, 617.89, 132.737, 416.5, 3.048250, 21, 300000}
  527.     },
  528.     [2] = {
  529.         {33350, 605.45, 106.82, 417.5, 2.429357, 21, 300000},
  530.         {33350, 600.83, 101.45, 417.5, 2.441138, 21, 300000},
  531.         {33350, 594.86, 96.459, 417.5, 2.297408, 21, 300000}
  532.     },
  533.     -- between 2 & 3 = center
  534.     [3] = {
  535.         {33350, 569.39, 85.18, 416.5, 1.903139, 21, 300000},
  536.         {33350, 556.74, 85.3, 416.5, 1.491590, 21, 300000},
  537.         {33350, 532, 96.7, 417.5, 0.875837, 21, 300000}
  538.     },
  539.     [4] = { -- horde flag
  540.         {33350, 520.7, 107.8, 417.5, 0.632363, 21, 300000},
  541.         {33350, 509.4, 133.5, 416.5, 0.048419, 21, 300000},
  542.         {33350, 509.2, 146, 416.5, 6.157244, 21, 300000}
  543.     }
  544. }
  545.  
  546. function TOC.VAR.XTEnterEventAndStuff(pUnit, Event)
  547.     if Event == 1 then
  548.         pUnit:SendChatMessage(14,0,"New toys? For me? I promise I won't break them this time!")
  549.         pUnit:PlaySoundToSet(15724)
  550.         pUnit:RegisterEvent("TOC.VAR.Stun_Everyone_Baddass_Boss", 40000, 0)
  551.         pUnit:RegisterEvent("TOC.VAR.pewpewmaintandana", 25000, 0)
  552.         pUnit:RegisterEvent("TOC.VAR.slamthegrounda", 33000, 0)
  553.         pUnit:RegisterEvent("TOC.VAR.SpawnTrashConstantly", 5000, 0)
  554.         pUnit:RegisterEvent("TOC.VAR.CheckForWIPEXT", 3000, 0)
  555.         pUnit:RegisterEvent("TOC.VAR.XTplayerscastself", 24000, 0)
  556.         pUnit:RegisterEvent("TOC.VAR.SendRandomMessagesRandomlyXT", 5000, 0)
  557.     elseif Event == 4 then
  558.         pUnit:PlaySoundToSet(15731)
  559.         pUnit:SendChatMessage(14,0,"You are bad... Toys... Very... Baaaaad!")
  560.         pUnit:RemoveEvents()
  561.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  562.             if not unit:IsPlayer() then
  563.                 if unit:GetEntry() == 280211 or unit:GetEntry() == 280212 or unit:GetEntry() == 280213 then
  564.                     unit:Kill(unit)
  565.                 elseif unit:GetEntry() == 33350 then
  566.                     unit:Despawn(1,0)
  567.                 end
  568.             end
  569.         end
  570.     end
  571. end
  572.  
  573. function TOC.VAR.SendRandomMessagesRandomlyXT(pUnit)
  574.     if math.random(1,4) == 1 then
  575.         local choice = math.random(1,3)
  576.         if choice == 1 then
  577.             pUnit:SendChatMessage(14,0,"I guess it doesn't bend that way.")
  578.             pUnit:PlaySoundToSet(15729)
  579.         elseif choice == 2 then
  580.             pUnit:SendChatMessage(14,0,"I'm tired of these toys. I don't want to play anymore!")
  581.             pUnit:PlaySoundToSet(15730)
  582.         elseif choice == 3 then
  583.             pUnit:SendChatMessage(14,0,"Time for a new game! My old toys will fight my new toys!")
  584.             pUnit:PlaySoundToSet(15732)
  585.         end
  586.     end
  587. end
  588.  
  589. function TOC.VAR.XTplayerscastself(pUnit)
  590.     local plr = pUnit:GetRandomPlayer(0)
  591.     if plr ~= nil then
  592.         if plr:GetVehicleBase() ~= nil then
  593.             plr:GetVehicleBase():FullCastSpell(63025)
  594.         else
  595.             plr:FullCastSpell(63025)
  596.         end
  597.     end
  598. end
  599.  
  600. function TOC.VAR.CheckForWIPEXT(pUnit)
  601.     local found = false
  602.     for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  603.         if plrs:IsAlive() then
  604.             found = true
  605.             break
  606.         end
  607.     end
  608.     if not found then
  609.         pUnit:PlaySoundToSet(15728)
  610.         pUnit:SendChatMessage(14,0,"I... I think I broke it.")
  611.         pUnit:RemoveEvents()
  612.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  613.             if not unit:IsPlayer() then
  614.                 unit:Despawn(1,0)
  615.             end
  616.         end
  617.         pUnit:SendChatMessage(42,0,"You have failed.")
  618.         pUnit:Despawn(2000, 0)
  619.     end
  620. end
  621.  
  622. function TOC.VAR.Stun_Everyone_Baddass_Boss(pUnit)
  623.     if not pUnit:IsCasting() then
  624.         local plr = pUnit:GetRandomPlayer(0)
  625.         if plr ~= nil then
  626.             pUnit:FullCastSpellOnTarget(38052, plr)
  627.         end
  628.     end
  629. end
  630.  
  631. function TOC.VAR.pewpewmaintandana(pUnit)
  632.     if not pUnit:IsCasting() then
  633.         pUnit:FullCastSpell(25322)
  634.         pUnit:SendChatMessage(14,0,"I'm ready to play!")
  635.         pUnit:PlaySoundToSet(15726)
  636.     end
  637. end
  638.  
  639. function TOC.VAR.slamthegrounda(pUnit)
  640.     pUnit:Root()
  641.     pUnit:SendChatMessage(14,0,"NO! NO! NO! NO! NO!")
  642.     pUnit:PlaySoundToSet(15727)
  643.     pUnit:FullCastSpell(62776)
  644.     pUnit:RegisterEvent("TOC.VAR.unrootBossXT", 8000, 1)
  645. end
  646.  
  647. function TOC.VAR.unrootBossXT(pUnit)
  648.     pUnit:Unroot()
  649. end
  650.  
  651. RegisterUnitEvent(1133293, 1, "TOC.VAR.XTEnterEventAndStuff")
  652. RegisterUnitEvent(1133293, 4, "TOC.VAR.XTEnterEventAndStuff")
  653.  
  654. function TOC.VAR.SpawnTrashConstantly(pUnit)
  655.     for _,unit in pairs(pUnit:GetInRangeUnits()) do
  656.         if not unit:IsPlayer() then
  657.             if not unit:IsAlive() then
  658.                 unit:Despawn(1, 0)
  659.             end
  660.         end
  661.     end
  662.     local chance = math.random(1,100)
  663.     if chance < 26 then
  664.         chance = 1
  665.     elseif chance < 51 then
  666.         chance = 2
  667.     elseif chance < 76 then
  668.         chance = 3
  669.     elseif chance < 101 then
  670.         chance = 4
  671.     end
  672.     local tbl = TopSpawns[chance]
  673.     for info in pairs(tbl) do
  674.         pUnit:SpawnCreature(unpack(tbl[info])):SetUInt32Value(UNIT_FIELD_FLAGS, 2)
  675.     end
  676. end
  677.  
  678. function TOC.VAR.TrashSpawnedFoRXT(pUnit, Event)
  679.     pUnit:RegisterEvent("TOC.VAR.trashXTJump", math.random(1000, 4000), 1)
  680. end
  681.  
  682. function TOC.VAR.trashXTJump(pUnit)
  683.     local a = pUnit:CalcToDistance(589.75, 139.4, 394.4)
  684.     local b = pUnit:CalcToDistance(563.5, 113.8, 394.4)
  685.     local c = pUnit:CalcToDistance(537.4, 139.3, 394.4)
  686.     local answer = 1
  687.     if b < a then
  688.         answer = 2
  689.     end
  690.     if c < a then
  691.         answer = 3
  692.     end
  693.     if answer == 1 then
  694.         pUnit:MoveJump(589.75+math.random(0,2), 139.4+math.random(0,2), 394.4)
  695.     elseif answer == 2 then
  696.         pUnit:MoveJump(563.5+math.random(0,2), 113.8+math.random(0,2), 394.4)
  697.     elseif answer == 3 then
  698.         pUnit:MoveJump(537.4+math.random(0,2), 139.3+math.random(0,2), 394.4)
  699.     end
  700.     pUnit:RegisterEvent("TOC.VAR.trashSetHostileXT", 3000, 1)
  701. end
  702.  
  703. function TOC.VAR.trashSetHostileXT(pUnit)
  704.     local plr = pUnit:GetClosestPlayer()
  705.     if plr ~= nil then
  706.         pUnit:SetMovementFlags(1)
  707.         pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  708.     end
  709.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  710. end
  711.  
  712. RegisterUnitEvent(33350, 18, "TOC.VAR.TrashSpawnedFoRXT")
  713.  
  714. -- 2nd boss main guy death
  715.  
  716. function TOC.VAR.miniXTEvents(pUnit, Event)
  717.     if Event == 1 then
  718.         pUnit:RegisterEvent("TOC.VAR.MiniDoThingsXT", 3000, 0)
  719.     elseif Event == 2 then
  720.         pUnit:RemoveEvents()
  721.         pUnit:Despawn(2000, 0)
  722.     elseif Event == 4 then
  723.         pUnit:RemoveEvents()
  724.         local id = pUnit:GetInstanceID()
  725.         if id == nil then id = 1 end
  726.         TOC[id].VAR.xtdead = true
  727.     end
  728. end
  729.  
  730. function TOC.VAR.MiniDoThingsXT(pUnit)
  731.     local plr = pUnit:GetRandomPlayer(0)
  732.     if plr ~= nil then
  733.         pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 4069) -- bomb
  734.     end
  735. end
  736.  
  737. RegisterUnitEvent(33412, 1, "TOC.VAR.miniXTEvents")
  738. RegisterUnitEvent(33412, 2, "TOC.VAR.miniXTEvents")
  739. RegisterUnitEvent(33412, 4, "TOC.VAR.miniXTEvents")
  740.  
  741. -- For testing
  742. --[[
  743. function TOC.VAR.TrialoftheCrusader_Object(event, plr, message, type, language)
  744.     if message == "#destroy" then
  745.         local object = plr:GetGameObjectNearestCoords(563.4, 177.8, 398.8, 195527)
  746.         if object ~= nil then
  747.             plr:SendBroadcastMessage("Destroying...")
  748.             object:SetUInt32Value(0x0006+0x0003,0x400) -- destroy destructable object
  749.         end
  750.         return false
  751.     elseif message == "#rebuild" then
  752.         local object = plr:GetGameObjectNearestCoords(563.4, 177.8, 398.8, 195527)
  753.         if object ~= nil then
  754.             plr:SendBroadcastMessage("Rebuilding...")
  755.             object:RemoveFlag(0x0006+0x0003,0x400) -- destroyed rebuild
  756.             object:RemoveFlag(0x0006+0x0003,0x200) -- damaged rebuild
  757.         end
  758.         return false
  759.     elseif message == "#damage" then
  760.         local object = plr:GetGameObjectNearestCoords(563.4, 177.8, 398.8, 195527)
  761.         if object ~= nil then
  762.             plr:SendBroadcastMessage("Damaging...")
  763.             object:SetUInt32Value(0x0006+0x0003,0x200) -- damaged
  764.         end
  765.         return false
  766.     end
  767. end
  768.  
  769. RegisterServerHook(16, "TOC.VAR.TrialoftheCrusader_Object")
  770. ]]
Advertisement
Add Comment
Please, Sign In to add comment