stoneharry

Untitled

Jul 28th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.70 KB | None | 0 0
  1.  
  2. ZG = {}
  3. ZG.VAR = {}
  4.  
  5. local OBJECT_END = 0x0006
  6. local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
  7. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  8. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  9. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
  10. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  11.  
  12. --[[
  13. 11250   A_TEMPEST_Zerek_Aggro01
  14. 11251   A_TEMPEST_Zerek_Slay01
  15. 11252   A_TEMPEST_Zerek_Slay02
  16. 11253   A_TEMPEST_Zerek_ShadowHell01
  17. 11254   A_TEMPEST_Zerek_ShadowHell02
  18. 11255   A_TEMPEST_Zerek_Death01
  19. ]]
  20.  
  21. -- Main boss
  22.  
  23. function ZG.VAR.MainBossSpawn(pUnit, Event)
  24.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  25.     pUnit:RegisterEvent("ZG.VAR.WaitForBossToLoad", 1000, 1)
  26. end
  27.  
  28. function ZG.VAR.WaitForBossToLoad(pUnit)
  29. --  pUnit:SetPosition(-11121.9, -2013.3, 147, 2.857928)
  30.     pUnit:SetScale(1.5)
  31.     pUnit:ChannelSpell(70358, pUnit) -- visual
  32.     pUnit:RegisterEvent("ZG.VAR.CheckForPlayers", 2500, 0)
  33. end
  34.  
  35. function ZG.VAR.CheckForPlayers(pUnit)
  36.     local plr = pUnit:GetClosestPlayer()
  37.     if plr ~= nil then
  38.         if pUnit:GetDistanceYards(plr) < 40 and plr:IsAlive() then
  39.             pUnit:RemoveEvents()
  40.             pUnit:StopChannel()
  41.             pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0.111894)
  42.             pUnit:SendChatMessage(14,0,"Life energy, to consume...")
  43.             pUnit:PlaySoundToSet(11250)
  44.             pUnit:RegisterEvent("ZG.VAR.BeginEventMainBoss", 3000, 1)
  45.         end
  46.     end
  47. end
  48.  
  49. function ZG.VAR.BeginEventMainBoss(pUnit)
  50.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
  51. end
  52.  
  53. RegisterUnitEvent(20738, 18, "ZG.VAR.MainBossSpawn")
  54.  
  55. --------------------------------------------------------
  56.  
  57. function ZG.VAR.MainBossHnadler(pUnit, Event)
  58.     if Event == 1 then
  59.         -- entered combat
  60.         pUnit:SetScale(1)
  61.         pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 7500, 0)
  62.         pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 7000, 0)
  63.         pUnit:RegisterEvent("ZG.VAR.MainTimeFreeze", 8000, 0)
  64.         pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 10000, 1)
  65.         pUnit:RegisterEvent("ZG.VAR.CheckForPhaseTwoMain", 2000, 0)
  66.     elseif Event == 2 then
  67.         -- Left combat
  68.         pUnit:RemoveEvents()
  69.         pUnit:RegisterEvent("ZG.VAR.MainBossSpawn", 6000, 1)
  70.     elseif Event == 3 then
  71.         -- killed someone
  72.     elseif Event == 4 then
  73.         -- Got killed
  74.         pUnit:RemoveEvents()
  75.         pUnit:PlaySoundToSet(11252)
  76.         pUnit:SendChatMessage(14,0,"No more life...")
  77.     end
  78. end
  79.  
  80. function ZG.VAR.MainGrowAndPwnStuff(pUnit)
  81.     pUnit:CastSpell(72679) -- Grow and shizzle
  82.     if math.random(1,2) == 1 then
  83.         pUnit:SendChatMessage(14,0,"Darkness consumes all.")
  84.         pUnit:PlaySoundToSet(11254)
  85.     else
  86.         pUnit:SendChatMessage(14,0,"The shadow will in cone you.")
  87.         pUnit:PlaySoundToSet(11253)
  88.     end
  89.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", math.random(18000, 35000), 1)
  90. end
  91.  
  92. function ZG.VAR.MainRandomVisuals(pUnit)
  93.     local plr = pUnit:GetRandomPlayer(0)
  94.     if plr ~= nil then
  95.         pUnit:CastSpellOnTarget(73539, plr) -- random visual
  96.     end
  97. end
  98.  
  99. function ZG.VAR.MainShadowCleave(pUnit)
  100.     local plr = pUnit:GetMainTank()
  101.     if plr ~= nil then
  102.         pUnit:FullCastSpellOnTarget(31629, plr)
  103.     end
  104. end
  105.  
  106. function ZG.VAR.MainTimeFreeze(pUnit)
  107.     local plr = pUnit:GetRandomPlayer(0)
  108.     if plr ~= nil then
  109.         pUnit:FullCastSpellOnTarget(40951, plr)
  110.     end
  111. end
  112.  
  113. function ZG.VAR.CheckForPhaseTwoMain(pUnit)
  114.     if pUnit:GetHealthPct() < 75 then
  115.         pUnit:RemoveEvents()
  116.         pUnit:SendChatMessage(14,0,"No more life.")
  117.         pUnit:PlaySoundToSet(11252)
  118.         pUnit:AIDisableCombat(true) -- Requires custom patch to work
  119.         pUnit:MoveTo(-11101, -2021, 147, 0)
  120.         pUnit:RegisterEvent("ZG.VAR.BringItOnMainBoss", 6000, 1)
  121.     end
  122. end
  123.  
  124. function ZG.VAR.BringItOnMainBoss(pUnit)
  125.     pUnit:ChannelSpell(12380, pUnit)
  126.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 1000, 0)
  127.     if pUnit:GetHealthPct() < 35 then
  128.         pUnit:RegisterEvent("ZG.VAR.MainEndVisualfinal", 15500, 1)
  129.     else
  130.         pUnit:RegisterEvent("ZG.VAR.MainEndVisual", 15500, 1)
  131.     end
  132. end
  133.  
  134. function ZG.VAR.MainEndVisual(pUnit)
  135.     pUnit:RemoveEvents()
  136.     pUnit:StopChannel()
  137.     pUnit:AIDisableCombat(false) -- Requires custom patch to work
  138.     -- Time to troll
  139.     local plr = pUnit:GetRandomPlayer(0)
  140.     if plr ~= nil then
  141.         pUnit:FullCastSpellOnTarget(40251, plr) -- kills them after 55 seconds
  142.     end
  143.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 7500, 0)
  144.     pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 7000, 0)
  145.     pUnit:RegisterEvent("ZG.VAR.MainDisoreitnate", 12000, 0)
  146.     pUnit:RegisterEvent("ZG.VAR.MainShroudGuys", 6000, 0)
  147.     pUnit:RegisterEvent("ZG.VAR.MainDeathGrip", 8000, 0)
  148.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 20000, 1)
  149.     pUnit:RegisterEvent("ZG.VAR.CheckForNextMainPhase", 2000, 0)
  150. end
  151.  
  152. function ZG.VAR.MainDisoreitnate(pUnit)
  153.     local plr = pUnit:GetClosestPlayer()
  154.     if plr ~= nil then
  155.         pUnit:FullCastSpellOnTarget(26108, plr) -- cause to run around randomly for 3 seconds
  156.     end
  157. end
  158.  
  159. function ZG.VAR.MainShroudGuys(pUnit)
  160.     local plr = pUnit:GetRandomPlayer(0)
  161.     if plr ~= nil then
  162.         plr:CastSpell(40251) -- shroud of darkness
  163.     end
  164. end
  165.  
  166. function ZG.VAR.MainDeathGrip(pUnit)
  167.     local plr = pUnit:GetRandomPlayer2(0)
  168.     if plr ~= nil then
  169.         pUnit:FullCastSpellOnTarget(64429, plr) -- visual
  170.         plr:MoveKnockback(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 10, 20)
  171.     end
  172. end
  173.  
  174. function ZG.VAR.CheckForNextMainPhase(pUnit)
  175.     if pUnit:GetHealthPct() < 35 then
  176.         pUnit:RemoveEvents()
  177.         pUnit:SendChatMessage(14,0,"No more life.")
  178.         pUnit:PlaySoundToSet(11252)
  179.         pUnit:AIDisableCombat(true) -- Requires custom patch to work
  180.         pUnit:MoveTo(-11101, -2021, 147, 0)
  181.         pUnit:RegisterEvent("ZG.VAR.BringItOnMainBoss", 6000, 1)
  182.     end
  183. end
  184.  
  185. function ZG.VAR.MainEndVisualfinal(pUnit)
  186.     pUnit:RemoveEvents()
  187.     pUnit:StopChannel()
  188.     pUnit:AIDisableCombat(false) -- Requires custom patch to work
  189.     -- Time to troll
  190.     local plr = pUnit:GetRandomPlayer(0)
  191.     if plr ~= nil then
  192.         pUnit:FullCastSpellOnTarget(40251, plr) -- kills them after 55 seconds
  193.     end
  194.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 9000, 0)
  195.     pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 8000, 0)
  196.     pUnit:RegisterEvent("ZG.VAR.MainDisoreitnate", 10000, 0)
  197.     pUnit:RegisterEvent("ZG.VAR.MainShroudGuys", 6000, 0)
  198.     pUnit:RegisterEvent("ZG.VAR.MainDeathGrip", 6000, 0)
  199.     pUnit:RegisterEvent("ZG.VAR.MainTimeFreeze", 10000, 0)
  200.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 10000, 1)
  201. end
  202.  
  203. RegisterUnitEvent(20738, 1, "ZG.VAR.MainBossHnadler")
  204. RegisterUnitEvent(20738, 2, "ZG.VAR.MainBossHnadler")
  205. RegisterUnitEvent(20738, 3, "ZG.VAR.MainBossHnadler")
  206. RegisterUnitEvent(20738, 4, "ZG.VAR.MainBossHnadler")
  207.  
  208. -- Void zones -- spawned from the spell impact
  209.  
  210. function ZG.VAR.VoidZoneSpawn(pUnit, Event)
  211.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
  212.     pUnit:Root()
  213.     pUnit:SetCombatCapable(false)
  214.     pUnit:RegisterEvent("ZG.VAR.SendVisualVoidZone", 250, 1)
  215.     pUnit:RegisterEvent("ZG.VAR.DamageNearbyZone", 1000, 0)
  216. end
  217.  
  218. function ZG.VAR.DamageNearbyZone(pUnit)
  219.     for k,plrs in pairs(pUnit:GetInRangePlayers()) do
  220.         if pUnit:GetDistanceYards(plrs) < 6 then
  221.             pUnit:Strike(plrs, 2, 695, 90, 100, 1)
  222.         end
  223.     end
  224. end
  225.  
  226. function ZG.VAR.SendVisualVoidZone(pUnit)
  227.     pUnit:FullCastSpell(73525)
  228.     if pUnit:GetMapId() == 37 then
  229.     else
  230.     pUnit:RegisterEvent("ZG.VAR.VoidZoneDespawn", 25500, 1)
  231. end
  232. end
  233.  
  234. function ZG.VAR.VoidZoneDespawn(pUnit)
  235.     pUnit:RemoveEvents()
  236.     pUnit:RemoveAura(73525)
  237.     pUnit:Despawn(1000, 0)
  238. end
  239.  
  240. RegisterUnitEvent(39137, 18, "ZG.VAR.VoidZoneSpawn")
  241.  
  242.  
  243.  --[[ FIRST BOSS
  244.  
  245.  11238 TEMPEST_WrthScryr_Aggro01.wav
  246.  
  247. 11239 TEMPEST_WrthScryr_Slay01.wav
  248.  
  249. 11240 TEMPEST_WrthScryr_Slay02.wav
  250.  
  251. 11241 TEMPEST_WrthScryr_FireChrg01.wav
  252.  
  253. 11242 TEMPEST_WrthScryr_FireChrg02.wav
  254.  
  255. 11243 TEMPEST_WrthScryr_Death01.wav
  256.  ]]
  257.  
  258.  function ZG.VAR.EXECUTIONER_WHIRLWIND(pUnit,Event)
  259.  pUnit:RemoveEvents()
  260.  pUnit:CastSpell(40653)
  261.  pUnit:AIDisableCombat(true)
  262.     if math.random(1,2) <= 1 then
  263.         pUnit:PlaySoundToSet(11241)
  264.         pUnit:SendChatMessage(14,0,"On guard!")
  265.         elseif math.random(1,2) <= 2 then
  266.         pUnit:PlaySoundToSet(11242)
  267.         pUnit:SendChatMessage(14,0,"Defend yourself, for all the good it will do...")
  268.         end
  269.  pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_MOVERANDOMSPOT", 3000, 3)
  270.   pUnit:RegisterEvent("ZG.VAR.SETAICOMBAT", 9000, 1)
  271.  end
  272.  
  273.  function ZG.VAR.SETAICOMBAT(pUnit,Event)
  274.  pUnit:AIDisableCombat(false)
  275.  pUnit:CancelSpell()
  276.  pUnit:RegisterEvent("ZG.VAR.EXECUTIONHANDLE", 3000, 0)
  277.   pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_WHIRLWIND", 16000, 0)
  278.     pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_NoOneInRange", 2000, 0)
  279.     pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_BLACKCLEAVE", 7000, 0)
  280.  end
  281.  
  282.  function ZG.VAR.EXECUTIONER_MOVERANDOMSPOT(pUnit,Event)
  283.  local player = pUnit:GetRandomPlayer(0)
  284. if player ~= nil then
  285. if pUnit:GetDistanceYards(player) < 20 then
  286.  pUnit:MoveTo(player:GetX(),player:GetY(),player:GetZ(),player:GetO())
  287.         end
  288.     end
  289. end
  290.  
  291.  function ZG.VAR.EXECUTIONER_NoOneInRange(pUnit,Event)
  292.  local player = pUnit:GetClosestPlayer()
  293.  if pUnit:GetDistanceYards(player) > 22 then
  294.  local PlayersAllAround = pUnit:GetInRangePlayers()
  295.                 for a, players in pairs(PlayersAllAround) do
  296.                  if pUnit:GetDistanceYards(players) > 22 then
  297.     pUnit:FullCastSpellOnTarget(64429, players) -- visual
  298.         players:MoveKnockback(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 10, 20)
  299.             end
  300.          end
  301.      end
  302.  end
  303.  
  304.  function ZG.VAR.EXECUTIONHANDLE(pUnit,Event) -- Boss charges to the player, taking advantage of their low health and executes them quickly.
  305.     local id = pUnit:GetInstanceID()
  306.     if id == nil then id = 1 end
  307.     ZG[id] = ZG[id] or {VAR={}}
  308.     ZG[id].VAR.ExecutedPlayer = pUnit:GetRandomPlayer(0)
  309.     if ZG[id].VAR.ExecutedPlayer ~= nil then
  310.     if pUnit:GetDistanceYards(ZG[id].VAR.ExecutedPlayer) < 30 then
  311.         if ZG[id].VAR.ExecutedPlayer:IsDead() == false then
  312.             if ZG[id].VAR.ExecutedPlayer:GetHealthPct() < 25 then
  313.             pUnit:RemoveEvents()
  314.                 local name = ZG[id].VAR.ExecutedPlayer:GetName()
  315.                 --pUnit:CastSpellOnTarget(100,ZG[id].VAR.ExecutedPlayer)
  316.                  pUnit:AIDisableCombat(true)
  317.                   pUnit:MoveTo(ZG[id].VAR.ExecutedPlayer:GetX(),ZG[id].VAR.ExecutedPlayer:GetY(),ZG[id].VAR.ExecutedPlayer:GetZ(),ZG[id].VAR.ExecutedPlayer:GetO())
  318.                   ZG[id].VAR.ExecutedPlayer:Root()
  319.                   ZG[id].VAR.ExecutedPlayer:DisableSpells(1)
  320.                   ZG[id].VAR.ExecutedPlayer:DisableMelee(1)
  321.                   ZG[id].VAR.ExecutedPlayer:DisableRanged(1)
  322.                   ZG[id].VAR.ExecutedPlayer:CastSpell(68442)
  323.                    pUnit:RegisterEvent("ZG.VAR.EXEUCTION", 4000, 1)
  324.                 local PlayersAllAround = pUnit:GetInRangePlayers()
  325.                 for a, players in pairs(PlayersAllAround) do
  326.                     if pUnit:GetDistanceYards(players) < 30 then
  327.                         pUnit:SendChatMessageToPlayer(42,0,"Rathorian Begins To Execute "..name.."", players)
  328.                    end
  329.                 end
  330.             end
  331.         end
  332.     end
  333. end
  334.     end
  335.    
  336.    
  337.     function ZG.VAR.EXEUCTION(pUnit,Event)
  338.     local id = pUnit:GetInstanceID()
  339.     if id == nil then id = 1 end
  340.     ZG[id] = ZG[id] or {VAR={}}
  341.     pUnit:AIDisableCombat(false)
  342.     pUnit:Emote(38,1500)
  343.                   ZG[id].VAR.ExecutedPlayer:Root()
  344.                   ZG[id].VAR.ExecutedPlayer:DisableSpells(0)
  345.                   ZG[id].VAR.ExecutedPlayer:DisableMelee(0)
  346.                   ZG[id].VAR.ExecutedPlayer:DisableRanged(0)
  347.                   ZG[id].VAR.ExecutedPlayer:RemoveAura(68442)
  348.                   pUnit:CastSpell(70304)
  349.                   pUnit:ChannelSpell(42889, ZG[id].VAR.ExecutedPlayer)
  350.                      pUnit:Strike(ZG[id].VAR.ExecutedPlayer,1,61140,2800,3950,1)
  351.                      if pUnit:GetDistanceYards(ZG[id].VAR.ExecutedPlayer) > 10 then
  352.                      pUnit:CastSpellOnTarget(59209,ZG[id].VAR.ExecutedPlayer)
  353.                      end
  354.                       pUnit:RegisterEvent("ZG.VAR.EXECUTIONHANDLE", 3000, 0)
  355.                        pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_WHIRLWIND", 16000, 0)
  356.                         pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_NoOneInRange", 2000, 0)
  357.                         pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_BLACKCLEAVE", 7000, 0)
  358.                         pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_STOPCHANNEL", 1000, 1)
  359.     end
  360.    
  361.     function ZG.VAR.EXECUTIONER_STOPCHANNEL(pUnit,Event)
  362.     pUnit:StopChannel()
  363.     end
  364.    
  365.    
  366.     function ZG.VAR.EXECUTIONER_BLACKCLEAVE(pUnit,Event) -- deals dot + cleave
  367.         local tank = pUnit:GetMainTank()
  368.                 if tank ~= nil then
  369.     pUnit:CastSpellOnTarget(33480,tank)
  370.     end
  371.     end
  372.    
  373.     function ZG.VAR.Executioner_Kill(pUnit,Event)
  374.         if math.random(1,2) <= 1 then
  375.         pUnit:PlaySoundToSet(11239)
  376.         pUnit:SendChatMessage(14,0,"Yes, that was quite satisfying.")
  377.         elseif math.random(1,2) <= 2 then
  378.         pUnit:PlaySoundToSet(11240)
  379.         pUnit:SendChatMessage(14,0,"Ah, much better!")
  380.         end
  381.     end
  382.    
  383.    
  384.     function ZG.VAR.Executioner_Combat(pUnit,Event)
  385.     pUnit:PlaySoundToSet(11238)
  386.         pUnit:SendChatMessage(14,0,"At last, a target for my frustrations!")
  387.          pUnit:RegisterEvent("ZG.VAR.EXECUTIONHANDLE", 3000, 0)
  388.           pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_NoOneInRange", 2000, 0)
  389.   pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_WHIRLWIND", 16000, 0)
  390.   pUnit:RegisterEvent("ZG.VAR.EXECUTIONER_BLACKCLEAVE", 7000, 0)
  391.     end
  392.    
  393.     function ZG.VAR.Executioner_LEAVE(pUnit,Event)
  394.     pUnit:RemoveEvents()
  395.     pUnit:RemoveAura(70304)
  396.     pUnit:Despawn(1000,5000)
  397.     end
  398.    
  399.         function ZG.VAR.Executioner_DEAD(pUnit,Event)
  400.     pUnit:RemoveEvents()
  401.         pUnit:PlaySoundToSet(11243)
  402.         pUnit:SendChatMessage(14,0,"Knew this was... the only way out.")
  403.     end
  404.    
  405.    
  406.         RegisterUnitEvent(40848, 2, "ZG.VAR.Executioner_LEAVE")
  407. RegisterUnitEvent(40848, 4, "ZG.VAR.Executioner_DEAD")
  408.     RegisterUnitEvent(40848, 1, "ZG.VAR.Executioner_Combat")
  409.     RegisterUnitEvent(40848, 3, "ZG.VAR.Executioner_Kill")
  410.    
  411.     function ZG.VAR.EXEUCTIONER_Leash(pUnit,Event)
  412.   for place,creature in pairs(pUnit:GetInRangeUnits()) do
  413.     if creature:GetEntry() == 40848 then
  414. if pUnit:GetDistanceYards(creature) < 4.5 and creature:IsAlive() then
  415. creature:Despawn(1000,5000)
  416. end
  417.     end
  418.         end
  419.     end
  420.            
  421.            
  422. function ZG.VAR.EXEUCTIONER_Leasher(pUnit,Event)
  423.  pUnit:RegisterEvent("ZG.VAR.EXEUCTIONER_Leash", 1000, 0)
  424.     end
  425.    
  426.    
  427.         RegisterUnitEvent(40849,18, "ZG.VAR.EXEUCTIONER_Leasher")
  428.  
  429. -- Trash, jumping spiders ---------------------------------------------------
  430.  
  431. function ZG.VAR.JumpingSpiderSpawn(pUnit, Event)
  432.     pUnit:RegisterEvent("ZG.VAR.JumpWhenREadySpider", 3000, 0)
  433. end
  434.  
  435. function ZG.VAR.JumpWhenREadySpider(pUnit)
  436.     local plr = pUnit:GetClosestPlayer()
  437.     if plr ~= nil then
  438.         if plr:GetDistanceYards(pUnit) < 40 then
  439.             pUnit:RemoveEvents()
  440.             pUnit:CastSpell(69986) -- web visual
  441.             pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  442.             pUnit:MoveKnockback(plr:GetX(), plr:GetY(), plr:GetZ(), 6, 13)
  443.             pUnit:RegisterEvent("ZG.VAR.SpiderSetHostileHurpaDerp", 5000, 1)
  444.             --pUnit:RegisterEvent("ZG.VAR.StopSpawnResetSpider", 500, 0)
  445.         end
  446.     end
  447. end
  448.  
  449. --[[function ZG.VAR.StopSpawnResetSpider(pUnit)
  450.     if pUnit:GetZ() < (pUnit:GetLandHeight(pUnit:GetX(), pUnit:GetY()) + 5) then
  451.         pUnit:Root()
  452.     end
  453. end]]
  454.  
  455. function ZG.VAR.SpiderSetHostileHurpaDerp(pUnit)
  456.     pUnit:RemoveEvents()
  457.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- attackable
  458.     pUnit:Unroot()
  459. end
  460.  
  461. function ZG.VAR.JumpingSpideEvent(pUnit, Event)
  462.     if Event == 2 then
  463.         pUnit:RemoveEvents()
  464.         pUnit:RegisterEvent("ZG.VAR.JumpWhenREadySpider", 3000, 0)
  465.     elseif Event == 4 then
  466.         pUnit:RemoveEvents()
  467.     end
  468. end
  469.  
  470. RegisterUnitEvent(74444, 18, "ZG.VAR.JumpingSpiderSpawn")
  471. RegisterUnitEvent(74444, 2, "ZG.VAR.JumpingSpideEvent")
  472. RegisterUnitEvent(74444, 4, "ZG.VAR.JumpingSpideEvent")
  473.  
  474. -- Second Boss ---------------------------------------------------------------
  475.  
  476. function ZG.VAR.SecondBossHandlerEvent(pUnit, Event)
  477.     if Event == 1 then
  478.         -- entered
  479.         pUnit:RegisterEvent("ZG.VAR.SecondCurseOne", 1000, 1)
  480.         pUnit:RegisterEvent("ZG.VAR.SecondCurseTwo", 5000, 0)
  481.         pUnit:RegisterEvent("ZG.VAR.SecondCurseThree", 15000, 0)
  482.         pUnit:RegisterEvent("ZG.VAR.BurnAllSecond", 22000, 0)
  483.         pUnit:RegisterEvent("ZG.VAR.SEcondFireShield", 39000, 0)
  484.         pUnit:RegisterEvent("ZG.VAR.RandomisePlayersSecond", 15000, 0)
  485.     elseif Event == 2 then
  486.         pUnit:RemoveEvents()
  487.         pUnit:Despawn(3500, 4000)
  488.     elseif Event == 3 then
  489.         pUnit:FullCastSpell(22428) -- enrage
  490.     elseif Event == 4 then
  491.         pUnit:RemoveEvents()
  492.     end
  493. end
  494.  
  495. function ZG.VAR.SecondCurseOne(pUnit)
  496.     local plr = pUnit:GetClosestPlayer()
  497.     if plr ~= nil then
  498.         pUnit:FullCastSpellOnTarget(6946, plr)
  499.     end
  500. end
  501.  
  502. function ZG.VAR.SecondCurseTwo(pUnit)
  503.     local plr = pUnit:GetRandomPlayer(0)
  504.     if plr ~= nil then
  505.         pUnit:FullCastSpellOnTarget(16871, plr)
  506.     end
  507. end
  508.  
  509. function ZG.VAR.SecondCurseThree(pUnit)
  510.     pUnit:CastSpell(11988)
  511. end
  512.  
  513. function ZG.VAR.BurnAllSecond(pUnit)
  514.     pUnit:StopMovement(3500)
  515.     pUnit:FullCastSpell(51768)
  516. end
  517.  
  518. function ZG.VAR.SEcondFireShield(pUnit)
  519.     pUnit:CastSpell(11350) -- fire shield
  520. end
  521.  
  522. function ZG.VAR.RandomisePlayersSecond(pUnit)
  523.     -- Store players & amount
  524.     local index = {}
  525.     local count = 0
  526.     -- Get all players in this area, and add them to our encounter
  527.     for place,plrs in pairs(pUnit:GetInRangePlayers()) do
  528.         if plrs ~= nil and plrs:HasGmFlag() == false then
  529.             index[place] = plrs
  530.             count = count + 1
  531.         end
  532.     end
  533.     -- If we have more than one player
  534.     if count > 1 then
  535.         -- Set up variables
  536.         local x,y,z = 0,0,0
  537.         if index[1] ~= nil and index[2] ~= nil then
  538.             x,y,z = index[1]:GetX(), index[1]:GetY(), index[1]:GetZ()
  539.             index[1]:CancelSpell()
  540.             index[2]:CancelSpell()
  541.             index[1]:MoveKnockback(index[2]:GetX(), index[2]:GetY(), index[2]:GetZ(), 7, 14)
  542.             pUnit:FullCastSpellOnTarget(64429, index[2]) -- visual
  543.             pUnit:FullCastSpellOnTarget(64429, index[1]) -- visual
  544.             index[2]:MoveKnockback(x,y,z, 10, 20)
  545.         end
  546.         if index[3] ~= nil and index[4] ~= nil then
  547.             x,y,z = index[3]:GetX(), index[3]:GetY(), index[3]:GetZ()
  548.             index[3]:CancelSpell()
  549.             index[4]:CancelSpell()
  550.             pUnit:FullCastSpellOnTarget(64429, index[3]) -- visual
  551.             pUnit:FullCastSpellOnTarget(64429, index[4]) -- visual
  552.             index[3]:MoveKnockback(index[4]:GetX(), index[4]:GetY(), index[4]:GetZ(),7,14)
  553.             index[4]:MoveKnockback(x,y,z,10,20)
  554.         end
  555.         if index[5] ~= nil then
  556.             index[5]:CancelSpell()
  557.             pUnit:FullCastSpellOnTarget(64429, index[5]) -- visual
  558.             index[5]:MoveKnockback(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(),7,14)
  559.         end
  560.     end
  561. end
  562.  
  563. RegisterUnitEvent(218331, 1, "ZG.VAR.SecondBossHandlerEvent")
  564. RegisterUnitEvent(218331, 2, "ZG.VAR.SecondBossHandlerEvent")
  565. RegisterUnitEvent(218331, 3, "ZG.VAR.SecondBossHandlerEvent")
  566. RegisterUnitEvent(218331, 4, "ZG.VAR.SecondBossHandlerEvent")
  567.  
  568. -- The bridge event ----------------------------------------------------------
  569.  
  570. function ZG.VAR.BridgeEventSpawn(pUnit, Event)
  571.     pUnit:RegisterEvent("ZG.VAR.BridgeEventCheck", 1000, 0)
  572. end
  573.  
  574. function ZG.VAR.BridgeEventCheck(pUnit)
  575.     local plr = pUnit:GetClosestPlayer()
  576.     if plr ~= nil then
  577.         if pUnit:GetDistanceYards(plr) < 10 then
  578.             pUnit:RemoveEvents()
  579.             pUnit:SendChatMessage(42,0,"The ground begins to quake!")
  580.             for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  581.                 plrs:Dismount()
  582.                 plrs:Root()
  583.                 plrs:SetPlayerLock(true)
  584.                 plrs:CastSpell(43328) -- stun visual
  585.                 plrs:CastSpell(36455) -- shake camera - long
  586.             end
  587.             local id = pUnit:GetInstanceID()
  588.             if id == nil then id = 1 end
  589.             ZG[id] = ZG[id] or {VAR={}}
  590.             ZG[id].VAR.inferno = true
  591.             pUnit:RegisterEvent("ZG.VAR.InfernalReverseStun", 1000, 0)
  592.         end
  593.     end
  594. end
  595.  
  596. function ZG.VAR.InfernalReverseStun(pUnit)
  597.     local id = pUnit:GetInstanceID()
  598.     if id == nil then id = 1 end
  599.     ZG[id] = ZG[id] or {VAR={}}
  600.     if not ZG[id].VAR.inferno then
  601.         pUnit:RemoveEvents()
  602.         for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  603.             plrs:Unroot()
  604.             plrs:SetPlayerLock(false)
  605.             plrs:RemoveAura(43328) -- stun visual
  606.         end
  607.     end
  608. end
  609.  
  610. RegisterUnitEvent(88880, 18, "ZG.VAR.BridgeEventSpawn")
  611.  
  612. function ZG.VAR.BridgeEventVisualSpawn(pUnit)
  613.     pUnit:RegisterEvent("ZG.VAR.BridgeEventVisualCheck", 1000, 0)
  614. end
  615.  
  616. function ZG.VAR.BridgeEventVisualCheck(pUnit)
  617.     local id = pUnit:GetInstanceID()
  618.     if id == nil then id = 1 end
  619.     ZG[id] = ZG[id] or {VAR={}}
  620.     if ZG[id].VAR.inferno then
  621.         pUnit:RemoveEvents()
  622.         pUnit:RegisterEvent("ZG.VAR.incomingInfernalZ", 4000, 1)
  623.     end
  624. end
  625.  
  626. function ZG.VAR.incomingInfernalZ(pUnit)
  627.     pUnit:CastSpellAoF(-11091, -1855, 63.27, 32148) -- infernal
  628.     pUnit:CastSpellAoF(-11096, -1833, 67.9, 32148) -- infernal
  629.     pUnit:CastSpellAoF(-11103, -1876, 72.5, 32148) -- infernal
  630.     pUnit:RegisterEvent("ZG.VAR.InfernalImpactSpawn", 4500, 1)
  631. end
  632.  
  633. function ZG.VAR.InfernalImpactSpawn(pUnit)
  634.     pUnit:SpawnCreature(89, -11091, -1855, 63.27, 0, 21, 120000)
  635.     pUnit:SpawnCreature(89, -11096, -1833, 67.9, 0, 21, 120000)
  636.     pUnit:SpawnCreature(89, -11103, -1876, 72.5, 0, 21, 120000)
  637.     local id = pUnit:GetInstanceID()
  638.     if id == nil then id = 1 end
  639.     ZG[id] = ZG[id] or {VAR={}}
  640.     ZG[id].VAR.inferno = false
  641. end
  642.  
  643. RegisterUnitEvent(88881, 18, "ZG.VAR.BridgeEventVisualSpawn")
  644.  
  645. function ZG.VAR.InfernalOnSpawn(pUnit)
  646.     pUnit:RegisterEvent("ZG.VAR.InfernalRunToPlayers", 500, 1)
  647. end
  648.  
  649. function ZG.VAR.InfernalRunToPlayers(pUnit)
  650.     local plr = pUnit:GetClosestPlayer()
  651.     if plr ~= nil then
  652.         pUnit:SetMovementFlags(1)
  653.         pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  654.     end
  655. end
  656.  
  657. RegisterUnitEvent(89, 18, "ZG.VAR.InfernalOnSpawn")
  658.  
  659. -- Trash ---------------------------------------------------------------------
  660.  
  661. function ZG.VAR.BrokenKodoCombat(pUnit)
  662.     pUnit:FullCastSpell(16096)
  663.     pUnit:RegisterEvent("ZG.VAR.kodostomp", math.random(4000, 12000), 0)
  664. end
  665.  
  666. function ZG.VAR.kodostomp(pUnit)
  667.     pUnit:FullCastSpell(28125)
  668. end
  669.  
  670. function ZG.VAR.BrokenKodoDeath(pUnit) -- it seems that spawning mobs bugs movementmaps
  671.     --[[local d = math.random(1,4)
  672.     local i = 0
  673.     while i ~= d do
  674.         pUnit:SpawnCreature(40847, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 21, 120000)
  675.         i = i + 1
  676.     end]]
  677.     pUnit:RemoveEvents()
  678. end
  679.  
  680. RegisterUnitEvent(109161, 4, "ZG.VAR.BrokenKodoDeath")
  681. RegisterUnitEvent(109161, 2, "ZG.VAR.BrokenKodoDeath")
  682. RegisterUnitEvent(109161, 1, "ZG.VAR.BrokenKodoCombat")
  683.  
  684. -- Satyr Trash ---------------------------------------------------------------
  685.  
  686. function ZG.VAR.SatyrTrashOnEvent(pUnit, Event)
  687.     if Event == 1 then
  688.         if pUnit:GetEntry() == 3758 then -- Tank
  689.             if math.random(1,2) == 1 then
  690.                 pUnit:FullCastSpell(8713)
  691.             else
  692.                 pUnit:StopMovement(1200)
  693.                 pUnit:FullCastSpell(72143)
  694.                 pUnit:RegisterEvent("ZG.VAR.SatyrTankCharge", 1500, 1)
  695.                 pUnit:RegisterEvent("ZG.VAR.SatyrTankCastRandom", 6500, 0)
  696.             end
  697.         elseif pUnit:GetEntry() == 6125 then -- Rogue
  698.             pUnit:RegisterEvent("ZG.VAR.SatyrRogueStrike", 2000, 0)
  699.             pUnit:RegisterEvent("ZG.VAR.SatyrRogueEnergy", 500, 0)
  700.         elseif pUnit:GetEntry() == 6200 then -- Caster
  701.             pUnit:RegisterEvent("ZG.VAR.SatyrHealerHeal", 1000, 1)
  702.         end
  703.     elseif Event == 2 or Event == 4 then
  704.         pUnit:RemoveEvents()
  705.         if pUnit:GetEntry() == 6125 then
  706.             pUnit:SetPower(100, 3)
  707.         end
  708.         if pUnit:HasAura(8713) then
  709.             pUnit:RemoveAura(8713)
  710.         end
  711.     elseif Event == 18 then
  712.         pUnit:SetMaxPower(100, 3)
  713.         pUnit:SetPower(100, 3)
  714.         pUnit:SetPowerType(3)
  715.     end
  716. end
  717.  
  718. function ZG.VAR.SatyrRogueEnergy(pUnit)
  719.     if pUnit:GetPower(3) < 100 then
  720.         pUnit:SetPower(pUnit:GetPower(3)+5, 3)
  721.     end
  722. end
  723.  
  724. function ZG.VAR.SatyrRogueStrike(pUnit)
  725.     local plr = pUnit:GetMainTank()
  726.     if plr ~= nil then
  727.         pUnit:FullCastSpellOnTarget(11294, plr) -- sinister strike
  728.     end
  729.     if math.random(1,10) == 5 then
  730.         pUnit:FullCastSpell(6434)
  731.     end
  732. end
  733.  
  734. function ZG.VAR.SatyrTankCharge(pUnit)
  735.     local plr = pUnit:GetClosestPlayer()
  736.     if plr ~= nil then
  737.         pUnit:FullCastSpellOnTarget(55317, plr)
  738.     end
  739. end
  740.  
  741. function ZG.VAR.SatyrTankCastRandom(pUnit)
  742.     if math.random(1,2) == 1 then
  743.         local target = pUnit:GetMainTank()
  744.         if target ~= nil then
  745.             pUnit:FullCastSpellOnTarget(21949, target) -- rend
  746.         end
  747.     else
  748.         pUnit:FullCastSpell(3143) -- roar
  749.     end
  750. end
  751.  
  752. function ZG.VAR.SatyrHealerHeal(pUnit)
  753.     local found = false
  754.     for _,target in pairs(pUnit:GetInRangeUnits()) do
  755.         if target:IsAlive() then
  756.             if not target:IsPlayer() then
  757.                 if target:GetHealthPct() < 60 then
  758.                     if target:GetDistanceYards(pUnit) < 30 then
  759.                         pUnit:StopMovement(3000)
  760.                         pUnit:FullCastSpellOnTarget(10623, target)
  761.                         found = true
  762.                         break
  763.                     end
  764.                 end
  765.             end
  766.         end
  767.     end
  768.     if not found then
  769.         local plr = pUnit:GetRandomPlayer(0)
  770.         if plr ~= nil then
  771.             if plr:GetDistanceYards(pUnit) < 30 then
  772.                 pUnit:StopMovement(3500)
  773.                 pUnit:FullCastSpellOnTarget(39054, plr)
  774.             end
  775.         end
  776.     end
  777.     pUnit:RegisterEvent("ZG.VAR.SatyrHealerHeal", 7000, 1)
  778. end
  779.  
  780. RegisterUnitEvent(3758, 1, "ZG.VAR.SatyrTrashOnEvent") -- Tank
  781. RegisterUnitEvent(3758, 2, "ZG.VAR.SatyrTrashOnEvent")
  782. RegisterUnitEvent(3758, 4, "ZG.VAR.SatyrTrashOnEvent")
  783. RegisterUnitEvent(6125, 1, "ZG.VAR.SatyrTrashOnEvent") -- Rogue
  784. RegisterUnitEvent(6125, 2, "ZG.VAR.SatyrTrashOnEvent")
  785. RegisterUnitEvent(6125, 4, "ZG.VAR.SatyrTrashOnEvent")
  786. RegisterUnitEvent(6125, 18, "ZG.VAR.SatyrTrashOnEvent")
  787. RegisterUnitEvent(6200, 1, "ZG.VAR.SatyrTrashOnEvent") -- Caster
  788. RegisterUnitEvent(6200, 2, "ZG.VAR.SatyrTrashOnEvent")
  789. RegisterUnitEvent(6200, 4, "ZG.VAR.SatyrTrashOnEvent")
  790.  
  791. -- Final Dragon Boss ---------------------------------------------------------
  792.  
  793. function ZG.VAR.DragonBossEvent_COT(pUnit, Event)
  794.     if Event == 4 then
  795.         pUnit:RemoveEvents()
  796.     elseif Event == 18 then
  797.         pUnit:RegisterEvent("ZG.VAR.SetUpCreatures_Dragon", 1000, 1)
  798.     end
  799. end
  800.  
  801. RegisterUnitEvent(115831, 4, "ZG.VAR.DragonBossEvent_COT")
  802. RegisterUnitEvent(115831, 18, "ZG.VAR.DragonBossEvent_COT")
  803.  
  804. function ZG.VAR.SetUpCreatures_Dragon(pUnit)
  805.     pUnit:SetMaxPower(100, 2)
  806.     pUnit:SetPower(100, 2)
  807.     pUnit:SetPowerType(2)
  808.     --pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+6, pUnit:GetO())
  809.     local id = pUnit:GetInstanceID()
  810.     if id == nil then id = 1 end
  811.     ZG[id] = ZG[id] or {VAR={}}
  812.     ZG[id].VAR.leader = pUnit:SpawnCreature(36544, -11062, -2306, 145.9, 1.290404, 35, 0, 50429) -- Leader
  813.     ZG[id].VAR.addA = pUnit:SpawnCreature(4052, -11075, -2307, 145, 1.058709, 35, 0, 45212)
  814.     ZG[id].VAR.addB = pUnit:SpawnCreature(4052, -11066, -2311, 145.9, 1.184373, 35, 0, 45212)
  815.     ZG[id].VAR.addC = pUnit:SpawnCreature(4052, -11057, -2314, 147.3, 1.549583, 35, 0, 45212)
  816.     ZG[id].VAR.addD = pUnit:SpawnCreature(4052, -11049, -2311, 146.3, 2, 35, 0, 45212)
  817.     pUnit:RegisterEvent("ZG.VAR.WhileNoPlayer_DoVisual", 1500, 1)
  818.     pUnit:RegisterEvent("ZG.VAR.CheckForPlayers_ToStart", 1000, 0)
  819. end
  820.  
  821. function ZG.VAR.WhileNoPlayer_DoVisual(pUnit)
  822.     local id = pUnit:GetInstanceID()
  823.     if id == nil then id = 1 end
  824.     ZG[id] = ZG[id] or {VAR={}}
  825.     ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
  826.     ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
  827.     ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
  828.     ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
  829.     ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)
  830. end
  831.  
  832. function ZG.VAR.CheckForPlayers_ToStart(pUnit)
  833.     local id = pUnit:GetInstanceID()
  834.     if id == nil then id = 1 end
  835.     ZG[id] = ZG[id] or {VAR={}}
  836.     local plr = ZG[id].VAR.leader:GetClosestPlayer()
  837.     if plr ~= nil then
  838.         if ZG[id].VAR.leader:GetDistanceYards(plr) < 10 then
  839.             if plr:IsAlive() then
  840.                 pUnit:SetMovementFlags(2)
  841.                 ZG[id].VAR.leader:SendChatMessage(12,0,"Hurry mortals, I cannot hold the beast back for long!")
  842.                 pUnit:RemoveEvents()
  843.                 pUnit:RegisterEvent("ZG.VAR.HEREWEGO_DRAGON", 4000, 1)
  844.             end
  845.         end
  846.     end
  847. end
  848.  
  849. function ZG.VAR.HEREWEGO_DRAGON(pUnit)
  850.     local id = pUnit:GetInstanceID()
  851.     if id == nil then id = 1 end
  852.     ZG[id] = ZG[id] or {VAR={}}
  853.     pUnit:SendChatMessage(14,0,"ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!")
  854.     pUnit:SpawnGameObject(146086, -11095.85, -2318.86, 147.5, 6.154612, 900000, 100) -- cave in
  855.     ZG[id].VAR.leader:PlaySoundToSet(8289)
  856.     ZG[id].VAR.leader:StopChannel()
  857.     ZG[id].VAR.addA:StopChannel()
  858.     ZG[id].VAR.addB:StopChannel()
  859.     ZG[id].VAR.addC:StopChannel()
  860.     ZG[id].VAR.addD:StopChannel()
  861.     pUnit:RegisterEvent("ZG.VAR.WaitForVisualsToPlayDURP", 250, 1)
  862.     ZG[id].VAR.e = 0
  863.     ZG[id].VAR.hpCount = 1
  864.     ZG[id].VAR.hpList = {90,80,70,60,50,40,30,20,10}
  865.     pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 7000, 1)
  866.     pUnit:RegisterEvent("ZG.VAR.DrainDragonBossHealth", 500, 0)
  867.     pUnit:RegisterEvent("ZG.VAR.DragonBossCheckForWipe_Astarot", 2000, 0)
  868.     pUnit:RegisterEvent("ZG.VAR.DragonDespawnDeadTrash", 10000, 0)
  869. end
  870.  
  871. function ZG.VAR.WaitForVisualsToPlayDURP(pUnit)
  872.     local id = pUnit:GetInstanceID()
  873.     if id == nil then id = 1 end
  874.     ZG[id] = ZG[id] or {VAR={}}
  875.     ZG[id].VAR.leader:CastSpell(68848)
  876.     ZG[id].VAR.addA:CastSpell(68848) -- knockdown visual
  877.     ZG[id].VAR.addB:CastSpell(68848)
  878.     ZG[id].VAR.addC:CastSpell(68848)
  879.     ZG[id].VAR.addD:CastSpell(68848)
  880. end
  881.  
  882. function ZG.VAR.DrainDragonBossHealth(pUnit)
  883.     local id = pUnit:GetInstanceID()
  884.     if id == nil then id = 1 end
  885.     ZG[id] = ZG[id] or {VAR={}}
  886.     if pUnit:GetHealthPct() > ZG[id].VAR.hpList[ZG[id].VAR.hpCount] then
  887.         pUnit:SetHealth(pUnit:GetHealth()-200)
  888.     end
  889.     --[[if pUnit:GetPower() < pUnit:GetMaxPower() then
  890.         pUnit:SetPower(pUnit:GetPower(2)+1, 2)
  891.     end]]
  892. end
  893.  
  894. function ZG.VAR.BeginZeEventZZ(pUnit)
  895.     local id = pUnit:GetInstanceID()
  896.     if id == nil then id = 1 end
  897.     ZG[id] = ZG[id] or {VAR={}}
  898.     ZG[id].VAR.e = ZG[id].VAR.e + 1
  899.     if ZG[id].VAR.e == 1 then
  900.         ZG[id].VAR.leader:SendChatMessage(12,0,"Mortals, you must defend us while we attempt to destroy this being, or all hope is lost!")
  901.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 3000, 1)
  902.     elseif ZG[id].VAR.e == 2 then
  903.         ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
  904.         ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
  905.         ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
  906.         ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)     
  907.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  908.     elseif ZG[id].VAR.e == 3 then
  909.         ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
  910.         --ZG[id].VAR.e = 15 -- DEBUG -------------------------------------------------------------------------
  911.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  912.     elseif ZG[id].VAR.e == 4 then
  913.         pUnit:CastSpellAoF(-11062.66, -2297.34, 146, 68926)
  914.         pUnit:SpawnCreature(21234, -11062.66, -2297.34, 146, 0, 15, 300000)
  915.         ZG[id].VAR.dragons = 0
  916.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 2)
  917.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)
  918.     elseif ZG[id].VAR.e == 5 then
  919.         local found = false
  920.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  921.             local entry = unit:GetEntry()
  922.             if entry == 871111 or entry == 497111 then
  923.                 if unit:IsAlive() then
  924.                     found = true
  925.                     break
  926.                 end
  927.             end
  928.         end
  929.         if not found then
  930.             ZG[id].VAR.leader:PlaySoundToSet(8291)
  931.             pUnit:SendChatMessage(14,0,"Impossible! Rise my minions! Serve your master once more!")
  932.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  933.         else
  934.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  935.         end
  936.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  937.     elseif ZG[id].VAR.e == 6 then
  938.         ZG[id].VAR.dragons = 0
  939.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
  940.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)     
  941.     elseif ZG[id].VAR.e == 7 then
  942.         local found = false
  943.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  944.             local entry = unit:GetEntry()
  945.             if entry == 871111 or entry == 497111 then
  946.                 if unit:IsAlive() then
  947.                     found = true
  948.                     break
  949.                 end
  950.             end
  951.         end
  952.         if not found then
  953.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  954.             ZG[id].VAR.leader:PlaySoundToSet(8290)
  955.             pUnit:SendChatMessage(14,0,"Burn, you wretches! Burn!")
  956.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  957.             local trigger = pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942)
  958.             trigger:SetScale(0.8)
  959.             trigger:CastSpell(63894) -- shield
  960.         else
  961.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  962.         end
  963.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  964.     elseif ZG[id].VAR.e == 8 then
  965.         ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
  966.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
  967.     elseif ZG[id].VAR.e == 9 then
  968.         for i=1,100 do
  969.             pUnit:RegisterEvent("ZG.VAR.METEORSINCOMINGDUN_DUN", math.random(1000,20000),1)
  970.         end
  971.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 23000, 1)
  972.     elseif ZG[id].VAR.e == 10 then
  973.         pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942):RemoveAura(63894) -- shield
  974.         ZG[id].VAR.leader:PlaySoundToSet(8292)
  975.         pUnit:SendChatMessage(14,0,"This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!")
  976.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
  977.     elseif ZG[id].VAR.e == 11 then
  978.         ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  979.         ZG[id].VAR.dragons = 0
  980.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 4)
  981.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
  982.     elseif ZG[id].VAR.e == 12 then
  983.         local found = false
  984.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  985.             local entry = unit:GetEntry()
  986.             if entry == 871111 or entry == 497111 then
  987.                 if unit:IsAlive() then
  988.                     found = true
  989.                     break
  990.                 end
  991.             end
  992.         end
  993.         if not found then
  994.             for _,unit in pairs(pUnit:GetInRangeUnits()) do
  995.                 if unit:GetEntry() == 21234 then
  996.                     unit:Kill(unit)
  997.                     break
  998.                 end
  999.             end
  1000.             ZG[id].VAR.leader:PlaySoundToSet(8291)
  1001.             pUnit:SendChatMessage(14,0,"Impossible! Rise my minions! Serve your master once more!")
  1002.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1003.             ZG[id].VAR.dragons = 0
  1004.             pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
  1005.             pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
  1006.         else
  1007.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1008.             pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1009.         end
  1010.     elseif ZG[id].VAR.e == 13 then
  1011.         local found = false
  1012.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1013.             local entry = unit:GetEntry()
  1014.             if entry == 871111 or entry == 497111 then
  1015.                 if unit:IsAlive() then
  1016.                     found = true
  1017.                     break
  1018.                 end
  1019.             end
  1020.         end
  1021.         if not found then
  1022.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1023.             ZG[id].VAR.leader:PlaySoundToSet(8290)
  1024.             pUnit:SendChatMessage(14,0,"Burn, you wretches! Burn!")
  1025.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1026.             local trigger = pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942)
  1027.             trigger:SetScale(0.8)
  1028.             trigger:CastSpell(63894) -- shield
  1029.         else
  1030.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1031.         end
  1032.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)  
  1033.     elseif ZG[id].VAR.e == 14 then
  1034.         ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
  1035.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2500, 1)
  1036.     elseif ZG[id].VAR.e == 15 then
  1037.         for i=1,100 do
  1038.             pUnit:RegisterEvent("ZG.VAR.METEORSINCOMINGDUN_DUN", math.random(1000,20000),1)
  1039.         end
  1040.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 23000, 1)
  1041.     elseif ZG[id].VAR.e == 16 then
  1042.         pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942):RemoveAura(63894) -- shield
  1043.         ZG[id].VAR.leader:PlaySoundToSet(8292)
  1044.         pUnit:SendChatMessage(14,0,"This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!")
  1045.         pUnit:SetHealthPct(10)
  1046.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1047.     elseif ZG[id].VAR.e == 17 then
  1048.         --pUnit:ChannelSpell(68834, ZG[id].VAR.leader)
  1049.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  1050.     elseif ZG[id].VAR.e == 18 then
  1051.         ZG[id].VAR.leader:SendChatMessage(14,0,"No!")
  1052.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
  1053.     elseif ZG[id].VAR.e == 19 then
  1054.         ZG[id].VAR.leader:SendChatMessage(12,0,"Death to the interlopers.")
  1055.         ZG[id].VAR.leader:StopChannel()
  1056.         ZG[id].VAR.leader:CastSpell(41535) -- chains visual
  1057.         ZG[id].VAR.addA:StopChannel()
  1058.         ZG[id].VAR.addB:StopChannel()
  1059.         ZG[id].VAR.addC:StopChannel()
  1060.         ZG[id].VAR.addD:StopChannel()
  1061.         ZG[id].VAR.addcount = 0
  1062.         pUnit:RegisterEvent("ZG.VAR.SetFactionsOfNPCSDragon", 1000, 4)
  1063.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1064.     elseif ZG[id].VAR.e == 20 then
  1065.         ZG[id].VAR.addA:SetFaction(21)
  1066.         ZG[id].VAR.addB:SetFaction(21)
  1067.         ZG[id].VAR.addC:SetFaction(21)
  1068.         ZG[id].VAR.addD:SetFaction(21)
  1069.         ZG[id].VAR.leader:SetFaction(21)
  1070.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
  1071.     elseif ZG[id].VAR.e == 21 then
  1072.         local found = false
  1073.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1074.             local entry = unit:GetEntry()
  1075.             if entry == 36544 or entry == 4052 then
  1076.                 if unit:IsAlive() then
  1077.                     found = true
  1078.                     break
  1079.                 end
  1080.             end
  1081.         end
  1082.         if not found then
  1083.             ZG[id].VAR.leader:PlaySoundToSet(8293)
  1084.             pUnit:SendChatMessage(14,0,"Worthless wretch! Your friends will join you soon enough!")
  1085.             pUnit:SetHealth(132)
  1086.         else
  1087.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1088.         end
  1089.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)      
  1090.     elseif ZG[id].VAR.e == 22 then
  1091.         pUnit:MoveTo(-11064, -2310.88, 146.2, 0)
  1092.         pUnit:RegisterEvent("ZG.VAR.VisuzlzzBoss", 100, 0)
  1093.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 6000, 1)  
  1094.     elseif ZG[id].VAR.e == 23 then
  1095.         pUnit:RemoveEvents()
  1096.         --[[for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  1097.             if pUnit:IsAlive() then
  1098.                 plrs:CastSpellOnTarget(11, pUnit)
  1099.             end
  1100.         end]]
  1101.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1102.             local entry = unit:GetEntry()
  1103.             if entry == 21234 or entry == 871111 or entry == 36544 or entry == 497111 or entry == 4052 then
  1104.                 if not unit:IsAlive() then
  1105.                     unit:Despawn(1,0)
  1106.                 end
  1107.             end
  1108.         end
  1109.         local object = pUnit:GetGameObjectNearestCoords(-11095.5, -2318.3, 147.5, 146086) -- rocks
  1110.         if object ~= nil then
  1111.             object:Despawn(1,0)
  1112.         end
  1113.         pUnit:SpawnGameObject(355101, -11064, -2329.5, 146.6, 4.679757, 300000, 100) -- chest
  1114.         pUnit:Kill(pUnit)
  1115.     end
  1116. end
  1117.  
  1118. function ZG.VAR.SetFactionsOfNPCSDragon(pUnit)
  1119.     local id = pUnit:GetInstanceID()
  1120.     if id == nil then id = 1 end
  1121.     ZG[id] = ZG[id] or {VAR={}}
  1122.     ZG[id].VAR.addcount = ZG[id].VAR.addcount + 1
  1123.     if ZG[id].VAR.addcount == 1 then
  1124.         ZG[id].VAR.addA:CastSpell(41535)
  1125.     elseif ZG[id].VAR.addcount == 2 then
  1126.         ZG[id].VAR.addB:CastSpell(41535)
  1127.     elseif ZG[id].VAR.addcount == 3 then
  1128.         ZG[id].VAR.addC:CastSpell(41535)
  1129.     elseif ZG[id].VAR.addcount == 4 then
  1130.         ZG[id].VAR.addD:CastSpell(41535)
  1131.     end
  1132. end
  1133.  
  1134. function ZG.VAR.VisuzlzzBoss(pUnit)
  1135.     pUnit:CastSpell(32711) -- AoE visual
  1136. end
  1137.  
  1138. function ZG.VAR.METEORSINCOMINGDUN_DUN(pUnit)
  1139.     pUnit:SetPower(pUnit:GetPower(2)-3, 2)
  1140.     local nx = math.random(11051,11087)
  1141.     local ny = math.random(2325,2341)
  1142.     pUnit:CastSpellAoF(-nx,-ny,pUnit:GetLandHeight(-nx,-ny),57467)
  1143.     if math.random(1,100) < 13 then -- Since the square doesn't cover the sides of the shield, we'll hit those gaps
  1144.         if math.random(1,2) == 1 then
  1145.             pUnit:CastSpellAoF(-11048.75, -2320.6, 147.8,57467)
  1146.         else
  1147.             pUnit:CastSpellAoF(-11078.3, -2315, 147,57467)
  1148.         end
  1149.     end
  1150. end
  1151.  
  1152. function ZG.VAR.SpawnMoreDamnDragonLords(pUnit)
  1153.     local id = pUnit:GetInstanceID()
  1154.     if id == nil then id = 1 end
  1155.     ZG[id] = ZG[id] or {VAR={}}
  1156.     if ZG[id].VAR.dragons == 0 then
  1157.         pUnit:CastSpellAoF(-11042, -2333, 146.65, 68926)
  1158.         pUnit:SpawnCreature(871111, -11042, -2333, 146.8, 2.67, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  1159.     elseif ZG[id].VAR.dragons == 1 then
  1160.         pUnit:CastSpellAoF(-11089.64, -2331.76, 146.3, 68926)
  1161.         pUnit:SpawnCreature(871111, -11089.64, -2331.76, 146.3, 0.37, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  1162.     elseif ZG[id].VAR.dragons == 2 then
  1163.         pUnit:CastSpellAoF(-11090.4, -2332, 146.3, 68926)
  1164.         for i=1,math.random(5,12) do
  1165.             pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
  1166.         end
  1167.     elseif ZG[id].VAR.dragons == 3 then
  1168.         pUnit:CastSpellAoF(-11042.7, -2333, 146.7, 68926)
  1169.         for i=1,math.random(9,15) do
  1170.             pUnit:SpawnCreature(497111, -11042.7, -2333, 146.7, 2.649929, 15, 120000)
  1171.         end
  1172.     end
  1173.     ZG[id].VAR.dragons = ZG[id].VAR.dragons + 1
  1174. end
  1175.  
  1176. function ZG.VAR.DragonDespawnDeadTrash(pUnit)
  1177.     for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1178.         local entry = unit:GetEntry()
  1179.         if entry == 21234 or entry == 871111 or entry == 36544 or entry == 497111 or entry == 4052 then
  1180.             if not unit:IsAlive() then
  1181.                 --pUnit:CastSpellAoF(unit:GetX(), unit:GetY(), unit:GetZ(), 68926) -- causes too much damage
  1182.                 unit:Despawn(1,0)
  1183.             end
  1184.         end
  1185.     end
  1186. end
  1187.  
  1188. function ZG.VAR.DragonBossCheckForWipe_Astarot(pUnit)
  1189.     local found = false
  1190.     for _,plr in pairs(pUnit:GetInRangePlayers()) do
  1191.         if plr:GetZ() < 143 or plr:GetZ() > 149 then
  1192.             plr:Teleport(309, -11070, -2328.8, 150)
  1193.             plr:CastSpell(64446) -- teleport visual
  1194.         end
  1195.         if not found then
  1196.             if plr:IsAlive() then
  1197.                 found = true
  1198.             end
  1199.         end
  1200.     end
  1201.     if not found then
  1202.         -- wipe
  1203.         pUnit:RemoveEvents()
  1204.         pUnit:StopChannel()
  1205.         pUnit:SetHealth(pUnit:GetMaxHealth())
  1206.         local object = pUnit:GetGameObjectNearestCoords(-11095.85, -2318.86, 147.5, 146086) -- cave in
  1207.         if object ~= nil then
  1208.             object:Despawn(1000, 0)
  1209.         end
  1210.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1211.             local entry = unit:GetEntry()
  1212.             if entry == 21234 or entry == 871111 or entry == 497111 or entry == 36544 or entry == 4052 then
  1213.                 unit:StopChannel()
  1214.                 unit:CancelSpell()
  1215.                 unit:Despawn(1000,0)
  1216.             end
  1217.         end
  1218.         pUnit:RegisterEvent("ZG.VAR.SetUpCreatures_Dragon", 5000, 1)
  1219.     end
  1220. end
  1221.  
  1222. -- 8289 <- ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!
  1223. -- 8290 <- Burn, you wretches! Burn!
  1224. -- 8291 <- Impossible! Rise my minions! Serve your master once more!
  1225. -- 8292 <- This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!
  1226. -- 8293 <- Worthless wretch! Your friends will join you soon enough!
  1227.  
  1228. -- Draconic lords
  1229.  
  1230. function ZG.VAR.DRACONICLORDEVENT(pUnit, Event)
  1231.     if Event == 1 then
  1232.         pUnit:RegisterEvent("ZG.VAR.LordSpamFlameStrike", 10000, 0)
  1233.         pUnit:RegisterEvent("ZG.VAR.SummonWhelpsAndSuchLordd", 1100, 0)
  1234.     elseif Event == 2 or Event == 4 then
  1235.         pUnit:RemoveEvents()
  1236.     elseif Event == 18 then
  1237.         pUnit:RegisterEvent("ZG.VAR.MoveTowardsEnemyZZLord", 1000, 1)
  1238.     end
  1239. end
  1240.  
  1241. function ZG.VAR.LordSpamFlameStrike(pUnit)
  1242.     local plr = pUnit:GetRandomPlayer(0)
  1243.     if plr ~= nil then
  1244.         pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 2121)
  1245.     end
  1246.     plr = pUnit:GetMainTank()
  1247.     if plr ~= nil then
  1248.         if pUnit:GetDistanceYards(plr) < 7 then
  1249.             pUnit:StopMovement(2500)
  1250.             pUnit:FullCastSpellOnTarget(5213, plr)
  1251.         end
  1252.     end
  1253. end
  1254.  
  1255. function ZG.VAR.MoveTowardsEnemyZZLord(pUnit)
  1256.     if not pUnit:IsInCombat() then
  1257.         local plr = pUnit:GetClosestPlayer()
  1258.         if plr ~= nil then
  1259.             pUnit:SetMovementFlags(1)
  1260.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1261.             pUnit:ChangeTarget(plr)
  1262.         end
  1263.     end
  1264. end
  1265.  
  1266. function ZG.VAR.SummonWhelpsAndSuchLordd(pUnit)
  1267.     if pUnit:GetHealthPct() < 20 then
  1268.         local a = pUnit:GetCreatureNearestCoords(-11041, -2334.4, 146.8, 25525)
  1269.         local b = pUnit:GetCreatureNearestCoords(-11091, -2332.4, 146.3, 25525)
  1270.         if a and b then
  1271.             pUnit:RemoveEvents()
  1272.             pUnit:Root()
  1273.             pUnit:CastSpell(22663) -- immune to all damage
  1274.             pUnit:AIDisableCombat(true)
  1275.             local ad = pUnit:GetDistanceYards(a)
  1276.             local bd = pUnit:GetDistanceYards(b)
  1277.             if ad > bd then
  1278.                 pUnit:ChannelSpell(76221, b)
  1279.                 pUnit:RegisterEvent("ZG.VAR.HatchEggsBBB", 7500, 1)
  1280.             else
  1281.                 pUnit:ChannelSpell(76221, a)
  1282.                 pUnit:RegisterEvent("ZG.VAR.HatchEggsAAA", 7500, 1)
  1283.             end
  1284.         end
  1285.     end
  1286. end
  1287.  
  1288. function ZG.VAR.HatchEggsBBB(pUnit)
  1289.     pUnit:RemoveAura(22663)
  1290.     pUnit:CastSpell(32711) -- AoE
  1291.     pUnit:StopChannel()
  1292.     for i=1,math.random(5,12) do
  1293.         pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
  1294.     end
  1295.     pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 500, 1)
  1296. end
  1297.  
  1298. function ZG.VAR.HatchEggsAAA(pUnit)
  1299.     pUnit:RemoveAura(22663)
  1300.     pUnit:CastSpell(32711) -- AoE
  1301.     pUnit:StopChannel()
  1302.     for i=1,math.random(5,12) do
  1303.         pUnit:SpawnCreature(497111, -11042, -2333.4, 146.7, 2.853576, 15, 120000)
  1304.     end
  1305.     pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 250, 1)
  1306. end
  1307.  
  1308. function ZG.VAR.KILL_SELF_INSEC(pUnit)
  1309.     pUnit:Kill(pUnit)
  1310. end
  1311.  
  1312. RegisterUnitEvent(871111, 1, "ZG.VAR.DRACONICLORDEVENT")
  1313. RegisterUnitEvent(871111, 2, "ZG.VAR.DRACONICLORDEVENT")
  1314. RegisterUnitEvent(871111, 4, "ZG.VAR.DRACONICLORDEVENT")
  1315. RegisterUnitEvent(871111, 18, "ZG.VAR.DRACONICLORDEVENT")
  1316.  
  1317. -- Whelps
  1318.  
  1319. function ZG.VAR.WhelpsOverwhelmingDrac(pUnit, Event)
  1320.     pUnit:RegisterEvent("ZG.VAR.WHelpsFactionsMove", math.random(900, 2000), 1)
  1321. end
  1322.  
  1323. function ZG.VAR.WHelpsFactionsMove(pUnit)
  1324.     pUnit:SetFaction(21)
  1325.     local plr = pUnit:GetRandomPlayer(0)
  1326.     if plr ~= nil then
  1327.         pUnit:SetMovementFlags(1)
  1328.         pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1329.         pUnit:ChangeTarget(plr)
  1330.     end
  1331. end
  1332.  
  1333. RegisterUnitEvent(497111, 18, "ZG.VAR.WhelpsOverwhelmingDrac")
  1334.  
  1335. -- avoid these balls
  1336.  
  1337. function ZG.VAR.DESEMAGIZAVOID(pUnit)
  1338.     if Event == 4 then
  1339.         pUnit:RemoveEvents()
  1340.     else
  1341.         pUnit:RegisterEvent("ZG.VAR.VisualReadyGoGO", 1000, 1)
  1342.         pUnit:RegisterEvent("ZG.VAR.MOVETOWARDS_PLAYZ", 1000, 0)
  1343.     end
  1344. end
  1345.  
  1346. function ZG.VAR.VisualReadyGoGO(pUnit)
  1347.     pUnit:ChannelSpell(56220, pUnit)
  1348.     pUnit:AIDisableCombat(true)
  1349.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
  1350. end
  1351.  
  1352. function ZG.VAR.MOVETOWARDS_PLAYZ(pUnit)
  1353.     local plr = pUnit:GetClosestPlayer()
  1354.     if plr ~= nil then
  1355.         if not plr:IsAlive() then
  1356.             plr = pUnit:GetRandomPlayer(0)
  1357.             if plr ~= nil then
  1358.                 pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1359.             end
  1360.         else
  1361.             local trigger = pUnit:GetCreatureNearestCoords(-11062, -2306, 146, 27942)
  1362.             if trigger then
  1363.                 if trigger:HasAura(63894) then
  1364.                     if pUnit:GetDistanceYards(trigger) < 12 then
  1365.                         pUnit:StopMovement(100)
  1366.                     end
  1367.                 else
  1368.                     pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1369.                 end
  1370.             end
  1371.         end
  1372.     end
  1373.     for _,plrs in pairs(pUnit:GetInRangeUnits()) do
  1374.         if plrs:GetDistanceYards(pUnit) < 8 then
  1375.             if plrs:IsPlayer() then
  1376.                 if pUnit:GetDistanceYards(plrs) < 5 then
  1377.                     pUnit:Strike(plrs, 2, 59322, 250, 300, 1)
  1378.                 end
  1379.             else
  1380.                 if plrs:GetEntry() ~= 4052 and plrs:GetEntry() ~= 36544 and plrs:GetEntry() ~= 27942 then
  1381.                     if not plrs:HasAura(22663) then
  1382.                         if (plrs:GetHealth()-150) < 1 then
  1383.                             plrs:Kill(plrs)
  1384.                         else
  1385.                             plrs:SetHealth(plrs:GetHealth()-150)
  1386.                         end
  1387.                     end
  1388.                 else
  1389.                     local choice = math.random(1,11)
  1390.                     if choice == 1 then
  1391.                         plrs:SendChatMessage(14,0,"Ugh, get this thing off me!")
  1392.                     elseif choice == 2 then
  1393.                         plrs:SendChatMessage(14,0,"It burns!")
  1394.                     end
  1395.                 end
  1396.             end
  1397.         end
  1398.     end
  1399. end
  1400.  
  1401. RegisterUnitEvent(21234, 18, "ZG.VAR.DESEMAGIZAVOID")
  1402. RegisterUnitEvent(21234, 4, "ZG.VAR.DESEMAGIZAVOID")
  1403.  
  1404. -- The druids
  1405.  
  1406.  
  1407. -- if entry == 36544 or entry == 4052 then
  1408.  
  1409. function ZG.VAR.MainLeaderSpawn_Event(pUnit, Event)
  1410.     if Event == 1 then
  1411.         pUnit:Root()
  1412.         pUnit:RegisterEvent("ZG.VAR.MainSpells_Dragon_Add", 4000, 0)
  1413.     elseif Event == 2 or 4 then
  1414.         pUnit:RemoveEvents()
  1415.     elseif Event == 18 then
  1416.         local plr = pUnit:GetClosestPlayer()
  1417.         if plr ~= nil then
  1418.             pUnit:SetMovementFlags(1)
  1419.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1420.         end
  1421.     end
  1422. end
  1423.  
  1424. function ZG.VAR.MainSpells_Dragon_Add(pUnit)
  1425.     local plr = pUnit:GetClosestPlayer()
  1426.     if plr ~= nil then
  1427.         pUnit:FullCastSpellOnTarget(8950, plr) -- starfire
  1428.     end
  1429. end
  1430.  
  1431. RegisterUnitEvent(36544, 1, "ZG.VAR.MainLeaderSpawn_Event")
  1432. RegisterUnitEvent(36544, 2, "ZG.VAR.MainLeaderSpawn_Event")
  1433. RegisterUnitEvent(36544, 4, "ZG.VAR.MainLeaderSpawn_Event")
  1434. RegisterUnitEvent(36544, 18, "ZG.VAR.MainLeaderSpawn_Event")
  1435.  
  1436. function ZG.VAR.AddEvent_Dragon(pUnit, Event)
  1437.     if Event == 1 then
  1438.         pUnit:Root()
  1439.         pUnit:RegisterEvent("ZG.VAR.AddSpells_Dragon", 2500, 0)
  1440.     elseif Event == 2 or Event == 4 then
  1441.         pUnit:RemoveEvents()
  1442.         local PlayersAllAround = pUnit:GetInRangePlayers()
  1443.   for a, players in pairs(PlayersAllAround) do
  1444.     if pUnit:GetDistanceYards(players) < 50 then
  1445.         if players:HasAchievement(59387) == false then
  1446.                     players:AddAchievement(59387)
  1447.                     end
  1448.     end
  1449.     end
  1450.     elseif Event == 18 then
  1451.         local plr = pUnit:GetClosestPlayer()
  1452.         if plr ~= nil then
  1453.             pUnit:SetMovementFlags(1)
  1454.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1455.         end
  1456.     end
  1457. end
  1458.  
  1459. function ZG.VAR.AddSpells_Dragon(pUnit)
  1460.     local plr = pUnit:GetClosestPlayer()
  1461.     if plr ~= nil then
  1462.         pUnit:FullCastSpellOnTarget(9739, plr) -- Wrath
  1463.     end
  1464. end
  1465.  
  1466. RegisterUnitEvent(4052, 1, "ZG.VAR.AddEvent_Dragon")
  1467. RegisterUnitEvent(4052, 2, "ZG.VAR.AddEvent_Dragon")
  1468. RegisterUnitEvent(4052, 4, "ZG.VAR.AddEvent_Dragon")
  1469. RegisterUnitEvent(4052, 18, "ZG.VAR.AddEvent_Dragon")
  1470.  
  1471. -- Hack fix, stop people falling down ----------------------------------------
  1472.  
  1473. function ZG.VAR.Check_Players_InZG()
  1474.     for place,plrs in pairs(GetPlayersInWorld()) do
  1475.         if plrs and plrs ~= nil then
  1476.             if plrs:GetMapId() == 309 then
  1477.                 if (plrs:IsAlive() and plrs:GetZ() < 52 and plrs:GetY() > -2135) then
  1478.                     plrs:SetHealth(1)
  1479.                     plrs:CastSpell(11)
  1480.                     plrs:CastSpell(46995) -- visual
  1481.                     plrs:CastSpell(39180) -- visual
  1482.                 end
  1483.                 if (not plrs:HasAura(35480) and not plrs:HasAura(35481)) then -- added female aura
  1484.                     if plrs:GetGender() == 0 then -- added gender check
  1485.                         plrs:CastSpell(35480)
  1486.                     else
  1487.                         plrs:CastSpell(35481)
  1488.                     end
  1489.                 end
  1490.             elseif plrs:HasAura(35480) or plrs:HasAura(35481) then
  1491.                 if plrs:GetGender() == 0 then
  1492.                     plrs:RemoveAura(35480)
  1493.                 else
  1494.                     plrs:RemoveAura(35481)
  1495.                 end
  1496.             elseif plrs:GetMapId() == 578 then
  1497.                 if (plrs:IsAlive() and plrs:GetZ() < 425 and plrs:GetY() > 450) then
  1498.                     plrs:Teleport(578,1046,1032,432.516541)
  1499.                     plrs:CastSpell(51347)
  1500.                 end
  1501.             end
  1502.         end
  1503.     end
  1504. end
  1505.    
  1506.  
  1507. RegisterTimedEvent("ZG.VAR.Check_Players_InZG", 5000, 0)
Advertisement
Add Comment
Please, Sign In to add comment