stoneharry

Untitled

Mar 30th, 2011
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.82 KB | None | 0 0
  1. -------------------
  2. -- By Stoneharry --
  3. -------------------
  4. -- Variable Decleration
  5. -- Configuration
  6.  
  7. local HANDLER_CREATURE = 780000
  8. local AddA = 780002 -- 4 of them     Gate A
  9. local AddB = 780003 -- 10 of them    Gate A
  10. local AddC = 780004 -- 2 of them     Gate A and B
  11. local AddD = 780005 -- 20 of them    Gate A and B
  12. local AddE = 780006 -- 6 of them     Gate A
  13. local AddF = 780007 -- 15 of them    Gate B
  14. local AddG = 780008 -- 4 of them     Gate A and B
  15. local AddH = 780009 -- 20 of them    no gate
  16. local BossID = 780001
  17. local FIRE = 780010 -- The ID for the lines of fire that spawn
  18.  
  19. local locA, locB, locC = 4523, 2778, 404 -- Randomly moves to one of these two coords on spawn (make near middle)
  20. local locX, locY, locZ = 4522, 2760, 404
  21. local gateAX, gateAY, gateAZ, gateAID = 4522.24, 2740.8, 403.984, 201374 -- The coords then ID of each gate on each side of the room
  22. local gateBX, gateBY, gateBZ, gateBID = 4522.21, 2797.87, 403.984, 201374
  23. local behindGateAX, behindGateAY, behindGateAZ = 4522, 2734, 404 -- The coords behind gate A to spawn mobs
  24. local behindGateBX, behindGateBY, behindGateBZ = 4522, 2804, 404 -- The coords behind gate B to spawn mobs
  25.  
  26. -- Do not touch below unless you are not using 3.3.5a
  27.  
  28. local OBJECT_END = 0x0006
  29. local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
  30. local SMSG_INIT_WORLD_STATES = 0x2C2
  31. local SMSG_UPDATE_WORLD_STATE = 0x2C3
  32.  
  33. -- Do not touch below
  34.  
  35. local CanStart = false
  36. local Wave = 1
  37. local Dead = 0
  38. local gateA = nil
  39. local gateB = nil
  40. local Open = false
  41. local pack = nil
  42. local zX = nil
  43. local zY = nil
  44. SetDBCSpellVar(52989, "c_is_flags", 0x01000)
  45.  
  46. ---------------------------------------------------------
  47. -- Wave Handler -----------------------------------------
  48. ---------------------------------------------------------
  49.  
  50. function Invisible_NpcDEFENDMALL(pUnit, Event)
  51.     pUnit:RegisterEvent("Check_For_EventDEFENDMALL", 5000, 0)
  52. end
  53.  
  54. function Check_For_EventDEFENDMALL(pUnit)
  55.     if CanStart then
  56.         pUnit:RemoveEvents()
  57.         CanStart = false
  58.         Wave = 1
  59.         Dead = 0
  60.         gateA = pUnit:GetGameObjectNearestCoords(gateAX, gateAY, gateAZ, gateAID)
  61.         gateB = pUnit:GetGameObjectNearestCoords(gateBX, gateBY, gateBZ, gateBID)
  62.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  63.             if plrs:GetPhase() == 2 then
  64.                 pUnit:SendChatMessageToPlayer(42,0,"The event has begun! Defend the room for all 8 waves.", plrs)
  65.                 pack = LuaPacket:CreatePacket(SMSG_INIT_WORLD_STATES, 18) -- Waves remaining
  66.                 pack:WriteULong(534) -- Map
  67.                 pack:WriteULong(3606) -- Zone
  68.                 pack:WriteULong(0)
  69.                 pack:WriteUShort(2)
  70.                 pack:WriteULong(2842) -- ID
  71.                 pack:WriteULong(1) -- Value
  72.                 plrs:SendPacketToPlayer(pack)
  73.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  74.                 pack:WriteULong(2842) -- ID, total
  75.                 pack:WriteULong(Wave) -- Value
  76.                 plrs:SendPacketToPlayer(pack)
  77.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 1
  78.             end
  79.         end
  80.         pUnit:PlaySoundToSet(8887) -- Scary music
  81.         pUnit:RegisterEvent("Spawn_Adds_DEFENDMALL", 7000, 1)
  82.     end
  83. end
  84.  
  85. RegisterUnitEvent(HANDLER_CREATURE, 18, "Invisible_NpcDEFENDMALL")
  86.  
  87. function Spawn_Adds_DEFENDMALL(pUnit)
  88.     if gateA ~= nil then
  89.         gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  90.         Open = true
  91.     end
  92.     local i = 0
  93.     while i ~= 4 do
  94.         i = i + 1
  95.         pUnit:SpawnCreature(AddA, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 180000)
  96.     end
  97.     pUnit:RegisterEvent("CheckForDeadAddsOhLol", 10000, 0)
  98.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 180000, 1)
  99. end
  100.  
  101. function CheckForDeadAddsOhLol(pUnit)
  102.     if Open then
  103.         if gateA ~= nil then
  104.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  105.             Open = false
  106.         end
  107.     end
  108.     if Dead > 3 then
  109.         Wave = Wave + 1
  110.         pUnit:RemoveEvents()
  111.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  112.             if plrs:GetPhase() == 2 then
  113.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  114.                 pack:WriteULong(2842) -- ID, total
  115.                 pack:WriteULong(Wave) -- Value
  116.                 plrs:SendPacketToPlayer(pack)
  117.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 2
  118.             end
  119.         end
  120.         if gateA ~= nil then
  121.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  122.             Open = true
  123.         end
  124.         local i = 0
  125.         while i ~= 10 do
  126.             i = i + 1
  127.             pUnit:SpawnCreature(AddB, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 300000)
  128.         end
  129.         pUnit:RegisterEvent("Check_For_All_DeadDEFENDMALL", 10000, 0)
  130.         pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 300000, 1)
  131.     end
  132. end
  133.  
  134. function Check_For_All_DeadDEFENDMALL(pUnit)
  135.     if Open then
  136.         if gateA ~= nil then
  137.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  138.             Open = false
  139.         end
  140.     end
  141.     if Dead > 11 then
  142.         pUnit:RemoveEvents()
  143.         Wave = Wave + 1
  144.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  145.             if plrs:GetPhase() == 2 then
  146.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  147.                 pack:WriteULong(2842) -- ID, total
  148.                 pack:WriteULong(Wave) -- Value
  149.                 plrs:SendPacketToPlayer(pack)
  150.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 3
  151.             end
  152.         end
  153.         if gateA ~= nil then
  154.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  155.             Open = true
  156.         end
  157.         if gateB ~= nil then
  158.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  159.             Open = true
  160.         end
  161.         pUnit:SpawnCreature(AddC, behindGateAX, behindGateAY, behindGateAZ, 0, 15, 320000)
  162.         pUnit:SpawnCreature(AddC, behindGateBX, behindGateBY, behindGateBZ, 0, 15, 320000)
  163.         pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 320000, 1)
  164.         pUnit:RegisterEvent("Check_For_ADDCDEATHS_DEFENDMALL", 10000, 0)
  165.     end
  166. end
  167.  
  168. function Check_For_ADDCDEATHS_DEFENDMALL(pUnit)
  169.     if Open then
  170.         if gateA ~= nil then
  171.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  172.             Open = false
  173.         end
  174.         if gateB ~= nil then
  175.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  176.             Open = false
  177.         end
  178.     end
  179.     if Dead > 13 then
  180.         pUnit:RemoveEvents()
  181.         Wave = Wave + 1
  182.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  183.             if plrs:GetPhase() == 2 then
  184.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  185.                 pack:WriteULong(2842) -- ID, total
  186.                 pack:WriteULong(Wave) -- Value
  187.                 plrs:SendPacketToPlayer(pack)
  188.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 4
  189.             end
  190.         end
  191.         --pUnit:PlaySoundToSet(10763)
  192.         pUnit:RegisterEvent("Break_Break_GiveBreak_DEFENDMALL", 8000, 1)
  193.     end
  194. end
  195.  
  196. function Break_Break_GiveBreak_DEFENDMALL(pUnit)
  197.     local i = 0
  198.     while i ~= 20 do
  199.         i = i + 1
  200.         if math.random(1,2) == 1 then
  201.             pUnit:SpawnCreature(AddD, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 180000)
  202.         else
  203.             pUnit:SpawnCreature(AddD, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 180000)
  204.         end
  205.     end
  206.     if gateA ~= nil then
  207.         gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  208.         Open = true
  209.     end
  210.     if gateB ~= nil then
  211.         gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  212.         Open = true
  213.     end
  214.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 180000, 1)
  215.     pUnit:RegisterEvent("Check_For_mobDDeaths_Yarp", 10000, 0)
  216. end
  217.  
  218. function Check_For_mobDDeaths_Yarp(pUnit)
  219.     if Open then
  220.         if gateA ~= nil then
  221.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  222.             Open = false
  223.         end
  224.         if gateB ~= nil then
  225.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  226.             Open = false
  227.         end
  228.     end
  229.     if Dead > 35 then
  230.         pUnit:RemoveEvents()
  231.         Wave = Wave + 1
  232.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  233.             if plrs:GetPhase() == 2 then
  234.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  235.                 pack:WriteULong(2842) -- ID, total
  236.                 pack:WriteULong(Wave) -- Value
  237.                 plrs:SendPacketToPlayer(pack)
  238.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 5
  239.             end
  240.         end
  241.         pUnit:PlaySoundToSet(15119)
  242.         pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALL", 7500, 1)
  243.     end
  244. end
  245.  
  246. function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALL(pUnit)
  247.     local i = 0
  248.     while i ~= 6 do
  249.         i = i + 1
  250.         pUnit:SpawnCreature(AddE, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 380000)
  251.     end
  252.     if gateA ~= nil then
  253.         gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  254.         Open = true
  255.     end
  256.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 380000, 1)
  257.     pUnit:RegisterEvent("CHECK_FOR_DEAD_MALLEVENTgtoustwo", 10000, 0)
  258. end
  259.  
  260. function CHECK_FOR_DEAD_MALLEVENTgtoustwo(pUnit)
  261.     if Open then
  262.         if gateA ~= nil then
  263.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  264.             Open = false
  265.         end
  266.     end
  267.     if Dead > 40 then
  268.         pUnit:RemoveEvents()
  269.         Wave = Wave + 1
  270.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  271.             if plrs:GetPhase() == 2 then
  272.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  273.                 pack:WriteULong(2842) -- ID, total
  274.                 pack:WriteULong(Wave) -- Value
  275.                 plrs:SendPacketToPlayer(pack)
  276.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 6
  277.             end
  278.         end
  279.         pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLtwo", 7500, 1)
  280.     end
  281. end
  282.  
  283. function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLtwo(pUnit)
  284.     local i = 0
  285.     while i ~= 15 do
  286.         i = i + 1
  287.         pUnit:SpawnCreature(AddF, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 280000)
  288.     end
  289.     if gateB ~= nil then
  290.         gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  291.         Open = true
  292.     end
  293.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 280000, 1)
  294.     pUnit:RegisterEvent("CHECK_FOR_DEAD_MALLEVENTaaassssffff", 10000, 0)
  295. end
  296.  
  297. function CHECK_FOR_DEAD_MALLEVENTaaassssffff(pUnit)
  298.     if Open then
  299.         if gateB ~= nil then
  300.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  301.             Open = false
  302.         end
  303.     end
  304.     if Dead > 54 then
  305.         pUnit:RemoveEvents()
  306.         Wave = Wave + 1
  307.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  308.             if plrs:GetPhase() == 2 then
  309.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  310.                 pack:WriteULong(2842) -- ID, total
  311.                 pack:WriteULong(Wave) -- Value
  312.                 plrs:SendPacketToPlayer(pack)
  313.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 7
  314.             end
  315.         end
  316.         pUnit:RegisterEvent("WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLgaga", 7500, 1)
  317.     end
  318. end
  319.  
  320. function WAIT_FOR_THE_RIGHT_MOMENT_DUN_DUN_DEFENDMALLgaga(pUnit)
  321.     local i = 0
  322.     while i ~= 4 do
  323.         i = i + 1
  324.         if math.random(1,2) == 1 then
  325.             pUnit:SpawnCreature(AddG, behindGateAX, behindGateAY, behindGateAZ , 0, 15, 480000)
  326.         else
  327.             pUnit:SpawnCreature(AddG, behindGateBX, behindGateBY, behindGateBZ , 0, 15, 480000)
  328.         end
  329.     end
  330.     if gateA ~= nil then
  331.         gateA:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  332.         Open = true
  333.     end
  334.     if gateB ~= nil then
  335.         gateB:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open
  336.         Open = true
  337.     end
  338.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 480000, 1)
  339.     pUnit:RegisterEvent("Check_For_mobDDeaths_Yarpgggggh", 10000, 0)
  340. end
  341.  
  342. function Check_For_mobDDeaths_Yarpgggggh(pUnit)
  343.     if Open then
  344.         if gateA ~= nil then
  345.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  346.             Open = false
  347.         end
  348.         if gateB ~= nil then
  349.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  350.             Open = false
  351.         end
  352.     end
  353.     if Dead > 59 then
  354.         pUnit:RemoveEvents()
  355.         Wave = Wave + 1
  356.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  357.             if plrs:GetPhase() == 2 then
  358.                 pack = LuaPacket:CreatePacket(SMSG_UPDATE_WORLD_STATE, 8)
  359.                 pack:WriteULong(2842) -- ID, total
  360.                 pack:WriteULong(Wave) -- Value
  361.                 plrs:SendPacketToPlayer(pack)
  362.                 pUnit:SendChatMessageToPlayer(42, 0, "Wave "..Wave.."!", plrs) -- 8
  363.             end
  364.         end
  365.         pUnit:RegisterEvent("FINALWAVE_DEFENDMALL", 8000, 1)
  366.     end
  367. end
  368.  
  369. function FINALWAVE_DEFENDMALL(pUnit)
  370.     local i = 0
  371.     local pla = nil
  372.     while i ~= 20 do
  373.         i = i + 1
  374.         pla = pUnit:GetRandomPlayer(0)
  375.         if pla ~= nil then
  376.             pUnit:SpawnCreature(AddH, pla:GetX(), pla:GetY(), pla:GetZ(), 0, 15, 300000)
  377.         end
  378.     end
  379.     pUnit:RegisterEvent("CHECK_FOR_WIPE_hurpdurpDEFENDMALL", 300000, 1)
  380.     pUnit:RegisterEvent("WAVES_COMPLETE_BOSS_DUNDUN", 10000, 0)
  381. end
  382.  
  383. function WAVES_COMPLETE_BOSS_DUNDUN(pUnit)
  384.     if Dead > 63 then
  385.         pUnit:RemoveEvents()
  386.         Wave = 1
  387.         Dead = 0
  388.         local Grill = pUnit:GetGameObjectNearestCoords(4522, 2769, 404, 201755) -- x,y,z,id
  389.         if Grill ~= nil then
  390.             Grill:SetByte(GAMEOBJECT_BYTES_1,0,0) -- Open Trap
  391.             pUnit:PlaySoundToSet(16541)
  392.             Grill:Despawn(30000, 10000)
  393.         end
  394.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  395.             if plrs:GetPhase() == 2 then
  396.                 pUnit:SendChatMessageToPlayer(42, 0, "The way to the boss is clear!", plrs)
  397.             end
  398.         end
  399.         pUnit:SpawnCreature(BossID, 4575, 2768, 361.3, 3.121345, 35, 0)
  400.         pUnit:RegisterEvent("Check_For_EventDEFENDMALL", 10000, 0) -- CanStart is not true yet
  401.     end
  402. end
  403.  
  404. --
  405.  
  406. function CHECK_FOR_WIPE_hurpdurpDEFENDMALL(pUnit)
  407.     pUnit:RemoveEvents()
  408.     Wave = 1
  409.     Dead = 0
  410.     if Open then
  411.         if gateA ~= nil then
  412.             gateA:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  413.             Open = false
  414.         end
  415.         if gateB ~= nil then
  416.             gateB:SetByte(GAMEOBJECT_BYTES_1,0,1) -- Close
  417.             Open = false
  418.         end
  419.     end
  420.     pUnit:RegisterEvent("Check_For_EventDEFENDMALL", 10000, 0)
  421. end
  422.  
  423. ---------------------------------------------------------
  424. -- Add Scripts ------------------------------------------
  425. ---------------------------------------------------------
  426.  
  427. function Adds_OnSpawn_ohlol(pUnit, Event)
  428.     pUnit:SetPhase(2)
  429.     pUnit:SetMovementFlags(1)
  430.     pUnit:RegisterEvent("SetFaction_Hostile_After_Gate", 2500, 1)
  431.     if pUnit:GetEntry() == AddC then
  432.         pUnit:RegisterEvent("Cast_ADDC_DEFENDMALL", math.random(6000, 12000), 0)
  433.     elseif pUnit:GetEntry() == AddG then
  434.         pUnit:RegisterEvent("CastSoekks_DEFENDMALL", math.random(2000, 12000), 1)
  435.     elseif pUnit:GetEntry() == AddH then
  436.         pUnit:RegisterEvent("SPawnVisual_teoaj", math.random(250, 1000), 1)
  437.     end
  438. end
  439.  
  440. function SetFaction_Hostile_After_Gate(pUnit)
  441.     pUnit:SetPhase(2) -- Just in case
  442.     pUnit:SetMovementFlags(1)
  443.     pUnit:SetFaction(21)
  444.     if math.random(1,2) == 1 then
  445.         pUnit:MoveTo(locA+math.random(0,2),locB-math.random(0,2),locC,0)
  446.     else
  447.         pUnit:MoveTo(locX-math.random(0,2),locY+math.random(0,2),locZ,0)
  448.     end
  449. end
  450.  
  451. function Adds_OnDead_Ohlol(pUnit)
  452.     pUnit:RemoveEvents()
  453.     Dead = Dead + 1
  454.     --pUnit:Despawn(10,0) -- bugs
  455. end
  456.  
  457. function Cast_ADDC_DEFENDMALL(pUnit)
  458.     pUnit:FullCastSpell(36132) -- Normal damage + 300 for two strong adds
  459. end
  460.  
  461. function CastSoekks_DEFENDMALL(pUnit)
  462.     pUnit:CastSpell(15636) -- Avatar of flame
  463. end
  464.  
  465. function SPawnVisual_teoaj(pUnit)
  466.     pUnit:CastSpell(64446) -- Teleport visual
  467. end
  468.  
  469. RegisterUnitEvent(AddA, 18, "Adds_OnSpawn_ohlol")
  470. RegisterUnitEvent(AddB, 18, "Adds_OnSpawn_ohlol")
  471. RegisterUnitEvent(AddC, 18, "Adds_OnSpawn_ohlol")
  472. RegisterUnitEvent(AddD, 18, "Adds_OnSpawn_ohlol")
  473. RegisterUnitEvent(AddE, 18, "Adds_OnSpawn_ohlol")
  474. RegisterUnitEvent(AddF, 18, "Adds_OnSpawn_ohlol")
  475. RegisterUnitEvent(AddG, 18, "Adds_OnSpawn_ohlol")
  476. RegisterUnitEvent(AddH, 18, "Adds_OnSpawn_ohlol")
  477.  
  478. RegisterUnitEvent(AddA, 4, "Adds_OnDead_Ohlol")
  479. RegisterUnitEvent(AddB, 4, "Adds_OnDead_Ohlol")
  480. RegisterUnitEvent(AddC, 4, "Adds_OnDead_Ohlol")
  481. RegisterUnitEvent(AddD, 4, "Adds_OnDead_Ohlol")
  482. RegisterUnitEvent(AddE, 4, "Adds_OnDead_Ohlol")
  483. RegisterUnitEvent(AddF, 4, "Adds_OnDead_Ohlol")
  484. RegisterUnitEvent(AddG, 4, "Adds_OnDead_Ohlol")
  485. RegisterUnitEvent(AddH, 4, "Adds_OnDead_Ohlol")
  486.  
  487. ---------------------------------------------------------
  488. -- Boss -------------------------------------------------
  489. ---------------------------------------------------------
  490.  
  491. function BOSS_ONDEATH_HURPDURP(pUnit)
  492.     pUnit:RemoveEvents()
  493.     pUnit:SendChatMessage(12,0,"Death... Is only the beginning.")
  494. end
  495.  
  496. function BOSS_ONLEAVE_HURPDURP(pUnit)
  497.     pUnit:RemoveEvents()
  498. end
  499.  
  500. function Boss_ONSPAWN_DEFENDMALL(pUnit)
  501.     pUnit:SetPhase(2)
  502.     pUnit:RegisterEvent("CheckFOrPlayers_HUtoayp", 2500, 0)
  503. end
  504.  
  505. function CheckFOrPlayers_HUtoayp(pUnit)
  506.     local plr = pUnit:GetClosestPlayer()
  507.     if plr ~= nil then
  508.         if plr:GetPhase() == 2 then
  509.             if pUnit:GetDistanceYards(plr) < 12 then
  510.                 pUnit:RemoveEvents()
  511.                 pUnit:SendChatMessage(12,0,"Welcome all, salutations are in order. My name is Arugal and unfortunately, you appear to be on tonights menu.")
  512.                 pUnit:MoveTo(4552.8, 2769.2, 351.4, 3)
  513.                 pUnit:EquipWeapons(18842, 0, 0)
  514.                 pUnit:RegisterEvent("WalkingDownStairs_DEFENDMALL", 11000, 1)
  515.             end
  516.         end
  517.     end
  518. end
  519.  
  520. function WalkingDownStairs_DEFENDMALL(pUnit)
  521.     pUnit:SendChatMessage(12,0,"Let me tenderise you all.")
  522.     pUnit:Emote(1,3000)
  523.     pUnit:RegisterEvent("Delay_A_Moment_GPOAJ", 4000, 1)
  524. end
  525.  
  526. function Delay_A_Moment_GPOAJ(pUnit)
  527.     pUnit:CastSpell(29880) -- Mana shield
  528.     pUnit:Root()
  529.     pUnit:SetFaction(21)
  530.     local plr = nil
  531.     local i = 0
  532.     while i ~= 10 do
  533.         i = i + 1
  534.         plr = pUnit:GetRandomPlayer(0)
  535.         if plr ~= nil then
  536.             if plr:GetPhase() == 2 then
  537.                 pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
  538.                 pUnit:CastSpellOnTarget(7124, plr) -- Damage
  539.             end
  540.         end
  541.     end
  542.     pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  543.     pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  544.     pUnit:RegisterEvent("CheckForManaPCTPCTPCT", 2500, 0)
  545. end
  546.  
  547. function Shadowbolt_Spam_Three_Argual(pUnit)
  548.     local plr = pUnit:GetRandomPlayer(0)
  549.     if plr ~= nil then
  550.         if plr:GetPhase() == 2 then
  551.             if math.random(1,2) == 1 then
  552.                 pUnit:FullCastSpellOnTarget(12739, plr) -- shadowbolt
  553.             else
  554.                 pUnit:FullCastSpell(39082) -- shadowfury
  555.             end
  556.         end
  557.     end
  558. end
  559.  
  560. function VolleyOfShadowbolts(pUnit)
  561.     pUnit:CastSpell(29166) -- Innervate
  562.     local plr = nil
  563.     local i = 0
  564.     while i ~= 10 do
  565.         i = i + 1
  566.         plr = pUnit:GetRandomPlayer(0)
  567.         if plr ~= nil then
  568.             if plr:GetPhase() == 2 then
  569.                 pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
  570.             end
  571.         end
  572.     end
  573. end
  574.  
  575. function CheckForManaPCTPCTPCT(pUnit)
  576.     if pUnit:GetManaPct() < 86 then
  577.         pUnit:RemoveEvents()
  578.         pUnit:SendChatMessage(12,0,"You're still underdone. Let me see if I can speed up the process.")
  579.         pUnit:Unroot()
  580.         pUnit:SetCombatCapable(1)
  581.         pUnit:SetMovementFlags(1) -- Run
  582.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  583.             plrs:CastSpell(52989) -- Stun
  584.         end
  585.         pUnit:MoveTo(4522.8, 2679, 352, 0)
  586.         pUnit:RegisterEvent("ResetPlayershurpdurp", 5000, 1)
  587.     end
  588. end
  589.  
  590. function ResetPlayershurpdurp(pUnit)
  591.     pUnit:MoveTo(4522.8, 2679, 352, 0)
  592.     pUnit:Root()
  593.     pUnit:SetCombatCapable(0)
  594.     for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  595.         plrs:RemoveAura(52989) -- Stun
  596.     end
  597.     pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  598.     pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  599.     pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  600.     pUnit:RegisterEvent("FlyPhaseDUndundun", 5000, 0)
  601.     pUnit:RegisterEvent("LightningVisual_DEFENDMALL", 6397, 0)
  602.    
  603. end
  604.  
  605. function LightningVisual_DEFENDMALL(pUnit)
  606.     local plz = pUnit:GetRandomPlayer(0)
  607.     if plz ~= nil then
  608.         pUnit:CastSpellOnTarget(37848, plz)
  609.         pUnit:FullCastSpell(17228)
  610.     end
  611.     plz = pUnit:GetClosestPlayer()
  612.     if plz ~= nil then
  613.         if pUnit:GetDistanceYards(plz) < 10 then
  614.             pUnit:CastSpellOnTarget(24199,plz)
  615.         end
  616.     end
  617. end
  618.  
  619. function Stoneharry_FireLines(pUnit)
  620.     -- So we are random timer each time
  621.     pUnit:RegisterEvent("Stoneharry_FireLines", math.random(4000, 10000), 1)
  622.     -- We have four directions in which to go in
  623.     local choice = math.random(1,4)
  624.     if choice == 1 then
  625.         -- Direction 1
  626.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY(), pUnit:GetZ(), 0, 21, 4500)
  627.         zX = pUnit:GetX()+5
  628.         -- Keep them spawning in the line
  629.         pUnit:RegisterEvent("Keep_spawning_fires_in_a_line", 750, 5)
  630.     elseif choice == 2 then
  631.         pUnit:SpawnCreature(FIRE, pUnit:GetX(), pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  632.         zX = pUnit:GetY()+5
  633.         pUnit:RegisterEvent("zKeep_spawning_fires_in_a_line", 750, 5)
  634.     elseif choice == 3 then
  635.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  636.         zX = pUnit:GetY()+5
  637.         zY = pUnit:GetX()+5
  638.         pUnit:RegisterEvent("zzKeep_spawning_fires_in_a_line", 750, 5) 
  639.     elseif choice == 4 then
  640.         pUnit:SpawnCreature(FIRE, pUnit:GetX()-5, pUnit:GetY()-5, pUnit:GetZ(), 0, 21, 4500)
  641.         zX = pUnit:GetY()-5
  642.         zY = pUnit:GetX()-5
  643.         pUnit:RegisterEvent("zzzKeep_spawning_fires_in_a_line", 750, 5)
  644.     elseif choice == 5 then
  645.         pUnit:SpawnCreature(FIRE, pUnit:GetX()-5, pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  646.         zX = pUnit:GetY()+5
  647.         zY = pUnit:GetX()-5
  648.         pUnit:RegisterEvent("zzzzKeep_spawning_fires_in_a_line", 750, 5)   
  649.     elseif choice == 5 then
  650.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY()-5, pUnit:GetZ(), 0, 21, 4500)
  651.         zX = pUnit:GetY()-5
  652.         zY = pUnit:GetX()+5
  653.         pUnit:RegisterEvent("zzzzzKeep_spawning_fires_in_a_line", 750, 5)  
  654.     end
  655. end
  656.  
  657. function Keep_spawning_fires_in_a_line(pUnit)
  658.     zX = zX + 5 -- left
  659.     pUnit:SpawnCreature(FIRE, zX, pUnit:GetY(), pUnit:GetZ(), 0, 21, 5000) 
  660. end
  661.  
  662. function zKeep_spawning_fires_in_a_line(pUnit)
  663.     zX = zX + 5 -- Right
  664.     pUnit:SpawnCreature(FIRE, pUnit:GetX(), zX, pUnit:GetZ(), 0, 21, 5000) 
  665. end
  666.  
  667. function zzKeep_spawning_fires_in_a_line(pUnit)
  668.     zX = zX + 5 -- Up
  669.     zY = zY + 5 -- Up
  670.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  671. end
  672.  
  673. function zzzKeep_spawning_fires_in_a_line(pUnit)
  674.     zX = zX - 5 -- Down
  675.     zY = zY - 5 -- Down
  676.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  677. end
  678.  
  679. function zzzzKeep_spawning_fires_in_a_line(pUnit)
  680.     zX = zX - 5
  681.     zY = zY + 5
  682.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  683. end
  684.  
  685. function zzzzzKeep_spawning_fires_in_a_line(pUnit)
  686.     zX = zX + 5 -- Down
  687.     zY = zY - 5 -- Down
  688.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  689. end
  690.  
  691. function FlyPhaseDUndundun(pUnit)
  692.     if pUnit:GetManaPct() < 50 then
  693.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  694.             plrs:EnableFlight(true)
  695.         end
  696.         pUnit:CastSpell(29166) -- Innervate
  697.         pUnit:RemoveEvents()
  698.         pUnit:SendChatMessage(12,0,"I think you would taste better overdone afterall!")
  699.         pUnit:Unroot()
  700.         pUnit:SetMovementFlags(2)
  701.         pUnit:SetCombatCapable(1)
  702.         pUnit:CastSpell(41918) -- Visual
  703.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+8, 0)
  704.         pUnit:SendChatMessage(42,0,"You can now fly!")
  705.         pUnit:RegisterEvent("CheckHealthTROLOLOL", 5000, 0)
  706.         pUnit:RegisterEvent("FixtateMovement", 1000, 1)
  707.         pUnit:RegisterEvent("messup_Stoneharry", 5500, 0)
  708.         pUnit:RegisterEvent("Stoneharry_FireLines", 5000, 1)
  709.         pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  710.         pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  711.     end
  712. end
  713.  
  714. function FixtateMovement(pUnit)
  715.     pUnit:SetCombatCapable(0)
  716.     pUnit:Root()
  717. end
  718.  
  719. function messup_Stoneharry(pUnit)
  720.     local plrA = pUnit:GetRandomPlayer(0) -- Get two players
  721.     local plrB = pUnit:GetRandomPlayer(0) -- Get two players
  722.     if plrA ~= nil and plrB ~= nil then   -- Make sure we did return somebody in the fight
  723.         if plrA == plrB then -- Make sure they are not the same person
  724.             local plrB = pUnit:GetRandomPlayer(0) -- Try again
  725.             if plrA == plrB then -- You better not be the same person
  726.                 plrB = pUnit:GetClosestPlayer() -- That's it, someone more reliable
  727.             end
  728.         end
  729.         plrA:CancelSpell()
  730.         plrB:CancelSpell() -- Stop casting
  731.         plrA:SetPosition(plrB:GetX(), plrB:GetY(), plrB:GetZ(), plrB:GetO()) -- Switch players, muhahaha
  732.         plrB:SetPosition(plrA:GetX(), plrA:GetY(), plrA:GetZ(), plrA:GetO())
  733.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrB:GetName().."!", plrA)
  734.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrA:GetName().."!", plrB)
  735.         plrA:CastSpell(64446) -- Teleport visual
  736.         plrB:CastSpell(64446)
  737.     end
  738. end
  739.  
  740. function CheckHealthTROLOLOL(pUnit)
  741.     if pUnit:GetManaPct() < 2 then
  742.         pUnit:SetMana(pUnit:GetMaxMana())
  743.         pUnit:CastSpell(29166) -- Innervate
  744.         pUnit:RemoveEvents()
  745.         pUnit:SetMovementFlags(1)
  746.         pUnit:Unroot()
  747.         pUnit:RemoveAura(29880) -- Mana shield
  748.         pUnit:SetCombatCapable(0)
  749.         pUnit:SendChatMessage(12,0,"Shaken, not stirred.")
  750.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  751.             plrs:EnableFlight(false)
  752.         end
  753.         pUnit:RegisterEvent("nomanaleft_malldefense", 5000, 0)
  754.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  755.     end
  756. end
  757.  
  758. function MINDCONTROLLLLLLL(pUnit)
  759.     local plr = pUnit:GetRandomPlayer(0)
  760.     if plr ~= nil then
  761.         if plr:GetPhase() == 2 then
  762.             plr:SetPlayerLock(1)
  763.             pUnit:Root()
  764.             plr:SetFaction(21)
  765.             pUnit:ChannelSpell(60452, plr)
  766.             plr:FullCastSpell(39082) -- shadowfury
  767.             RegisterTimedEvent("RESETPUNITANDPLAYER_DEFENDMALL", 3000, 1, pUnit, plr)
  768.         end
  769.     end
  770. end
  771.  
  772. function RESETPUNITANDPLAYER_DEFENDMALL(pUnit, plr)
  773.     if plr ~= nil then
  774.         plr:SetPlayerLock(0)
  775.         local race = plr:GetPlayerRace()
  776.         if race == 1 or race == 3 or race == 4 or race == 7 or race == 11 then -- alliance
  777.             plr:SetFaction(1)
  778.         else
  779.             plr:SetFaction(2)
  780.         end
  781.         pUnit:Unroot()
  782.         pUnit:StopChannel()
  783.     end
  784. end
  785.  
  786. function nomanaleft_malldefense(pUnit)
  787.     if pUnit:GetHealthPct() < 80 then
  788.         pUnit:RemoveEvents()
  789.         pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  790.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  791.         pUnit:SendChatMessage(12,0,"You appear to have escaped a roasted end, however, I am afraid I will have to put you out of your misery. Livestock must not be released.")
  792.     end
  793. end
  794.  
  795. RegisterUnitEvent(BossID, 18, "Boss_ONSPAWN_DEFENDMALL")
  796. RegisterUnitEvent(BossID, 4, "BOSS_ONDEATH_HURPDURP")
  797. RegisterUnitEvent(BossID, 2, "BOSS_ONLEAVE_HURPDURP")
  798.  
  799. ---------------------------------------------------------
  800.  
  801. function Fire_Visuals_Stoneharry(pUnit, event)
  802.     pUnit:Root()
  803.     pUnit:SetPhase(2)
  804.     pUnit:SetCombatCapable(1)
  805.     pUnit:RegisterEvent("WAIT_A_SEC_SEC_SEC", 1000, 1)
  806. end
  807.  
  808. function WAIT_A_SEC_SEC_SEC(pUnit, Event)
  809.     pUnit:Root() -- On spawn doesn't always trigger properly, so we'll do it again to be safe
  810.     pUnit:SetCombatCapable(1)
  811.     pUnit:CastSpell(74713) -- Visual
  812.     pUnit:RegisterEvent("zzzWAIT_A_SEC_SEC_SEC", math.random(500,1000), 5) -- To give a bit of variety
  813. end
  814.  
  815. function zzzWAIT_A_SEC_SEC_SEC(pUnit, Event)
  816.     pUnit:CastSpell(1449) -- Visual and damage
  817. end
  818.  
  819. RegisterUnitEvent(FIRE, 18, "Fire_Visuals_Stoneharry")
  820.  
  821. ---------------------------------------------------------
  822.  
  823. --[[
  824.     Debug Below
  825.         Comment out later
  826. ]]
  827.  
  828. function OnChat_Hook_ToJoinBG(event, plr, message, pType, pLanguage, pMisc)
  829.     local message = string.lower(message)
  830.     if message == "#start" then
  831.         CanStart = true
  832.     end
  833. end
  834.  
  835. RegisterServerHook(16, "OnChat_Hook_ToJoinBG")
  836.  
  837. ---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment