Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Final Dragon Boss ---------------------------------------------------------
- function ZG.VAR.DragonBossEvent_COT(pUnit, Event)
- if Event == 4 then
- pUnit:RemoveEvents()
- elseif Event == 18 then
- pUnit:RegisterEvent("ZG.VAR.SetUpCreatures_Dragon", 1000, 1)
- end
- end
- RegisterUnitEvent(115831, 4, "ZG.VAR.DragonBossEvent_COT")
- RegisterUnitEvent(115831, 18, "ZG.VAR.DragonBossEvent_COT")
- function ZG.VAR.SetUpCreatures_Dragon(pUnit)
- pUnit:SetMaxPower(100, 2)
- pUnit:SetPower(100, 2)
- pUnit:SetPowerType(2)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- ZG[id].VAR.leader = pUnit:SpawnCreature(36544, -11062, -2306, 145.9, 1.290404, 35, 0, 50429) -- Leader
- ZG[id].VAR.addA = pUnit:SpawnCreature(4052, -11075, -2307, 145, 1.058709, 35, 0, 45212)
- ZG[id].VAR.addB = pUnit:SpawnCreature(4052, -11066, -2311, 145.9, 1.184373, 35, 0, 45212)
- ZG[id].VAR.addC = pUnit:SpawnCreature(4052, -11057, -2314, 147.3, 1.549583, 35, 0, 45212)
- ZG[id].VAR.addD = pUnit:SpawnCreature(4052, -11049, -2311, 146.3, 2, 35, 0, 45212)
- pUnit:RegisterEvent("ZG.VAR.WhileNoPlayer_DoVisual", 1500, 1)
- pUnit:RegisterEvent("ZG.VAR.CheckForPlayers_ToStart", 1000, 0)
- end
- function ZG.VAR.WhileNoPlayer_DoVisual(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
- ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)
- end
- function ZG.VAR.CheckForPlayers_ToStart(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- local plr = ZG[id].VAR.leader:GetClosestPlayer()
- if plr ~= nil then
- if ZG[id].VAR.leader:GetDistanceYards(plr) < 10 then
- if plr:IsAlive() then
- ZG[id].VAR.leader:PlaySoundToSet(15861)
- ZG[id].VAR.leader:SendChatMessage(12,0,"Hurry mortals, I cannot hold the beast back for long!")
- pUnit:RemoveEvents()
- pUnit:RegisterEvent("ZG.VAR.HEREWEGO_DRAGON", 4000, 1)
- end
- end
- end
- end
- function ZG.VAR.HEREWEGO_DRAGON(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- pUnit:SendChatMessage(14,0,"ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!")
- pUnit:SpawnGameObject(146086, -11095.85, -2318.86, 147.5, 6.154612, 900000, 100) -- cave in
- ZG[id].VAR.leader:PlaySoundToSet(8289)
- ZG[id].VAR.leader:StopChannel()
- ZG[id].VAR.addA:StopChannel()
- ZG[id].VAR.addB:StopChannel()
- ZG[id].VAR.addC:StopChannel()
- ZG[id].VAR.addD:StopChannel()
- pUnit:RegisterEvent("ZG.VAR.WaitForVisualsToPlayDURP", 250, 1)
- ZG[id].VAR.e = 0
- ZG[id].VAR.hpCount = 1
- ZG[id].VAR.hpList = {90,80,70,60,50,40,30,20,10}
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 7000, 1)
- pUnit:RegisterEvent("ZG.VAR.DrainDragonBossHealth", 500, 0)
- pUnit:RegisterEvent("ZG.VAR.DragonBossCheckForWipe_Astarot", 2000, 0)
- pUnit:RegisterEvent("ZG.VAR.DragonDespawnDeadTrash", 10000, 0)
- end
- function ZG.VAR.WaitForVisualsToPlayDURP(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- ZG[id].VAR.leader:CastSpell(68848)
- ZG[id].VAR.addA:CastSpell(68848) -- knockdown visual
- ZG[id].VAR.addB:CastSpell(68848)
- ZG[id].VAR.addC:CastSpell(68848)
- ZG[id].VAR.addD:CastSpell(68848)
- end
- function ZG.VAR.DrainDragonBossHealth(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- if pUnit:GetHealthPct() > ZG[id].VAR.hpList[ZG[id].VAR.hpCount] then
- pUnit:SetHealth(pUnit:GetHealth()-200)
- end
- --[[if pUnit:GetPower() < pUnit:GetMaxPower() then
- pUnit:SetPower(pUnit:GetPower(2)+1, 2)
- end]]
- end
- function ZG.VAR.BeginZeEventZZ(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- ZG[id].VAR.e = ZG[id].VAR.e + 1
- if ZG[id].VAR.e == 1 then
- ZG[id].VAR.leader:SendChatMessage(12,0,"Mortals, you must defend us while we attempt to destroy this being, or all hope is lost!")
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 3000, 1)
- elseif ZG[id].VAR.e == 2 then
- ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
- elseif ZG[id].VAR.e == 3 then
- ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
- elseif ZG[id].VAR.e == 4 then
- pUnit:CastSpellAoF(-11062.66, -2297.34, 146, 68926)
- pUnit:SpawnCreature(21234, -11062.66, -2297.34, 146, 0, 15, 300000)
- ZG[id].VAR.dragons = 0
- pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 2)
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)
- elseif ZG[id].VAR.e == 5 then
- local found = false
- for _,unit in pairs(pUnit:GetInRangeUnits()) do
- local entry = unit:GetEntry()
- if entry == 871111 or entry == 497111 then
- if unit:IsAlive() then
- found = true
- break
- end
- end
- end
- if not found then
- ZG[id].VAR.leader:PlaySoundToSet(8291)
- pUnit:SendChatMessage(14,0,"Impossible! Rise my minions! Serve your master once more!")
- ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
- else
- ZG[id].VAR.e = ZG[id].VAR.e - 1
- end
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
- elseif ZG[id].VAR.e == 6 then
- ZG[id].VAR.dragons = 0
- pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 20000, 1)
- elseif ZG[id].VAR.e == 7 then
- local found = false
- for _,unit in pairs(pUnit:GetInRangeUnits()) do
- local entry = unit:GetEntry()
- if entry == 871111 or entry == 497111 then
- if unit:IsAlive() then
- found = true
- break
- end
- end
- end
- if not found then
- ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
- ZG[id].VAR.leader:PlaySoundToSet(8290)
- pUnit:SendChatMessage(14,0,"Burn, you wretches! Burn!")
- ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
- local trigger = pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942)
- trigger:SetScale(0.8)
- trigger:CastSpell(63894) -- shield
- else
- ZG[id].VAR.e = ZG[id].VAR.e - 1
- end
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
- elseif ZG[id].VAR.e == 8 then
- ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
- elseif ZG[id].VAR.e == 9 then
- for i=1,100 do
- pUnit:RegisterEvent("ZG.VAR.METEORSINCOMINGDUN_DUN", math.random(1000,20000),1)
- end
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 23000, 1)
- elseif ZG[id].VAR.e == 10 then
- pUnit:GetCreatureNearestCoords(ZG[id].VAR.leader:GetX(),ZG[id].VAR.leader:GetY(),ZG[id].VAR.leader:GetZ(),27942):RemoveAura(63894) -- shield
- ZG[id].VAR.leader:PlaySoundToSet(8292)
- pUnit:SendChatMessage(14,0,"This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!")
- pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 4000, 1)
- elseif ZG[id].VAR.e == 11 then
- ZG[id].VAR.hpCount = ZG[id].VAR.hpCount + 1
- ZG[id].VAR.dragons = 0
- pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 4)
- end
- end
- function ZG.VAR.METEORSINCOMINGDUN_DUN(pUnit)
- pUnit:SetPower(pUnit:GetPower(2)-3, 2)
- local nx = math.random(11051,11087)
- local ny = math.random(2325,2341)
- pUnit:CastSpellAoF(-nx,-ny,pUnit:GetLandHeight(-nx,-ny),57467)
- if math.random(1,100) < 13 then -- Since the square doesn't cover the sides of the shield, we'll hit those gaps
- if math.random(1,2) == 1 then
- pUnit:CastSpellAoF(-11048.75, -2320.6, 147.8,57467)
- else
- pUnit:CastSpellAoF(-11078.3, -2315, 147,57467)
- end
- end
- end
- function ZG.VAR.SpawnMoreDamnDragonLords(pUnit)
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- if ZG[id].VAR.dragons == 0 then
- pUnit:CastSpellAoF(-11042, -2333, 146.65, 68926)
- pUnit:SpawnCreature(871111, -11042, -2333, 146.8, 2.67, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- elseif ZG[id].VAR.dragons == 1 then
- pUnit:CastSpellAoF(-11089.64, -2331.76, 146.3, 68926)
- pUnit:SpawnCreature(871111, -11089.64, -2331.76, 146.3, 0.37, 21, 300000, 39221):SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
- elseif ZG[id].VAR.dragons == 2 then
- pUnit:CastSpellAoF(-11090.4, -2332, 146.3, 68926)
- for i=1,math.random(5,12) do
- pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
- end
- elseif ZG[id].VAR.dragons == 3 then
- pUnit:CastSpellAoF(-11042.7, -2333, 146.7, 68926)
- for i=1,math.random(9,15) do
- pUnit:SpawnCreature(497111, -11042.7, -2333, 146.7, 2.649929, 15, 120000)
- end
- end
- ZG[id].VAR.dragons = ZG[id].VAR.dragons + 1
- end
- function ZG.VAR.DragonDespawnDeadTrash(pUnit)
- for _,unit in pairs(pUnit:GetInRangeUnits()) do
- local entry = unit:GetEntry()
- if entry == 21234 or entry == 871111 or entry == 36544 or entry == 497111 or entry == 4052 then
- if not unit:IsAlive() then
- --pUnit:CastSpellAoF(unit:GetX(), unit:GetY(), unit:GetZ(), 68926) -- causes too much damage
- unit:Despawn(1,0)
- end
- end
- end
- end
- function ZG.VAR.DragonBossCheckForWipe_Astarot(pUnit)
- local found = false
- for _,plr in pairs(pUnit:GetInRangePlayers()) do
- if plr:GetZ() < 143 or plr:GetZ() > 149 then
- plr:Teleport(309, -11070, -2328.8, 150)
- plr:CastSpell(64446) -- teleport visual
- end
- if not found then
- if plr:IsAlive() then
- found = true
- end
- end
- end
- if not found then
- -- wipe
- pUnit:RemoveEvents()
- pUnit:StopChannel()
- pUnit:SetHealth(pUnit:GetMaxHealth())
- local object = pUnit:GetGameObjectNearestCoords(-11095.85, -2318.86, 147.5, 146086) -- cave in
- if object ~= nil then
- object:Despawn(1000, 0)
- end
- for _,unit in pairs(pUnit:GetInRangeUnits()) do
- local entry = unit:GetEntry()
- if entry == 21234 or entry == 871111 or entry == 497111 or entry == 36544 or entry == 4052 then
- unit:StopChannel()
- unit:CancelSpell()
- unit:Despawn(1000,0)
- end
- end
- pUnit:RegisterEvent("ZG.VAR.SetUpCreatures_Dragon", 5000, 1)
- end
- end
- -- 8289 <- ENOUGH! Now you vermin shall feel the force of my birthright: The Fury of the Earth itself!
- -- 8290 <- Burn, you wretches! Burn!
- -- 8291 <- Impossible! Rise my minions! Serve your master once more!
- -- 8292 <- This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!
- -- 8293 <- Worthless wretch! Your friends will join you soon enough!
- -- Draconic lords
- function ZG.VAR.DRACONICLORDEVENT(pUnit, Event)
- if Event == 1 then
- pUnit:RegisterEvent("ZG.VAR.LordSpamFlameStrike", 10000, 0)
- pUnit:RegisterEvent("ZG.VAR.SummonWhelpsAndSuchLordd", 1100, 0)
- elseif Event == 2 or Event == 4 then
- pUnit:RemoveEvents()
- elseif Event == 18 then
- pUnit:RegisterEvent("ZG.VAR.MoveTowardsEnemyZZLord", 1000, 1)
- end
- end
- function ZG.VAR.LordSpamFlameStrike(pUnit)
- local plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 2121)
- end
- plr = pUnit:GetMainTank()
- if plr ~= nil then
- if pUnit:GetDistanceYards(plr) < 7 then
- pUnit:StopMovement(2500)
- pUnit:FullCastSpellOnTarget(5213, plr)
- end
- end
- end
- function ZG.VAR.MoveTowardsEnemyZZLord(pUnit)
- if not pUnit:IsInCombat() then
- local plr = pUnit:GetClosestPlayer()
- if plr ~= nil then
- pUnit:SetMovementFlags(1)
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- pUnit:ChangeTarget(plr)
- end
- end
- end
- function ZG.VAR.SummonWhelpsAndSuchLordd(pUnit)
- if pUnit:GetHealthPct() < 20 then
- local a = pUnit:GetCreatureNearestCoords(-11041, -2334.4, 146.8, 25525)
- local b = pUnit:GetCreatureNearestCoords(-11091, -2332.4, 146.3, 25525)
- if a and b then
- pUnit:RemoveEvents()
- pUnit:Root()
- pUnit:CastSpell(22663) -- immune to all damage
- pUnit:AIDisableCombat(true)
- local ad = pUnit:GetDistanceYards(a)
- local bd = pUnit:GetDistanceYards(b)
- if ad > bd then
- pUnit:ChannelSpell(76221, b)
- pUnit:RegisterEvent("ZG.VAR.HatchEggsBBB", 7500, 1)
- else
- pUnit:ChannelSpell(76221, a)
- pUnit:RegisterEvent("ZG.VAR.HatchEggsAAA", 7500, 1)
- end
- end
- end
- end
- function ZG.VAR.HatchEggsBBB(pUnit)
- pUnit:RemoveAura(22663)
- pUnit:CastSpell(32711) -- AoE
- pUnit:StopChannel()
- for i=1,math.random(5,12) do
- pUnit:SpawnCreature(497111, -11090.4, -2332, 146.3, 0.206785, 15, 120000)
- end
- pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 500, 1)
- end
- function ZG.VAR.HatchEggsAAA(pUnit)
- pUnit:RemoveAura(22663)
- pUnit:CastSpell(32711) -- AoE
- pUnit:StopChannel()
- for i=1,math.random(5,12) do
- pUnit:SpawnCreature(497111, -11042, -2333.4, 146.7, 2.853576, 15, 120000)
- end
- pUnit:RegisterEvent("ZG.VAR.KILL_SELF_INSEC", 250, 1)
- end
- function ZG.VAR.KILL_SELF_INSEC(pUnit)
- pUnit:Kill(pUnit)
- end
- RegisterUnitEvent(871111, 1, "ZG.VAR.DRACONICLORDEVENT")
- RegisterUnitEvent(871111, 2, "ZG.VAR.DRACONICLORDEVENT")
- RegisterUnitEvent(871111, 4, "ZG.VAR.DRACONICLORDEVENT")
- RegisterUnitEvent(871111, 18, "ZG.VAR.DRACONICLORDEVENT")
- -- Whelps
- function ZG.VAR.WhelpsOverwhelmingDrac(pUnit, Event)
- pUnit:RegisterEvent("ZG.VAR.WHelpsFactionsMove", math.random(900, 2000), 1)
- end
- function ZG.VAR.WHelpsFactionsMove(pUnit)
- pUnit:SetFaction(21)
- local plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- pUnit:SetMovementFlags(1)
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- pUnit:ChangeTarget(plr)
- end
- end
- RegisterUnitEvent(497111, 18, "ZG.VAR.WhelpsOverwhelmingDrac")
- -- avoid these balls
- function ZG.VAR.DESEMAGIZAVOID(pUnit)
- if Event == 4 then
- pUnit:RemoveEvents()
- else
- pUnit:RegisterEvent("ZG.VAR.VisualReadyGoGO", 1000, 1)
- pUnit:RegisterEvent("ZG.VAR.MOVETOWARDS_PLAYZ", 1000, 0)
- end
- end
- function ZG.VAR.VisualReadyGoGO(pUnit)
- pUnit:ChannelSpell(56220, pUnit)
- pUnit:AIDisableCombat(true)
- pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
- end
- function ZG.VAR.MOVETOWARDS_PLAYZ(pUnit)
- local plr = pUnit:GetClosestPlayer()
- if plr ~= nil then
- if not plr:IsAlive() then
- plr = pUnit:GetRandomPlayer(0)
- if plr ~= nil then
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- end
- else
- local trigger = pUnit:GetCreatureNearestCoords(-11062, -2306, 146, 27942)
- if trigger then
- if trigger:HasAura(63894) then
- if pUnit:GetDistanceYards(trigger) < 12 then
- pUnit:StopMovement(100)
- end
- else
- pUnit:MoveTo(plr:GetX(), plr:GetY(), plr:GetZ(), 0)
- end
- end
- end
- end
- for _,plrs in pairs(pUnit:GetInRangeUnits()) do
- if plrs:GetDistanceYards(pUnit) < 8 then
- if plrs:IsPlayer() then
- if pUnit:GetDistanceYards(plrs) < 5 then
- pUnit:Strike(plrs, 2, 59322, 100, 100, 1)
- end
- else
- if plrs:GetEntry() ~= 4052 and plrs:GetEntry() ~= 36544 and plrs:GetEntry() ~= 27942 then
- if not plrs:HasAura(22663) then
- if (plrs:GetHealth()-150) < 1 then
- plrs:Kill(plrs)
- else
- plrs:SetHealth(plrs:GetHealth()-150)
- end
- end
- else
- local choice = math.random(1,11)
- if choice == 1 then
- plrs:SendChatMessage(14,0,"Ugh, get this thing off me!")
- elseif choice == 2 then
- plrs:SendChatMessage(14,0,"It burns!")
- end
- end
- end
- end
- end
- end
- RegisterUnitEvent(21234, 18, "ZG.VAR.DESEMAGIZAVOID")
- RegisterUnitEvent(21234, 4, "ZG.VAR.DESEMAGIZAVOID")
Advertisement
Add Comment
Please, Sign In to add comment