Code:
-- 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)
--pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+6, pUnit:GetO())
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
pUnit:SetMovementFlags(2)
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)
-- commented out as knockdown visual is broke
--[[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)
--ZG[id].VAR.e = 15 -- DEBUG -------------------------------------------------------------------------
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)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
elseif ZG[id].VAR.e == 12 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
for _,unit in pairs(pUnit:GetInRangeUnits()) do
if unit:GetEntry() == 21234 then
unit:Kill(unit)
break
end
end
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
ZG[id].VAR.dragons = 0
pUnit:RegisterEvent("ZG.VAR.SpawnMoreDamnDragonLords", 5000, 3)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 21000, 1)
else
ZG[id].VAR.e = ZG[id].VAR.e - 1
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
end
elseif ZG[id].VAR.e == 13 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 == 14 then
ZG[id].VAR.leader:SendChatMessage(14,0,"Quick, get within the barrier!")
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2500, 1)
elseif ZG[id].VAR.e == 15 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 == 16 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:SetHealthPct(10)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
elseif ZG[id].VAR.e == 17 then
--pUnit:ChannelSpell(68834, ZG[id].VAR.leader)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
elseif ZG[id].VAR.e == 18 then
ZG[id].VAR.leader:SendChatMessage(14,0,"No!")
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
elseif ZG[id].VAR.e == 19 then
ZG[id].VAR.leader:SendChatMessage(12,0,"Death to the interlopers.")
ZG[id].VAR.leader:StopChannel()
ZG[id].VAR.leader:CastSpell(41535) -- chains visual
ZG[id].VAR.addA:StopChannel()
ZG[id].VAR.addB:StopChannel()
ZG[id].VAR.addC:StopChannel()
ZG[id].VAR.addD:StopChannel()
ZG[id].VAR.addcount = 0
pUnit:RegisterEvent("ZG.VAR.SetFactionsOfNPCSDragon", 1000, 4)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 5000, 1)
elseif ZG[id].VAR.e == 20 then
ZG[id].VAR.addA:SetFaction(21)
ZG[id].VAR.addB:SetFaction(21)
ZG[id].VAR.addC:SetFaction(21)
ZG[id].VAR.addD:SetFaction(21)
ZG[id].VAR.leader:SetFaction(21)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 2000, 1)
elseif ZG[id].VAR.e == 21 then
local found = false
for _,unit in pairs(pUnit:GetInRangeUnits()) do
local entry = unit:GetEntry()
if entry == 36544 or entry == 4052 then
if unit:IsAlive() then
found = true
break
end
end
end
if not found then
ZG[id].VAR.leader:PlaySoundToSet(8293)
pUnit:SendChatMessage(14,0,"Worthless wretch! Your friends will join you soon enough!")
pUnit:SetHealth(132)
else
ZG[id].VAR.e = ZG[id].VAR.e - 1
end
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 1000, 1)
elseif ZG[id].VAR.e == 22 then
pUnit:MoveTo(-11064, -2310.88, 146.2, 0)
pUnit:RegisterEvent("ZG.VAR.VisuzlzzBoss", 100, 0)
pUnit:RegisterEvent("ZG.VAR.BeginZeEventZZ", 6000, 1)
elseif ZG[id].VAR.e == 23 then
pUnit:RemoveEvents()
--[[for _,plrs in pairs(pUnit:GetInRangePlayers()) do
if pUnit:IsAlive() then
plrs:CastSpellOnTarget(11, pUnit)
end
end]]
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
unit:Despawn(1,0)
end
end
end
local object = pUnit:GetGameObjectNearestCoords(-11095.5, -2318.3, 147.5, 146086) -- rocks
if object ~= nil then
object:Despawn(1,0)
end
pUnit:SpawnGameObject(355101, -11064, -2329.5, 146.6, 4.679757, 300000, 100) -- chest
pUnit:Kill(pUnit)
end
end
Excerpt from a boss script.