stoneharry

Untitled

Apr 2nd, 2011
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.91 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.             if plrs:GetPhase() == 2 then
  584.                 plrs:CastSpell(46416) -- Stun
  585.             end
  586.         end
  587.         pUnit:MoveTo(4522.52, 2769.3, 351.5, 0)
  588.         pUnit:RegisterEvent("ResetPlayershurpdurp", 5000, 1)
  589.     end
  590. end
  591.  
  592. function ResetPlayershurpdurp(pUnit)
  593.     pUnit:MoveTo(4522.52, 2769.3, 351.5, 0)
  594.     pUnit:Root()
  595.     pUnit:SetCombatCapable(0)
  596.     for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  597.         if plrs:GetPhase() == 2 then
  598.             plrs:RemoveAura(46416) -- Stun
  599.         end
  600.     end
  601.     pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  602.     pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  603.     pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  604.     pUnit:RegisterEvent("FlyPhaseDUndundun", 5000, 0)
  605.     pUnit:RegisterEvent("LightningVisual_DEFENDMALL", 6397, 0)
  606.    
  607. end
  608.  
  609. function LightningVisual_DEFENDMALL(pUnit)
  610.     local plz = pUnit:GetRandomPlayer(0)
  611.     if plz ~= nil then
  612.         pUnit:CastSpellOnTarget(37848, plz)
  613.         pUnit:FullCastSpell(17228)
  614.     end
  615.     plz = pUnit:GetClosestPlayer()
  616.     if plz ~= nil then
  617.         if pUnit:GetDistanceYards(plz) < 10 then
  618.             pUnit:CastSpellOnTarget(24199,plz)
  619.         end
  620.     end
  621. end
  622.  
  623. function Stoneharry_FireLines(pUnit)
  624.     -- So we are random timer each time
  625.     pUnit:RegisterEvent("Stoneharry_FireLines", math.random(4000, 10000), 1)
  626.     -- We have four directions in which to go in
  627.     local choice = math.random(1,4)
  628.     if choice == 1 then
  629.         -- Direction 1
  630.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY(), pUnit:GetZ(), 0, 21, 4500)
  631.         zX = pUnit:GetX()+5
  632.         -- Keep them spawning in the line
  633.         pUnit:RegisterEvent("Keep_spawning_fires_in_a_line", 750, 5)
  634.     elseif choice == 2 then
  635.         pUnit:SpawnCreature(FIRE, pUnit:GetX(), pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  636.         zX = pUnit:GetY()+5
  637.         pUnit:RegisterEvent("zKeep_spawning_fires_in_a_line", 750, 5)
  638.     elseif choice == 3 then
  639.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  640.         zX = pUnit:GetY()+5
  641.         zY = pUnit:GetX()+5
  642.         pUnit:RegisterEvent("zzKeep_spawning_fires_in_a_line", 750, 5) 
  643.     elseif choice == 4 then
  644.         pUnit:SpawnCreature(FIRE, pUnit:GetX()-5, pUnit:GetY()-5, pUnit:GetZ(), 0, 21, 4500)
  645.         zX = pUnit:GetY()-5
  646.         zY = pUnit:GetX()-5
  647.         pUnit:RegisterEvent("zzzKeep_spawning_fires_in_a_line", 750, 5)
  648.     elseif choice == 5 then
  649.         pUnit:SpawnCreature(FIRE, pUnit:GetX()-5, pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  650.         zX = pUnit:GetY()+5
  651.         zY = pUnit:GetX()-5
  652.         pUnit:RegisterEvent("zzzzKeep_spawning_fires_in_a_line", 750, 5)   
  653.     elseif choice == 5 then
  654.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY()-5, pUnit:GetZ(), 0, 21, 4500)
  655.         zX = pUnit:GetY()-5
  656.         zY = pUnit:GetX()+5
  657.         pUnit:RegisterEvent("zzzzzKeep_spawning_fires_in_a_line", 750, 5)  
  658.     end
  659. end
  660.  
  661. function Keep_spawning_fires_in_a_line(pUnit)
  662.     zX = zX + 5 -- left
  663.     pUnit:SpawnCreature(FIRE, zX, pUnit:GetY(), pUnit:GetZ(), 0, 21, 5000) 
  664. end
  665.  
  666. function zKeep_spawning_fires_in_a_line(pUnit)
  667.     zX = zX + 5 -- Right
  668.     pUnit:SpawnCreature(FIRE, pUnit:GetX(), zX, pUnit:GetZ(), 0, 21, 5000) 
  669. end
  670.  
  671. function zzKeep_spawning_fires_in_a_line(pUnit)
  672.     zX = zX + 5 -- Up
  673.     zY = zY + 5 -- Up
  674.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  675. end
  676.  
  677. function zzzKeep_spawning_fires_in_a_line(pUnit)
  678.     zX = zX - 5 -- Down
  679.     zY = zY - 5 -- Down
  680.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  681. end
  682.  
  683. function zzzzKeep_spawning_fires_in_a_line(pUnit)
  684.     zX = zX - 5
  685.     zY = zY + 5
  686.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  687. end
  688.  
  689. function zzzzzKeep_spawning_fires_in_a_line(pUnit)
  690.     zX = zX + 5 -- Down
  691.     zY = zY - 5 -- Down
  692.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  693. end
  694.  
  695. function FlyPhaseDUndundun(pUnit)
  696.     if pUnit:GetManaPct() < 50 then
  697.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  698.             plrs:EnableFlight(true)
  699.         end
  700.         pUnit:CastSpell(29166) -- Innervate
  701.         pUnit:RemoveEvents()
  702.         pUnit:SendChatMessage(12,0,"I think you would taste better overdone afterall!")
  703.         pUnit:Unroot()
  704.         pUnit:SetMovementFlags(2)
  705.         pUnit:SetCombatCapable(1)
  706.         pUnit:CastSpell(41918) -- Visual
  707.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+8, 0)
  708.         pUnit:SendChatMessage(42,0,"You can now fly!")
  709.         pUnit:RegisterEvent("CheckHealthTROLOLOL", 5000, 0)
  710.         pUnit:RegisterEvent("FixtateMovement", 1000, 1)
  711.         pUnit:RegisterEvent("messup_Stoneharry", 5500, 0)
  712.         pUnit:RegisterEvent("Stoneharry_FireLines", 5000, 1)
  713.         pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  714.         pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  715.     end
  716. end
  717.  
  718. function FixtateMovement(pUnit)
  719.     pUnit:SetCombatCapable(0)
  720.     pUnit:Root()
  721. end
  722.  
  723. function messup_Stoneharry(pUnit)
  724.     local plrA = pUnit:GetRandomPlayer(0) -- Get two players
  725.     local plrB = pUnit:GetRandomPlayer(0) -- Get two players
  726.     if plrA ~= nil and plrB ~= nil then   -- Make sure we did return somebody in the fight
  727.         if plrA == plrB then -- Make sure they are not the same person
  728.             local plrB = pUnit:GetRandomPlayer(0) -- Try again
  729.             if plrA == plrB then -- You better not be the same person
  730.                 plrB = pUnit:GetClosestPlayer() -- That's it, someone more reliable
  731.             end
  732.         end
  733.         plrA:CancelSpell()
  734.         plrB:CancelSpell() -- Stop casting
  735.         plrA:SetPosition(plrB:GetX(), plrB:GetY(), plrB:GetZ(), plrB:GetO()) -- Switch players, muhahaha
  736.         plrB:SetPosition(plrA:GetX(), plrA:GetY(), plrA:GetZ(), plrA:GetO())
  737.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrB:GetName().."!", plrA)
  738.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrA:GetName().."!", plrB)
  739.         plrA:CastSpell(64446) -- Teleport visual
  740.         plrB:CastSpell(64446)
  741.     end
  742. end
  743.  
  744. function CheckHealthTROLOLOL(pUnit)
  745.     if pUnit:GetManaPct() < 2 then
  746.         pUnit:SetMana(pUnit:GetMaxMana())
  747.         pUnit:CastSpell(29166) -- Innervate
  748.         pUnit:RemoveEvents()
  749.         pUnit:SetMovementFlags(1)
  750.         pUnit:Unroot()
  751.         pUnit:RemoveAura(29880) -- Mana shield
  752.         pUnit:SetCombatCapable(0)
  753.         pUnit:SendChatMessage(12,0,"Shaken, not stirred.")
  754.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  755.             plrs:EnableFlight(false)
  756.         end
  757.         pUnit:RegisterEvent("nomanaleft_malldefense", 5000, 0)
  758.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  759.     end
  760. end
  761.  
  762. function MINDCONTROLLLLLLL(pUnit)
  763.     local plr = pUnit:GetRandomPlayer(0)
  764.     if plr ~= nil then
  765.         if plr:GetPhase() == 2 then
  766.             plr:SetPlayerLock(1)
  767.             pUnit:Root()
  768.             plr:SetFaction(21)
  769.             pUnit:ChannelSpell(60452, plr)
  770.             plr:FullCastSpell(39082) -- shadowfury
  771.             RegisterTimedEvent("RESETPUNITANDPLAYER_DEFENDMALL", 3000, 1, pUnit, plr)
  772.         end
  773.     end
  774. end
  775.  
  776. function RESETPUNITANDPLAYER_DEFENDMALL(pUnit, plr)
  777.     if plr ~= nil then
  778.         plr:SetPlayerLock(0)
  779.         local race = plr:GetPlayerRace()
  780.         if race == 1 or race == 3 or race == 4 or race == 7 or race == 11 then -- alliance
  781.             plr:SetFaction(1)
  782.         else
  783.             plr:SetFaction(2)
  784.         end
  785.         pUnit:Unroot()
  786.         pUnit:StopChannel()
  787.     end
  788. end
  789.  
  790. function nomanaleft_malldefense(pUnit)
  791.     if pUnit:GetHealthPct() < 80 then
  792.         pUnit:RemoveEvents()
  793.         pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  794.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  795.         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.")
  796.     end
  797. end
  798.  
  799. RegisterUnitEvent(BossID, 18, "Boss_ONSPAWN_DEFENDMALL")
  800. RegisterUnitEvent(BossID, 4, "BOSS_ONDEATH_HURPDURP")
  801. RegisterUnitEvent(BossID, 2, "BOSS_ONLEAVE_HURPDURP")
  802.  
  803. ---------------------------------------------------------
  804.  
  805. function Fire_Visuals_Stoneharry(pUnit, event)
  806.     pUnit:Root()
  807.     pUnit:SetPhase(2)
  808.     pUnit:SetCombatCapable(1)
  809.     pUnit:RegisterEvent("WAIT_A_SEC_SEC_SEC", 1000, 1)
  810. end
  811.  
  812. function WAIT_A_SEC_SEC_SEC(pUnit, Event)
  813.     pUnit:Root() -- On spawn doesn't always trigger properly, so we'll do it again to be safe
  814.     pUnit:SetCombatCapable(1)
  815.     pUnit:CastSpell(74713) -- Visual
  816.     pUnit:RegisterEvent("zzzWAIT_A_SEC_SEC_SEC", math.random(500,1000), 5) -- To give a bit of variety
  817. end
  818.  
  819. function zzzWAIT_A_SEC_SEC_SEC(pUnit, Event)
  820.     pUnit:CastSpell(1449) -- Visual and damage
  821. end
  822.  
  823. RegisterUnitEvent(FIRE, 18, "Fire_Visuals_Stoneharry")
  824.  
  825. ---------------------------------------------------------
  826.  
  827. --[[
  828.     Debug Below
  829.         Comment out later
  830. ]]
  831.  
  832. function OnChat_Hook_ToJoinBG(event, plr, message, pType, pLanguage, pMisc)
  833.     local message = string.lower(message)
  834.     if message == "#start" then
  835.         CanStart = true
  836.     end
  837. end
  838.  
  839. RegisterServerHook(16, "OnChat_Hook_ToJoinBG")
  840.  
  841. ---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment