Advertisement
stoneharry

Untitled

May 13th, 2012
1,753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.61 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:PlaySoundToSet(11729) -- Black Temple final battle
  40.             pUnit:RemoveEvents()
  41.             pUnit:StopChannel()
  42.             pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0.111894)
  43.             pUnit:SendChatMessage(14,0,"Life energy, to consume...")
  44.             pUnit:PlaySoundToSet(11250)
  45.             pUnit:RegisterEvent("ZG.VAR.BeginEventMainBoss", 3000, 1)
  46.         end
  47.     end
  48. end
  49.  
  50. function ZG.VAR.BeginEventMainBoss(pUnit)
  51.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
  52. end
  53.  
  54. RegisterUnitEvent(20738, 18, "ZG.VAR.MainBossSpawn")
  55.  
  56. --------------------------------------------------------
  57.  
  58. function ZG.VAR.MainBossHnadler(pUnit, Event)
  59.     if Event == 1 then
  60.         -- entered combat
  61.         pUnit:SetScale(1)
  62.         pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 7500, 0)
  63.         pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 7000, 0)
  64.         pUnit:RegisterEvent("ZG.VAR.MainTimeFreeze", 8000, 0)
  65.         pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 10000, 1)
  66.         pUnit:RegisterEvent("ZG.VAR.CheckForPhaseTwoMain", 2000, 0)
  67.     elseif Event == 2 then
  68.         -- Left combat
  69.         pUnit:RemoveEvents()
  70.         pUnit:RegisterEvent("ZG.VAR.MainBossSpawn", 6000, 1)
  71.     elseif Event == 3 then
  72.         -- killed someone
  73.     elseif Event == 4 then
  74.         -- Got killed
  75.         pUnit:RemoveEvents()
  76.         pUnit:PlaySoundToSet(11252)
  77.         pUnit:SendChatMessage(14,0,"No more life...")
  78.     end
  79. end
  80.  
  81. function ZG.VAR.MainGrowAndPwnStuff(pUnit)
  82.     pUnit:CastSpell(72679) -- Grow and shizzle
  83.     if math.random(1,2) == 1 then
  84.         pUnit:SendChatMessage(14,0,"Darkness consumes all.")
  85.         pUnit:PlaySoundToSet(11254)
  86.     else
  87.         pUnit:SendChatMessage(14,0,"The shadow will in cone you.")
  88.         pUnit:PlaySoundToSet(11253)
  89.     end
  90.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", math.random(18000, 35000), 1)
  91. end
  92.  
  93. function ZG.VAR.MainRandomVisuals(pUnit)
  94.     local plr = pUnit:GetRandomPlayer(0)
  95.     if plr ~= nil then
  96.         pUnit:CastSpellOnTarget(73539, plr) -- random visual
  97.     end
  98. end
  99.  
  100. function ZG.VAR.MainShadowCleave(pUnit)
  101.     local plr = pUnit:GetMainTank()
  102.     if plr ~= nil then
  103.         pUnit:FullCastSpellOnTarget(31629, plr)
  104.     end
  105. end
  106.  
  107. function ZG.VAR.MainTimeFreeze(pUnit)
  108.     local plr = pUnit:GetRandomPlayer(0)
  109.     if plr ~= nil then
  110.         pUnit:FullCastSpellOnTarget(40951, plr)
  111.     end
  112. end
  113.  
  114. function ZG.VAR.CheckForPhaseTwoMain(pUnit)
  115.     if pUnit:GetHealthPct() < 75 then
  116.         pUnit:RemoveEvents()
  117.         pUnit:PlaySoundToSet(8888) -- More general eerie music
  118.         pUnit:SendChatMessage(14,0,"No more life.")
  119.         pUnit:PlaySoundToSet(11252)
  120.         pUnit:AIDisableCombat(true) -- Requires custom patch to work
  121.         pUnit:MoveTo(-11101, -2021, 147, 0)
  122.         pUnit:RegisterEvent("ZG.VAR.BringItOnMainBoss", 6000, 1)
  123.     end
  124. end
  125.  
  126. function ZG.VAR.BringItOnMainBoss(pUnit)
  127.     pUnit:ChannelSpell(12380, pUnit)
  128.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 1000, 0)
  129.     if pUnit:GetHealthPct() < 35 then
  130.         pUnit:RegisterEvent("ZG.VAR.MainEndVisualfinal", 15500, 1)
  131.     else
  132.         pUnit:RegisterEvent("ZG.VAR.MainEndVisual", 15500, 1)
  133.     end
  134. end
  135.  
  136. function ZG.VAR.MainEndVisual(pUnit)
  137.     pUnit:RemoveEvents()
  138.     pUnit:StopChannel()
  139.     pUnit:AIDisableCombat(false) -- Requires custom patch to work
  140.     -- Time to troll
  141.     local plr = pUnit:GetRandomPlayer(0)
  142.     if plr ~= nil then
  143.         pUnit:FullCastSpellOnTarget(40251, plr) -- kills them after 55 seconds
  144.     end
  145.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 7500, 0)
  146.     pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 7000, 0)
  147.     pUnit:RegisterEvent("ZG.VAR.MainDisoreitnate", 12000, 0)
  148.     pUnit:RegisterEvent("ZG.VAR.MainShroudGuys", 6000, 0)
  149.     pUnit:RegisterEvent("ZG.VAR.MainDeathGrip", 8000, 0)
  150.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 20000, 1)
  151.     pUnit:RegisterEvent("ZG.VAR.CheckForNextMainPhase", 2000, 0)
  152. end
  153.  
  154. function ZG.VAR.MainDisoreitnate(pUnit)
  155.     local plr = pUnit:GetClosestPlayer()
  156.     if plr ~= nil then
  157.         pUnit:FullCastSpellOnTarget(26108, plr) -- cause to run around randomly for 3 seconds
  158.     end
  159. end
  160.  
  161. function ZG.VAR.MainShroudGuys(pUnit)
  162.     local plr = pUnit:GetRandomPlayer(0)
  163.     if plr ~= nil then
  164.         plr:CastSpell(40251) -- shroud of darkness
  165.     end
  166. end
  167.  
  168. function ZG.VAR.MainDeathGrip(pUnit)
  169.     local plr = pUnit:GetRandomPlayer2(0)
  170.     if plr ~= nil then
  171.         pUnit:FullCastSpellOnTarget(64429, plr) -- visual
  172.         plr:MoveKnockback(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 10, 20)
  173.     end
  174. end
  175.  
  176. function ZG.VAR.CheckForNextMainPhase(pUnit)
  177.     if pUnit:GetHealthPct() < 35 then
  178.         pUnit:PlaySoundToSet(8888) -- More general eerie music
  179.         pUnit:RemoveEvents()
  180.         pUnit:SendChatMessage(14,0,"No more life.")
  181.         pUnit:PlaySoundToSet(11252)
  182.         pUnit:AIDisableCombat(true) -- Requires custom patch to work
  183.         pUnit:MoveTo(-11101, -2021, 147, 0)
  184.         pUnit:RegisterEvent("ZG.VAR.BringItOnMainBoss", 6000, 1)
  185.     end
  186. end
  187.  
  188. function ZG.VAR.MainEndVisualfinal(pUnit)
  189.     pUnit:RemoveEvents()
  190.     pUnit:StopChannel()
  191.     pUnit:AIDisableCombat(false) -- Requires custom patch to work
  192.     -- Time to troll
  193.     local plr = pUnit:GetRandomPlayer(0)
  194.     if plr ~= nil then
  195.         pUnit:FullCastSpellOnTarget(40251, plr) -- kills them after 55 seconds
  196.     end
  197.     pUnit:RegisterEvent("ZG.VAR.MainRandomVisuals", 9000, 0)
  198.     pUnit:RegisterEvent("ZG.VAR.MainShadowCleave", 8000, 0)
  199.     pUnit:RegisterEvent("ZG.VAR.MainDisoreitnate", 10000, 0)
  200.     pUnit:RegisterEvent("ZG.VAR.MainShroudGuys", 6000, 0)
  201.     pUnit:RegisterEvent("ZG.VAR.MainDeathGrip", 6000, 0)
  202.     pUnit:RegisterEvent("ZG.VAR.MainTimeFreeze", 10000, 0)
  203.     pUnit:RegisterEvent("ZG.VAR.MainGrowAndPwnStuff", 10000, 1)
  204. end
  205.  
  206. RegisterUnitEvent(20738, 1, "ZG.VAR.MainBossHnadler")
  207. RegisterUnitEvent(20738, 2, "ZG.VAR.MainBossHnadler")
  208. RegisterUnitEvent(20738, 3, "ZG.VAR.MainBossHnadler")
  209. RegisterUnitEvent(20738, 4, "ZG.VAR.MainBossHnadler")
  210.  
  211. -- Void zones -- spawned from the spell impact
  212.  
  213. function ZG.VAR.VoidZoneSpawn(pUnit, Event)
  214.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
  215.     pUnit:Root()
  216.     pUnit:SetCombatCapable(false)
  217.     pUnit:RegisterEvent("ZG.VAR.SendVisualVoidZone", 250, 1)
  218.     pUnit:RegisterEvent("ZG.VAR.DamageNearbyZone", 1000, 0)
  219. end
  220.  
  221. function ZG.VAR.DamageNearbyZone(pUnit)
  222.     for k,plrs in pairs(pUnit:GetInRangePlayers()) do
  223.         if pUnit:GetDistanceYards(plrs) < 6 then
  224.             pUnit:Strike(plrs, 2, 695, 90, 100, 1)
  225.         end
  226.     end
  227. end
  228.  
  229. function ZG.VAR.SendVisualVoidZone(pUnit)
  230.     pUnit:FullCastSpell(73525)
  231.     pUnit:RegisterEvent("ZG.VAR.VoidZoneDespawn", 25500, 1)
  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:PlaySoundToSet(15861)
  842.                 ZG[id].VAR.leader:SendChatMessage(12,0,"Hurry mortals, I cannot hold the beast back for long!")
  843.                 pUnit:RemoveEvents()
  844.                 pUnit:RegisterEvent("ZG.VAR.HEREWEGO_DRAGON", 4000, 1)
  845.             end
  846.         end
  847.     end
  848. end
  849.  
  850. function ZG.VAR.HEREWEGO_DRAGON(pUnit)
  851.     local id = pUnit:GetInstanceID()
  852.     if id == nil then id = 1 end
  853.     ZG[id] = ZG[id] or {VAR={}}
  854.     pUnit:SendChatMessage(14,0,"ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!")
  855.     pUnit:SpawnGameObject(146086, -11095.85, -2318.86, 147.5, 6.154612, 900000, 100) -- cave in
  856.     ZG[id].VAR.leader:PlaySoundToSet(8289)
  857.     ZG[id].VAR.leader:StopChannel()
  858.     ZG[id].VAR.addA:StopChannel()
  859.     ZG[id].VAR.addB:StopChannel()
  860.     ZG[id].VAR.addC:StopChannel()
  861.     ZG[id].VAR.addD:StopChannel()
  862.     pUnit:RegisterEvent("ZG.VAR.WaitForVisualsToPlayDURP", 250, 1)
  863.     ZG[id].VAR.e = 0
  864.     ZG[id].VAR.hpCount = 1
  865.     ZG[id].VAR.hpList = {90,80,70,60,50,40,30,20,10}
  866.     pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 7000, 1)
  867.     pUnit:RegisterEvent("ZG.VAR.DrainDragonBossHealth", 500, 0)
  868.     pUnit:RegisterEvent("ZG.VAR.DragonBossCheckForWipe_Astarot", 2000, 0)
  869.     pUnit:RegisterEvent("ZG.VAR.DragonDespawnDeadTrash", 10000, 0)
  870. end
  871.  
  872. function ZG.VAR.WaitForVisualsToPlayDURP(pUnit)
  873.     local id = pUnit:GetInstanceID()
  874.     if id == nil then id = 1 end
  875.     ZG[id] = ZG[id] or {VAR={}}
  876.     ZG[id].VAR.leader:CastSpell(68848)
  877.     ZG[id].VAR.addA:CastSpell(68848) -- knockdown visual
  878.     ZG[id].VAR.addB:CastSpell(68848)
  879.     ZG[id].VAR.addC:CastSpell(68848)
  880.     ZG[id].VAR.addD:CastSpell(68848)
  881. end
  882.  
  883. function ZG.VAR.DrainDragonBossHealth(pUnit)
  884.     local id = pUnit:GetInstanceID()
  885.     if id == nil then id = 1 end
  886.     ZG[id] = ZG[id] or {VAR={}}
  887.     if pUnit:GetHealthPct() > ZG[id].VAR.hpList[ZG[id].VAR.hpCount] then
  888.         pUnit:SetHealth(pUnit:GetHealth()-200)
  889.     end
  890.     --[[if pUnit:GetPower() < pUnit:GetMaxPower() then
  891.         pUnit:SetPower(pUnit:GetPower(2)+1, 2)
  892.     end]]
  893. end
  894.  
  895. function ZG.VAR.BeginZeEventZZ(pUnit)
  896.     local id = pUnit:GetInstanceID()
  897.     if id == nil then id = 1 end
  898.     ZG[id] = ZG[id] or {VAR={}}
  899.     ZG[id].VAR.e = ZG[id].VAR.e + 1
  900.     if ZG[id].VAR.e == 1 then
  901.         ZG[id].VAR.leader:SendChatMessage(12,0,"Mortals, you must defend us while we attempt to destroy this being, or all hope is lost!")
  902.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 3000, 1)
  903.     elseif ZG[id].VAR.e == 2 then
  904.         ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
  905.         ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
  906.         ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
  907.         ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)     
  908.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  909.     elseif ZG[id].VAR.e == 3 then
  910.         ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
  911.         --ZG[id].VAR.e = 15 -- DEBUG -------------------------------------------------------------------------
  912.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  913.     elseif ZG[id].VAR.e == 4 then
  914.         pUnit:CastSpellAoF(-11062.66, -2297.34, 146, 68926)
  915.         pUnit:SpawnCreature(21234, -11062.66, -2297.34, 146, 0, 15, 300000)
  916.         ZG[id].VAR.dragons = 0
  917.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 2)
  918.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)
  919.     elseif ZG[id].VAR.e == 5 then
  920.         local found = false
  921.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  922.             local entry = unit:GetEntry()
  923.             if entry == 871111 or entry == 497111 then
  924.                 if unit:IsAlive() then
  925.                     found = true
  926.                     break
  927.                 end
  928.             end
  929.         end
  930.         if not found then
  931.             ZG[id].VAR.leader:PlaySoundToSet(8291)
  932.             pUnit:SendChatMessage(14,0,"Impossible! Rise my minions! Serve your master once more!")
  933.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  934.         else
  935.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  936.         end
  937.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  938.     elseif ZG[id].VAR.e == 6 then
  939.         ZG[id].VAR.dragons = 0
  940.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
  941.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)     
  942.     elseif ZG[id].VAR.e == 7 then
  943.         local found = false
  944.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  945.             local entry = unit:GetEntry()
  946.             if entry == 871111 or entry == 497111 then
  947.                 if unit:IsAlive() then
  948.                     found = true
  949.                     break
  950.                 end
  951.             end
  952.         end
  953.         if not found then
  954.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  955.             ZG[id].VAR.leader:PlaySoundToSet(8290)
  956.             pUnit:SendChatMessage(14,0,"Burn, you wretches! Burn!")
  957.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  958.             local trigger = pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942)
  959.             trigger:SetScale(0.8)
  960.             trigger:CastSpell(63894) -- shield
  961.         else
  962.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  963.         end
  964.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  965.     elseif ZG[id].VAR.e == 8 then
  966.         ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
  967.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
  968.     elseif ZG[id].VAR.e == 9 then
  969.         for i=1,100 do
  970.             pUnit:RegisterEvent("ZG.VAR.METEORSINCOMINGDUN_DUN", math.random(1000,20000),1)
  971.         end
  972.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 23000, 1)
  973.     elseif ZG[id].VAR.e == 10 then
  974.         pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942):RemoveAura(63894) -- shield
  975.         ZG[id].VAR.leader:PlaySoundToSet(8292)
  976.         pUnit:SendChatMessage(14,0,"This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!")
  977.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
  978.     elseif ZG[id].VAR.e == 11 then
  979.         ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  980.         ZG[id].VAR.dragons = 0
  981.         pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 4)
  982.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
  983.     elseif ZG[id].VAR.e == 12 then
  984.         local found = false
  985.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  986.             local entry = unit:GetEntry()
  987.             if entry == 871111 or entry == 497111 then
  988.                 if unit:IsAlive() then
  989.                     found = true
  990.                     break
  991.                 end
  992.             end
  993.         end
  994.         if not found then
  995.             for _,unit in pairs(pUnit:GetInRangeUnits()) do
  996.                 if unit:GetEntry() == 21234 then
  997.                     unit:Kill(unit)
  998.                     break
  999.                 end
  1000.             end
  1001.             ZG[id].VAR.leader:PlaySoundToSet(8291)
  1002.             pUnit:SendChatMessage(14,0,"Impossible! Rise my minions! Serve your master once more!")
  1003.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1004.             ZG[id].VAR.dragons = 0
  1005.             pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
  1006.             pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
  1007.         else
  1008.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1009.             pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1010.         end
  1011.     elseif ZG[id].VAR.e == 13 then
  1012.         local found = false
  1013.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1014.             local entry = unit:GetEntry()
  1015.             if entry == 871111 or entry == 497111 then
  1016.                 if unit:IsAlive() then
  1017.                     found = true
  1018.                     break
  1019.                 end
  1020.             end
  1021.         end
  1022.         if not found then
  1023.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1024.             ZG[id].VAR.leader:PlaySoundToSet(8290)
  1025.             pUnit:SendChatMessage(14,0,"Burn, you wretches! Burn!")
  1026.             ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
  1027.             local trigger = pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942)
  1028.             trigger:SetScale(0.8)
  1029.             trigger:CastSpell(63894) -- shield
  1030.         else
  1031.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1032.         end
  1033.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)  
  1034.     elseif ZG[id].VAR.e == 14 then
  1035.         ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
  1036.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2500, 1)
  1037.     elseif ZG[id].VAR.e == 15 then
  1038.         for i=1,100 do
  1039.             pUnit:RegisterEvent("ZG.VAR.METEORSINCOMINGDUN_DUN", math.random(1000,20000),1)
  1040.         end
  1041.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 23000, 1)
  1042.     elseif ZG[id].VAR.e == 16 then
  1043.         pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942):RemoveAura(63894) -- shield
  1044.         ZG[id].VAR.leader:PlaySoundToSet(8292)
  1045.         pUnit:SendChatMessage(14,0,"This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!")
  1046.         pUnit:SetHealthPct(10)
  1047.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1048.     elseif ZG[id].VAR.e == 17 then
  1049.         --pUnit:ChannelSpell(68834, ZG[id].VAR.leader)
  1050.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
  1051.     elseif ZG[id].VAR.e == 18 then
  1052.         ZG[id].VAR.leader:SendChatMessage(14,0,"No!")
  1053.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
  1054.     elseif ZG[id].VAR.e == 19 then
  1055.         ZG[id].VAR.leader:SendChatMessage(12,0,"Death to the interlopers.")
  1056.         ZG[id].VAR.leader:StopChannel()
  1057.         ZG[id].VAR.leader:CastSpell(41535) -- chains visual
  1058.         ZG[id].VAR.addA:StopChannel()
  1059.         ZG[id].VAR.addB:StopChannel()
  1060.         ZG[id].VAR.addC:StopChannel()
  1061.         ZG[id].VAR.addD:StopChannel()
  1062.         ZG[id].VAR.addcount = 0
  1063.         pUnit:RegisterEvent("ZG.VAR.SetFactionsOfNPCSDragon", 1000, 4)
  1064.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
  1065.     elseif ZG[id].VAR.e == 20 then
  1066.         ZG[id].VAR.addA:SetFaction(21)
  1067.         ZG[id].VAR.addB:SetFaction(21)
  1068.         ZG[id].VAR.addC:SetFaction(21)
  1069.         ZG[id].VAR.addD:SetFaction(21)
  1070.         ZG[id].VAR.leader:SetFaction(21)
  1071.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
  1072.     elseif ZG[id].VAR.e == 21 then
  1073.         local found = false
  1074.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1075.             local entry = unit:GetEntry()
  1076.             if entry == 36544 or entry == 4052 then
  1077.                 if unit:IsAlive() then
  1078.                     found = true
  1079.                     break
  1080.                 end
  1081.             end
  1082.         end
  1083.         if not found then
  1084.             ZG[id].VAR.leader:PlaySoundToSet(8293)
  1085.             pUnit:SendChatMessage(14,0,"Worthless wretch! Your friends will join you soon enough!")
  1086.             pUnit:SetHealth(132)
  1087.         else
  1088.             ZG[id].VAR.e = ZG[id].VAR.e - 1
  1089.         end
  1090.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)      
  1091.     elseif ZG[id].VAR.e == 22 then
  1092.         pUnit:MoveTo(-11064, -2310.88, 146.2, 0)
  1093.         pUnit:RegisterEvent("ZG.VAR.VisuzlzzBoss", 100, 0)
  1094.         pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 6000, 1)  
  1095.     elseif ZG[id].VAR.e == 23 then
  1096.         pUnit:RemoveEvents()
  1097.         --[[for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  1098.             if pUnit:IsAlive() then
  1099.                 plrs:CastSpellOnTarget(11, pUnit)
  1100.             end
  1101.         end]]
  1102.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1103.             local entry = unit:GetEntry()
  1104.             if entry == 21234 or entry == 871111 or entry == 36544 or entry == 497111 or entry == 4052 then
  1105.                 if not unit:IsAlive() then
  1106.                     unit:Despawn(1,0)
  1107.                 end
  1108.             end
  1109.         end
  1110.         local object = pUnit:GetGameObjectNearestCoords(-11095.5, -2318.3, 147.5, 146086) -- rocks
  1111.         if object ~= nil then
  1112.             object:Despawn(1,0)
  1113.         end
  1114.         pUnit:SpawnGameObject(355101, -11064, -2329.5, 146.6, 4.679757, 300000, 100) -- chest
  1115.         pUnit:Kill(pUnit)
  1116.     end
  1117. end
  1118.  
  1119. function ZG.VAR.SetFactionsOfNPCSDragon(pUnit)
  1120.     local id = pUnit:GetInstanceID()
  1121.     if id == nil then id = 1 end
  1122.     ZG[id] = ZG[id] or {VAR={}}
  1123.     ZG[id].VAR.addcount = ZG[id].VAR.addcount + 1
  1124.     if ZG[id].VAR.addcount == 1 then
  1125.         ZG[id].VAR.addA:CastSpell(41535)
  1126.     elseif ZG[id].VAR.addcount == 2 then
  1127.         ZG[id].VAR.addB:CastSpell(41535)
  1128.     elseif ZG[id].VAR.addcount == 3 then
  1129.         ZG[id].VAR.addC:CastSpell(41535)
  1130.     elseif ZG[id].VAR.addcount == 4 then
  1131.         ZG[id].VAR.addD:CastSpell(41535)
  1132.     end
  1133. end
  1134.  
  1135. function ZG.VAR.VisuzlzzBoss(pUnit)
  1136.     pUnit:CastSpell(32711) -- AoE visual
  1137. end
  1138.  
  1139. function ZG.VAR.METEORSINCOMINGDUN_DUN(pUnit)
  1140.     pUnit:SetPower(pUnit:GetPower(2)-3, 2)
  1141.     local nx = math.random(11051,11087)
  1142.     local ny = math.random(2325,2341)
  1143.     pUnit:CastSpellAoF(-nx,-ny,pUnit:GetLandHeight(-nx,-ny),57467)
  1144.     if math.random(1,100) < 13 then -- Since the square doesn't cover the sides of the shield, we'll hit those gaps
  1145.         if math.random(1,2) == 1 then
  1146.             pUnit:CastSpellAoF(-11048.75, -2320.6, 147.8,57467)
  1147.         else
  1148.             pUnit:CastSpellAoF(-11078.3, -2315, 147,57467)
  1149.         end
  1150.     end
  1151. end
  1152.  
  1153. function ZG.VAR.SpawnMoreDamnDragonLords(pUnit)
  1154.     local id = pUnit:GetInstanceID()
  1155.     if id == nil then id = 1 end
  1156.     ZG[id] = ZG[id] or {VAR={}}
  1157.     if ZG[id].VAR.dragons == 0 then
  1158.         pUnit:CastSpellAoF(-11042, -2333, 146.65, 68926)
  1159.         pUnit:SpawnCreature(871111, -11042, -2333, 146.8, 2.67, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  1160.     elseif ZG[id].VAR.dragons == 1 then
  1161.         pUnit:CastSpellAoF(-11089.64, -2331.76, 146.3, 68926)
  1162.         pUnit:SpawnCreature(871111, -11089.64, -2331.76, 146.3, 0.37, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  1163.     elseif ZG[id].VAR.dragons == 2 then
  1164.         pUnit:CastSpellAoF(-11090.4, -2332, 146.3, 68926)
  1165.         for i=1,math.random(5,12) do
  1166.             pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
  1167.         end
  1168.     elseif ZG[id].VAR.dragons == 3 then
  1169.         pUnit:CastSpellAoF(-11042.7, -2333, 146.7, 68926)
  1170.         for i=1,math.random(9,15) do
  1171.             pUnit:SpawnCreature(497111, -11042.7, -2333, 146.7, 2.649929, 15, 120000)
  1172.         end
  1173.     end
  1174.     ZG[id].VAR.dragons = ZG[id].VAR.dragons + 1
  1175. end
  1176.  
  1177. function ZG.VAR.DragonDespawnDeadTrash(pUnit)
  1178.     for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1179.         local entry = unit:GetEntry()
  1180.         if entry == 21234 or entry == 871111 or entry == 36544 or entry == 497111 or entry == 4052 then
  1181.             if not unit:IsAlive() then
  1182.                 --pUnit:CastSpellAoF(unit:GetX(), unit:GetY(), unit:GetZ(), 68926) -- causes too much damage
  1183.                 unit:Despawn(1,0)
  1184.             end
  1185.         end
  1186.     end
  1187. end
  1188.  
  1189. function ZG.VAR.DragonBossCheckForWipe_Astarot(pUnit)
  1190.     local found = false
  1191.     for _,plr in pairs(pUnit:GetInRangePlayers()) do
  1192.         if plr:GetZ() < 143 or plr:GetZ() > 149 then
  1193.             plr:Teleport(309, -11070, -2328.8, 150)
  1194.             plr:CastSpell(64446) -- teleport visual
  1195.         end
  1196.         if not found then
  1197.             if plr:IsAlive() then
  1198.                 found = true
  1199.             end
  1200.         end
  1201.     end
  1202.     if not found then
  1203.         -- wipe
  1204.         pUnit:RemoveEvents()
  1205.         pUnit:StopChannel()
  1206.         pUnit:SetHealth(pUnit:GetMaxHealth())
  1207.         local object = pUnit:GetGameObjectNearestCoords(-11095.85, -2318.86, 147.5, 146086) -- cave in
  1208.         if object ~= nil then
  1209.             object:Despawn(1000, 0)
  1210.         end
  1211.         for _,unit in pairs(pUnit:GetInRangeUnits()) do
  1212.             local entry = unit:GetEntry()
  1213.             if entry == 21234 or entry == 871111 or entry == 497111 or entry == 36544 or entry == 4052 then
  1214.                 unit:StopChannel()
  1215.                 unit:CancelSpell()
  1216.                 unit:Despawn(1000,0)
  1217.             end
  1218.         end
  1219.         pUnit:RegisterEvent("ZG.VAR.SetUpCreatures_Dragon", 5000, 1)
  1220.     end
  1221. end
  1222.  
  1223. -- 8289 <- ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!
  1224. -- 8290 <- Burn, you wretches! Burn!
  1225. -- 8291 <- Impossible! Rise my minions! Serve your master once more!
  1226. -- 8292 <- This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!
  1227. -- 8293 <- Worthless wretch! Your friends will join you soon enough!
  1228.  
  1229. -- Draconic lords
  1230.  
  1231. function ZG.VAR.DRACONICLORDEVENT(pUnit, Event)
  1232.     if Event == 1 then
  1233.         pUnit:RegisterEvent("ZG.VAR.LordSpamFlameStrike", 10000, 0)
  1234.         pUnit:RegisterEvent("ZG.VAR.SummonWhelpsAndSuchLordd", 1100, 0)
  1235.     elseif Event == 2 or Event == 4 then
  1236.         pUnit:RemoveEvents()
  1237.     elseif Event == 18 then
  1238.         pUnit:RegisterEvent("ZG.VAR.MoveTowardsEnemyZZLord", 1000, 1)
  1239.     end
  1240. end
  1241.  
  1242. function ZG.VAR.LordSpamFlameStrike(pUnit)
  1243.     local plr = pUnit:GetRandomPlayer(0)
  1244.     if plr ~= nil then
  1245.         pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 2121)
  1246.     end
  1247.     plr = pUnit:GetMainTank()
  1248.     if plr ~= nil then
  1249.         if pUnit:GetDistanceYards(plr) < 7 then
  1250.             pUnit:StopMovement(2500)
  1251.             pUnit:FullCastSpellOnTarget(5213, plr)
  1252.         end
  1253.     end
  1254. end
  1255.  
  1256. function ZG.VAR.MoveTowardsEnemyZZLord(pUnit)
  1257.     if not pUnit:IsInCombat() then
  1258.         local plr = pUnit:GetClosestPlayer()
  1259.         if plr ~= nil then
  1260.             pUnit:SetMovementFlags(1)
  1261.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1262.             pUnit:ChangeTarget(plr)
  1263.         end
  1264.     end
  1265. end
  1266.  
  1267. function ZG.VAR.SummonWhelpsAndSuchLordd(pUnit)
  1268.     if pUnit:GetHealthPct() < 20 then
  1269.         local a = pUnit:GetCreatureNearestCoords(-11041, -2334.4, 146.8, 25525)
  1270.         local b = pUnit:GetCreatureNearestCoords(-11091, -2332.4, 146.3, 25525)
  1271.         if a and b then
  1272.             pUnit:RemoveEvents()
  1273.             pUnit:Root()
  1274.             pUnit:CastSpell(22663) -- immune to all damage
  1275.             pUnit:AIDisableCombat(true)
  1276.             local ad = pUnit:GetDistanceYards(a)
  1277.             local bd = pUnit:GetDistanceYards(b)
  1278.             if ad > bd then
  1279.                 pUnit:ChannelSpell(76221, b)
  1280.                 pUnit:RegisterEvent("ZG.VAR.HatchEggsBBB", 7500, 1)
  1281.             else
  1282.                 pUnit:ChannelSpell(76221, a)
  1283.                 pUnit:RegisterEvent("ZG.VAR.HatchEggsAAA", 7500, 1)
  1284.             end
  1285.         end
  1286.     end
  1287. end
  1288.  
  1289. function ZG.VAR.HatchEggsBBB(pUnit)
  1290.     pUnit:RemoveAura(22663)
  1291.     pUnit:CastSpell(32711) -- AoE
  1292.     pUnit:StopChannel()
  1293.     for i=1,math.random(5,12) do
  1294.         pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
  1295.     end
  1296.     pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 500, 1)
  1297. end
  1298.  
  1299. function ZG.VAR.HatchEggsAAA(pUnit)
  1300.     pUnit:RemoveAura(22663)
  1301.     pUnit:CastSpell(32711) -- AoE
  1302.     pUnit:StopChannel()
  1303.     for i=1,math.random(5,12) do
  1304.         pUnit:SpawnCreature(497111, -11042, -2333.4, 146.7, 2.853576, 15, 120000)
  1305.     end
  1306.     pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 250, 1)
  1307. end
  1308.  
  1309. function ZG.VAR.KILL_SELF_INSEC(pUnit)
  1310.     pUnit:Kill(pUnit)
  1311. end
  1312.  
  1313. RegisterUnitEvent(871111, 1, "ZG.VAR.DRACONICLORDEVENT")
  1314. RegisterUnitEvent(871111, 2, "ZG.VAR.DRACONICLORDEVENT")
  1315. RegisterUnitEvent(871111, 4, "ZG.VAR.DRACONICLORDEVENT")
  1316. RegisterUnitEvent(871111, 18, "ZG.VAR.DRACONICLORDEVENT")
  1317.  
  1318. -- Whelps
  1319.  
  1320. function ZG.VAR.WhelpsOverwhelmingDrac(pUnit, Event)
  1321.     pUnit:RegisterEvent("ZG.VAR.WHelpsFactionsMove", math.random(900, 2000), 1)
  1322. end
  1323.  
  1324. function ZG.VAR.WHelpsFactionsMove(pUnit)
  1325.     pUnit:SetFaction(21)
  1326.     local plr = pUnit:GetRandomPlayer(0)
  1327.     if plr ~= nil then
  1328.         pUnit:SetMovementFlags(1)
  1329.         pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1330.         pUnit:ChangeTarget(plr)
  1331.     end
  1332. end
  1333.  
  1334. RegisterUnitEvent(497111, 18, "ZG.VAR.WhelpsOverwhelmingDrac")
  1335.  
  1336. -- avoid these balls
  1337.  
  1338. function ZG.VAR.DESEMAGIZAVOID(pUnit)
  1339.     if Event == 4 then
  1340.         pUnit:RemoveEvents()
  1341.     else
  1342.         pUnit:RegisterEvent("ZG.VAR.VisualReadyGoGO", 1000, 1)
  1343.         pUnit:RegisterEvent("ZG.VAR.MOVETOWARDS_PLAYZ", 1000, 0)
  1344.     end
  1345. end
  1346.  
  1347. function ZG.VAR.VisualReadyGoGO(pUnit)
  1348.     pUnit:ChannelSpell(56220, pUnit)
  1349.     pUnit:AIDisableCombat(true)
  1350.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
  1351. end
  1352.  
  1353. function ZG.VAR.MOVETOWARDS_PLAYZ(pUnit)
  1354.     local plr = pUnit:GetClosestPlayer()
  1355.     if plr ~= nil then
  1356.         if not plr:IsAlive() then
  1357.             plr = pUnit:GetRandomPlayer(0)
  1358.             if plr ~= nil then
  1359.                 pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1360.             end
  1361.         else
  1362.             local trigger = pUnit:GetCreatureNearestCoords(-11062, -2306, 146, 27942)
  1363.             if trigger then
  1364.                 if trigger:HasAura(63894) then
  1365.                     if pUnit:GetDistanceYards(trigger) < 12 then
  1366.                         pUnit:StopMovement(100)
  1367.                     end
  1368.                 else
  1369.                     pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1370.                 end
  1371.             end
  1372.         end
  1373.     end
  1374.     for _,plrs in pairs(pUnit:GetInRangeUnits()) do
  1375.         if plrs:GetDistanceYards(pUnit) < 8 then
  1376.             if plrs:IsPlayer() then
  1377.                 if pUnit:GetDistanceYards(plrs) < 5 then
  1378.                     pUnit:Strike(plrs, 2, 59322, 250, 300, 1)
  1379.                 end
  1380.             else
  1381.                 if plrs:GetEntry() ~= 4052 and plrs:GetEntry() ~= 36544 and plrs:GetEntry() ~= 27942 then
  1382.                     if not plrs:HasAura(22663) then
  1383.                         if (plrs:GetHealth()-150) < 1 then
  1384.                             plrs:Kill(plrs)
  1385.                         else
  1386.                             plrs:SetHealth(plrs:GetHealth()-150)
  1387.                         end
  1388.                     end
  1389.                 else
  1390.                     local choice = math.random(1,11)
  1391.                     if choice == 1 then
  1392.                         plrs:SendChatMessage(14,0,"Ugh, get this thing off me!")
  1393.                     elseif choice == 2 then
  1394.                         plrs:SendChatMessage(14,0,"It burns!")
  1395.                     end
  1396.                 end
  1397.             end
  1398.         end
  1399.     end
  1400. end
  1401.  
  1402. RegisterUnitEvent(21234, 18, "ZG.VAR.DESEMAGIZAVOID")
  1403. RegisterUnitEvent(21234, 4, "ZG.VAR.DESEMAGIZAVOID")
  1404.  
  1405. -- The druids
  1406.  
  1407.  
  1408. -- if entry == 36544 or entry == 4052 then
  1409.  
  1410. function ZG.VAR.MainLeaderSpawn_Event(pUnit, Event)
  1411.     if Event == 1 then
  1412.         pUnit:Root()
  1413.         pUnit:RegisterEvent("ZG.VAR.MainSpells_Dragon_Add", 4000, 0)
  1414.     elseif Event == 2 or 4 then
  1415.         pUnit:RemoveEvents()
  1416.     elseif Event == 18 then
  1417.         local plr = pUnit:GetClosestPlayer()
  1418.         if plr ~= nil then
  1419.             pUnit:SetMovementFlags(1)
  1420.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1421.         end
  1422.     end
  1423. end
  1424.  
  1425. function ZG.VAR.MainSpells_Dragon_Add(pUnit)
  1426.     local plr = pUnit:GetClosestPlayer()
  1427.     if plr ~= nil then
  1428.         pUnit:FullCastSpellOnTarget(8950, plr) -- starfire
  1429.     end
  1430. end
  1431.  
  1432. RegisterUnitEvent(36544, 1, "ZG.VAR.MainLeaderSpawn_Event")
  1433. RegisterUnitEvent(36544, 2, "ZG.VAR.MainLeaderSpawn_Event")
  1434. RegisterUnitEvent(36544, 4, "ZG.VAR.MainLeaderSpawn_Event")
  1435. RegisterUnitEvent(36544, 18, "ZG.VAR.MainLeaderSpawn_Event")
  1436.  
  1437. function ZG.VAR.AddEvent_Dragon(pUnit, Event)
  1438.     if Event == 1 then
  1439.         pUnit:Root()
  1440.         pUnit:RegisterEvent("ZG.VAR.AddSpells_Dragon", 2500, 0)
  1441.     elseif Event == 2 or 4 then
  1442.         pUnit:RemoveEvents()
  1443.     elseif Event == 18 then
  1444.         local plr = pUnit:GetClosestPlayer()
  1445.         if plr ~= nil then
  1446.             pUnit:SetMovementFlags(1)
  1447.             pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
  1448.         end
  1449.     end
  1450. end
  1451.  
  1452. function ZG.VAR.AddSpells_Dragon(pUnit)
  1453.     local plr = pUnit:GetClosestPlayer()
  1454.     if plr ~= nil then
  1455.         pUnit:FullCastSpellOnTarget(9739, plr) -- Wrath
  1456.     end
  1457. end
  1458.  
  1459. RegisterUnitEvent(4052, 1, "ZG.VAR.AddEvent_Dragon")
  1460. RegisterUnitEvent(4052, 2, "ZG.VAR.AddEvent_Dragon")
  1461. RegisterUnitEvent(4052, 4, "ZG.VAR.AddEvent_Dragon")
  1462. RegisterUnitEvent(4052, 18, "ZG.VAR.AddEvent_Dragon")
  1463.  
  1464. -- Hack fix, stop people falling down ----------------------------------------
  1465.  
  1466. function ZG.VAR.Check_Players_InZG()
  1467.     for place,plrs in pairs(GetPlayersInWorld()) do
  1468.         if plrs and plrs ~= nil then
  1469.             if plrs:GetMapId() == 309 then
  1470.                 if (plrs:IsAlive() and plrs:GetZ() < 52 and plrs:GetY() > -2135) then
  1471.                     plrs:SetHealth(1)
  1472.                     plrs:CastSpell(11)
  1473.                     plrs:CastSpell(46995) -- visual
  1474.                     plrs:CastSpell(39180) -- visual
  1475.                 end
  1476.                 if (not plrs:HasAura(35480) and not plrs:HasAura(35481)) then -- added female aura
  1477.                     if plrs:GetGender() == 0 then -- added gender check
  1478.                         plrs:CastSpell(35480)
  1479.                     else
  1480.                         plrs:CastSpell(35481)
  1481.                     end
  1482.                 end
  1483.             elseif plrs:HasAura(35480) or plrs:HasAura(35481) then
  1484.                 if plrs:GetGender() == 0 then
  1485.                     plrs:RemoveAura(35480)
  1486.                 else
  1487.                     plrs:RemoveAura(35481)
  1488.                 end
  1489.             elseif plrs:GetMapId() == 578 then
  1490.                 if (plrs:IsAlive() and plrs:GetZ() < 425 and plrs:GetY() > 450) then
  1491.                     plrs:Teleport(578,1046,1032,432.516541)
  1492.                     plrs:CastSpell(51347)
  1493.                 end
  1494.             end
  1495.         end
  1496.     end
  1497. end
  1498.    
  1499.  
  1500. RegisterTimedEvent("ZG.VAR.Check_Players_InZG", 5000, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement