stoneharry

Untitled

Jun 23rd, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.42 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, 30000)
  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.     for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  495.         pack = LuaPacket:CreatePacket(SMSG_INIT_WORLD_STATES, 18) -- Waves remaining
  496.         pack:WriteULong(0) -- Map
  497.         pack:WriteULong(0) -- Zone
  498.         pack:WriteULong(0)
  499.         pack:WriteUShort(0)
  500.         pack:WriteULong(0) -- ID
  501.         pack:WriteULong(0) -- Value
  502.         plrs:SendPacketToPlayer(pack)
  503.     end
  504. end
  505.  
  506. function BOSS_ONLEAVE_HURPDURP(pUnit)
  507.     pUnit:RemoveEvents()
  508. end
  509.  
  510. function Boss_ONSPAWN_DEFENDMALL(pUnit)
  511.     pUnit:SetPhase(2)
  512.     pUnit:RegisterEvent("CheckFOrPlayers_HUtoayp", 2500, 0)
  513. end
  514.  
  515. function CheckFOrPlayers_HUtoayp(pUnit)
  516.     local plr = pUnit:GetClosestPlayer()
  517.     if plr ~= nil then
  518.         if plr:GetPhase() == 2 then
  519.             if pUnit:GetDistanceYards(plr) < 12 then
  520.                 pUnit:RemoveEvents()
  521.                 pUnit:SendChatMessage(12,0,"Welcome all, salutations are in order. My name is Arugal and unfortunately, you appear to be on tonights menu.")
  522.                 pUnit:MoveTo(4552.8, 2769.2, 351.4, 3)
  523.                 pUnit:EquipWeapons(18842, 0, 0)
  524.                 pUnit:RegisterEvent("WalkingDownStairs_DEFENDMALL", 11000, 1)
  525.             end
  526.         end
  527.     end
  528. end
  529.  
  530. function WalkingDownStairs_DEFENDMALL(pUnit)
  531.     pUnit:SendChatMessage(12,0,"Let me tenderise you all.")
  532.     pUnit:Emote(1,3000)
  533.     pUnit:RegisterEvent("Delay_A_Moment_GPOAJ", 4000, 1)
  534. end
  535.  
  536. function Delay_A_Moment_GPOAJ(pUnit)
  537.     pUnit:CastSpell(29880) -- Mana shield
  538.     pUnit:Root()
  539.     pUnit:SetFaction(21)
  540.     local plr = nil
  541.     local i = 0
  542.     while i ~= 10 do
  543.         i = i + 1
  544.         plr = pUnit:GetRandomPlayer(0)
  545.         if plr ~= nil then
  546.             if plr:GetPhase() == 2 then
  547.                 pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
  548.                 pUnit:CastSpellOnTarget(7124, plr) -- Damage
  549.             end
  550.         end
  551.     end
  552.     pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  553.     pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  554.     pUnit:RegisterEvent("CheckForManaPCTPCTPCT", 2500, 0)
  555. end
  556.  
  557. function Shadowbolt_Spam_Three_Argual(pUnit)
  558.     local plr = pUnit:GetRandomPlayer(0)
  559.     if plr ~= nil then
  560.         if plr:GetPhase() == 2 then
  561.             if math.random(1,2) == 1 then
  562.                 pUnit:FullCastSpellOnTarget(12739, plr) -- shadowbolt
  563.             else
  564.                 pUnit:FullCastSpell(39082) -- shadowfury
  565.             end
  566.         end
  567.     end
  568. end
  569.  
  570. function VolleyOfShadowbolts(pUnit)
  571.     pUnit:CastSpell(29166) -- Innervate
  572.     local plr = nil
  573.     local i = 0
  574.     while i ~= 10 do
  575.         i = i + 1
  576.         plr = pUnit:GetRandomPlayer(0)
  577.         if plr ~= nil then
  578.             if plr:GetPhase() == 2 then
  579.                 pUnit:CastSpellOnTarget(52257, plr) -- Shadowbolt
  580.             end
  581.         end
  582.     end
  583. end
  584.  
  585. function CheckForManaPCTPCTPCT(pUnit)
  586.     if pUnit:GetManaPct() < 86 then
  587.         pUnit:RemoveEvents()
  588.         pUnit:SendChatMessage(12,0,"You're still underdone. Let me see if I can speed up the process.")
  589.         pUnit:Unroot()
  590.         pUnit:SetCombatCapable(1)
  591.         pUnit:SetMovementFlags(1) -- Run
  592.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  593.             if plrs:GetPhase() == 2 then
  594.                 plrs:CastSpell(46416) -- Stun
  595.             end
  596.         end
  597.         pUnit:MoveTo(4522.52, 2769.3, 351.5, 0)
  598.         pUnit:RegisterEvent("ResetPlayershurpdurp", 5000, 1)
  599.     end
  600. end
  601.  
  602. function ResetPlayershurpdurp(pUnit)
  603.     pUnit:MoveTo(4522.52, 2769.3, 351.5, 0)
  604.     pUnit:Root()
  605.     pUnit:SetCombatCapable(0)
  606.     for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  607.         if plrs:GetPhase() == 2 then
  608.             plrs:RemoveAura(46416) -- Stun
  609.         end
  610.     end
  611.     pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  612.     pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  613.     pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  614.     pUnit:RegisterEvent("FlyPhaseDUndundun", 5000, 0)
  615.     pUnit:RegisterEvent("LightningVisual_DEFENDMALL", 6397, 0)
  616.    
  617. end
  618.  
  619. function LightningVisual_DEFENDMALL(pUnit)
  620.     local plz = pUnit:GetRandomPlayer(0)
  621.     if plz ~= nil then
  622.         pUnit:CastSpellOnTarget(37848, plz)
  623.         pUnit:FullCastSpell(17228)
  624.     end
  625.     plz = pUnit:GetClosestPlayer()
  626.     if plz ~= nil then
  627.         if pUnit:GetDistanceYards(plz) < 10 then
  628.             pUnit:CastSpellOnTarget(24199,plz)
  629.         end
  630.     end
  631. end
  632.  
  633. function Stoneharry_FireLines(pUnit)
  634.     -- So we are random timer each time
  635.     pUnit:RegisterEvent("Stoneharry_FireLines", math.random(4000, 10000), 1)
  636.     -- We have four directions in which to go in
  637.     local choice = math.random(1,4)
  638.     if choice == 1 then
  639.         -- Direction 1
  640.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY(), pUnit:GetZ(), 0, 21, 4500)
  641.         zX = pUnit:GetX()+5
  642.         -- Keep them spawning in the line
  643.         pUnit:RegisterEvent("Keep_spawning_fires_in_a_line", 750, 5)
  644.     elseif choice == 2 then
  645.         pUnit:SpawnCreature(FIRE, pUnit:GetX(), pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  646.         zX = pUnit:GetY()+5
  647.         pUnit:RegisterEvent("zKeep_spawning_fires_in_a_line", 750, 5)
  648.     elseif choice == 3 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("zzKeep_spawning_fires_in_a_line", 750, 5) 
  653.     elseif choice == 4 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("zzzKeep_spawning_fires_in_a_line", 750, 5)
  658.     elseif choice == 5 then
  659.         pUnit:SpawnCreature(FIRE, pUnit:GetX()-5, pUnit:GetY()+5, pUnit:GetZ(), 0, 21, 4500)
  660.         zX = pUnit:GetY()+5
  661.         zY = pUnit:GetX()-5
  662.         pUnit:RegisterEvent("zzzzKeep_spawning_fires_in_a_line", 750, 5)   
  663.     elseif choice == 5 then
  664.         pUnit:SpawnCreature(FIRE, pUnit:GetX()+5, pUnit:GetY()-5, pUnit:GetZ(), 0, 21, 4500)
  665.         zX = pUnit:GetY()-5
  666.         zY = pUnit:GetX()+5
  667.         pUnit:RegisterEvent("zzzzzKeep_spawning_fires_in_a_line", 750, 5)  
  668.     end
  669. end
  670.  
  671. function Keep_spawning_fires_in_a_line(pUnit)
  672.     zX = zX + 5 -- left
  673.     pUnit:SpawnCreature(FIRE, zX, pUnit:GetY(), pUnit:GetZ(), 0, 21, 5000) 
  674. end
  675.  
  676. function zKeep_spawning_fires_in_a_line(pUnit)
  677.     zX = zX + 5 -- Right
  678.     pUnit:SpawnCreature(FIRE, pUnit:GetX(), zX, pUnit:GetZ(), 0, 21, 5000) 
  679. end
  680.  
  681. function zzKeep_spawning_fires_in_a_line(pUnit)
  682.     zX = zX + 5 -- Up
  683.     zY = zY + 5 -- Up
  684.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  685. end
  686.  
  687. function zzzKeep_spawning_fires_in_a_line(pUnit)
  688.     zX = zX - 5 -- Down
  689.     zY = zY - 5 -- Down
  690.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  691. end
  692.  
  693. function zzzzKeep_spawning_fires_in_a_line(pUnit)
  694.     zX = zX - 5
  695.     zY = zY + 5
  696.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  697. end
  698.  
  699. function zzzzzKeep_spawning_fires_in_a_line(pUnit)
  700.     zX = zX + 5 -- Down
  701.     zY = zY - 5 -- Down
  702.     pUnit:SpawnCreature(FIRE, zY, zX, pUnit:GetZ(), 0, 21, 5000)   
  703. end
  704.  
  705. function FlyPhaseDUndundun(pUnit)
  706.     if pUnit:GetManaPct() < 50 then
  707.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  708.             plrs:EnableFlight(true)
  709.         end
  710.         pUnit:CastSpell(29166) -- Innervate
  711.         pUnit:RemoveEvents()
  712.         pUnit:SendChatMessage(12,0,"I think you would taste better overdone afterall!")
  713.         pUnit:Unroot()
  714.         pUnit:SetMovementFlags(2)
  715.         pUnit:SetCombatCapable(1)
  716.         pUnit:CastSpell(41918) -- Visual
  717.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+8, 0)
  718.         pUnit:SendChatMessage(42,0,"You can now fly!")
  719.         pUnit:RegisterEvent("CheckHealthTROLOLOL", 5000, 0)
  720.         pUnit:RegisterEvent("FixtateMovement", 1000, 1)
  721.         pUnit:RegisterEvent("messup_Stoneharry", 5500, 0)
  722.         pUnit:RegisterEvent("Stoneharry_FireLines", 5000, 1)
  723.         pUnit:RegisterEvent("Shadowbolt_Spam_Three_Argual", 3005, 0)
  724.         pUnit:RegisterEvent("VolleyOfShadowbolts", 7000, 0)
  725.     end
  726. end
  727.  
  728. function FixtateMovement(pUnit)
  729.     pUnit:SetCombatCapable(0)
  730.     pUnit:Root()
  731. end
  732.  
  733. function messup_Stoneharry(pUnit)
  734.     local plrA = pUnit:GetRandomPlayer(0) -- Get two players
  735.     local plrB = pUnit:GetRandomPlayer(0) -- Get two players
  736.     if plrA ~= nil and plrB ~= nil then   -- Make sure we did return somebody in the fight
  737.         if plrA == plrB then -- Make sure they are not the same person
  738.             local plrB = pUnit:GetRandomPlayer(0) -- Try again
  739.             if plrA == plrB then -- You better not be the same person
  740.                 plrB = pUnit:GetClosestPlayer() -- That's it, someone more reliable
  741.             end
  742.         end
  743.         plrA:CancelSpell()
  744.         plrB:CancelSpell() -- Stop casting
  745.         local aX = plrA:GetX()
  746.         local aY = plrA:GetY()
  747.         local aZ = plrA:GetZ()
  748.         local aO = plrA:GetO()
  749.         plrA:SetPosition(plrB:GetX(), plrB:GetY(), plrB:GetZ(), plrB:GetO()) -- Switch players, muhahaha
  750.         plrB:SetPosition(aX, aY, aZ, aO)
  751.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrB:GetName().."!", plrA)
  752.         pUnit:SendChatMessageToPlayer(42,0,"You have switches places with "..plrA:GetName().."!", plrB)
  753.         plrA:CastSpell(64446) -- Teleport visual
  754.         plrB:CastSpell(64446)
  755.     end
  756. end
  757.  
  758. function CheckHealthTROLOLOL(pUnit)
  759.     if pUnit:GetManaPct() < 2 then
  760.         pUnit:SetMana(pUnit:GetMaxMana())
  761.         pUnit:CastSpell(29166) -- Innervate
  762.         pUnit:RemoveEvents()
  763.         pUnit:SetMovementFlags(1)
  764.         pUnit:Unroot()
  765.         pUnit:RemoveAura(29880) -- Mana shield
  766.         pUnit:SetCombatCapable(0)
  767.         pUnit:SendChatMessage(12,0,"Shaken, not stirred.")
  768.         for place, plrs in pairs(pUnit:GetInRangePlayers()) do
  769.             plrs:EnableFlight(false)
  770.         end
  771.         pUnit:RegisterEvent("nomanaleft_malldefense", 5000, 0)
  772.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  773.     end
  774. end
  775.  
  776. function MINDCONTROLLLLLLL(pUnit)
  777.     local plr = pUnit:GetRandomPlayer(0)
  778.     if plr ~= nil then
  779.         if plr:GetPhase() == 2 then
  780.             plr:SetPlayerLock(1)
  781.             pUnit:Root()
  782.             plr:SetFaction(21)
  783.             pUnit:ChannelSpell(60452, plr)
  784.             plr:FullCastSpell(39082) -- shadowfury
  785.             RegisterTimedEvent("RESETPUNITANDPLAYER_DEFENDMALL", 3000, 1, pUnit, plr)
  786.         end
  787.     end
  788. end
  789.  
  790. function RESETPUNITANDPLAYER_DEFENDMALL(pUnit, plr)
  791.     if plr ~= nil then
  792.         plr:SetPlayerLock(0)
  793.         local race = plr:GetPlayerRace()
  794.         if race == 1 or race == 3 or race == 4 or race == 7 or race == 11 then -- alliance
  795.             plr:SetFaction(1)
  796.         else
  797.             plr:SetFaction(2)
  798.         end
  799.         pUnit:Unroot()
  800.         pUnit:StopChannel()
  801.     end
  802. end
  803.  
  804. function nomanaleft_malldefense(pUnit)
  805.     if pUnit:GetHealthPct() < 80 then
  806.         pUnit:RemoveEvents()
  807.         pUnit:RegisterEvent("Stoneharry_FireLines", 1000, 1)
  808.         pUnit:RegisterEvent("MINDCONTROLLLLLLL", 3005, 0)
  809.         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.")
  810.     end
  811. end
  812.  
  813. RegisterUnitEvent(BossID, 18, "Boss_ONSPAWN_DEFENDMALL")
  814. RegisterUnitEvent(BossID, 4, "BOSS_ONDEATH_HURPDURP")
  815. RegisterUnitEvent(BossID, 2, "BOSS_ONLEAVE_HURPDURP")
  816.  
  817. ---------------------------------------------------------
  818.  
  819. function Fire_Visuals_Stoneharry(pUnit, event)
  820.     pUnit:Root()
  821.     pUnit:SetPhase(2)
  822.     pUnit:SetCombatCapable(1)
  823.     pUnit:RegisterEvent("WAIT_A_SEC_SEC_SEC", 1000, 1)
  824. end
  825.  
  826. function WAIT_A_SEC_SEC_SEC(pUnit, Event)
  827.     pUnit:Root() -- On spawn doesn't always trigger properly, so we'll do it again to be safe
  828.     pUnit:SetCombatCapable(1)
  829.     pUnit:CastSpell(74713) -- Visual
  830.     pUnit:RegisterEvent("zzzWAIT_A_SEC_SEC_SEC", math.random(500,1000), 5) -- To give a bit of variety
  831. end
  832.  
  833. function zzzWAIT_A_SEC_SEC_SEC(pUnit, Event)
  834.     pUnit:CastSpell(1449) -- Visual and damage
  835. end
  836.  
  837. RegisterUnitEvent(FIRE, 18, "Fire_Visuals_Stoneharry")
  838.  
  839. ---------------------------------------------------------
  840.  
  841. --[[
  842.     Debug Below
  843.         Comment out later
  844. ]]
  845.  
  846. function OnChat_Hook_ToJoinBG(event, plr, message, pType, pLanguage, pMisc)
  847.     local message = string.lower(message)
  848.     if message == "#start" then
  849.         CanStart = true
  850.     end
  851. end
  852.  
  853. RegisterServerHook(16, "OnChat_Hook_ToJoinBG")
  854.  
  855. function ControlNPC_OnDeath(pUnit, Event)
  856.     CanStart = true
  857. end
  858.  
  859. RegisterUnitEvent(95341, 4, "ControlNPC_OnDeath")
  860.  
  861. ---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment