Code:
function Leviathan_OnEnterCombat(pUnit,Event) -- This referrs to RegisterUnitEvent(22884, 1, "Leviathan_OnEnterCombat")
-- At the bottom of the script. These RegisterUnitEvent functions are what
-- Are activated at the beginning of the script. Just copy what is at the bottom
-- Of this and edit the name/id (explained in detail lower down).
pUnit:SendChatMessage(12, 0, "I may look like a usual beast that you hunt, but having two heads can have it's uses!")
-- Above is a chat message. 12 is the ID for a /say. 14 for a /yell. These are the only 2 you will really use
-- but more are available if you search the internets and MMowned. Its a very basic command and to customise it you will
-- only really need to edit the type ID and the actual message inside the speech marks "".
pUnit:RegisterEvent("Leviathan_Morph1", 1000, 0)
-- This registers an event, and refreshes the register every 1000 milliseconds.
pUnit:CastSpell(15473)
-- Instantly casts the spell of ID '15473' on its target
-- Its also used if you want to cast an AOE such as Consencration
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_Empowering", 20000, 0)
pUnit:RegisterEvent("Leviathan_SpellCrushing", 14000, 0)
pUnit:RegisterEvent("Leviathan_SpellBolt", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellPain", 17000, 0)
-- All of the above are registering seperate events (1 talk, 4 spells)
-- The timers are very crucial as they help balance the fight. Set them accordingly
end
--Phase/Morph Specific Spells--
--ShadowPhase, 100 to 75 percent--
function Leviathan_Empowering(pUnit,Event)
-- pUnit:RegisterEvent("Leviathan_Empowering", 20000, 0)
-- This function is called and executed every 20000MS whilst the OnEnterCombat function
-- Is still active, or if pUnit(RemoveEvents); hasn't been executed.
pUnit:CastSpell(33783)
end
function Leviathan_SpellCrushing(pUnit,Event)
pUnit:CastSpellOnTarget(40243,pUnit:GetRandomPlayer(0))
-- Cast spell on target is a more precise way of spell management
-- There are quite a few different selections to choose from but the
-- main two are GetRandomPlayer and GetMainTank.
end
function Leviathan_SpellBolt(pUnit,Event)
pUnit:CastSpellOnTarget(27209,pUnit:GetRandomPlayer(0))
end
function Leviathan_SpellPain(pUnit,Event)
pUnit:CastSpellOnTarget(25368,pUnit:GetRandomPlayer(0))
pUnit:CastSpellOnTarget(25368,pUnit:GetMainTank())
-- Example of the "GetMainTank" selection.
end
--FirePhase, 75 to 50 percent--
function Leviathan_SpellFirecone(pUnit,Event)
pUnit:CastSpellOnTarget(19630,pUnit:GetClosestPlayer())
-- Another example of a target selection for a spell.
-- this one can be useful for AOE's/knockbacks.
end
function Leviathan_SpellFireball(pUnit,Event)
pUnit:CastSpellOnTarget(25306,pUnit:GetMainTank())
end
function Leviathan_SpellFireRain(pUnit,Event)
pUnit:CastSpell(27212)
end
function Leviathan_SpellSteal(pUnit,Event)
pUnit:CastSpellOnTarget(30449,pUnit:GetRandomPlayer(0))
end
--IceFrostPhase, 50 to 25 percent--
function Leviathan_SpellFrostbolt(pUnit,Event)
pUnit:CastSpellOnTarget(38697,pUnit:GetRandomPlayer(0))
end
function Leviathan_SpellBreath(pUnit,Event)
pUnit:CastSpellOnTarget(44799,pUnit:GetClosestPlayer())
end
function Leviathan_SpellClaw(pUnit,Event)
pUnit:CastSpellOnTarget(3130,pUnit:GetMainTank())
end
function Leviathan_SpellCone(pUnit,Event)
pUnit:CastSpellOnTarget(10159,pUnit:GetClosestPlayer())
end
function Leviathan_SpellPlague(pUnit,Event)
pUnit:CastSpellOnTarget(40351,pUnit:GetRandomPlayer(0))
end
--WarriorPhase, 25 to 1 percent--
function Leviathan_SpellCleave(pUnit,Event)
pUnit:CastSpellOnTarget(25231,pUnit:GetMainTank())
end
function Leviathan_SpellBlackCleave(pUnit,Event)
pUnit:CastSpellOnTarget(33480,pUnit:GetClosestPlayer())
end
function Leviathan_SpellClap(pUnit,Event)
pUnit:CastSpellOnTarget(6343,pUnit:GetMainTank())
end
function Leviathan_SpellRend(pUnit,Event)
pUnit:CastSpellOnTarget(25208,pUnit:GetRandomPlayer(0))
end
function Leviathan_SpellAgony(pUnit,Event)
pUnit:CastSpellOnTarget(36836,pUnit:GetRandomPlayer(0))
end
function Leviathan_SpellAgony(pUnit,Event)
pUnit:CastSpellOnTarget(36836,pUnit:GetRandomPlayer(0))
end
--Morphs and Phases--
--Morph one, Al'Ah display ID, FirePhase enabled, 75 to 50 percent--
function Leviathan_Morph1(pUnit,Event)
if pUnit:GetHealthPct() <= 75 then
-- This function wil be called at 75% health (Less than or Equal to signs used)
-- This function is called every 1000 MS whilst the first phase is active but
-- will not be executed until 75% health.
print "Group through stage 1"
-- Prints a message to the administrator console
pUnit:RemoveEvents()
-- Removes ALL events
pUnit:SetModel(18945)
-- Changes the model of the NPC
pUnit:SendChatMessage(12, 0, "You think you are a match for me? Pfft, what about if I do.... THIS?")
pUnit:SetScale(0.3)
-- Changes the scale of the NPC, exactly like .mod scale #
pUnit:CastSpell(25431)
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFirecone", 18000, 0)
pUnit:RegisterEvent("Leviathan_SpellFireball", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFireRain", 8000, 0)
pUnit:RegisterEvent("Leviathan_SpellSteal", 20000, 0)
pUnit:RegisterEvent("Leviathan_Morph2", 1000, 0)
-- Registering more events, plus the 50% phase.
end
end
--Morph two, Ahune The Frost Lord display ID, IceFrostPhase enabled, 50 to 25 percent--
function Leviathan_Morph2(pUnit,Event)
if pUnit:GetHealthPct() <= 50 then
print "Group through stage 2"
pUnit:RemoveEvents()
pUnit:SetModel(23344)
pUnit:SendChatMessage(12, 0, "Hah, you think that you may triumph over me, but you are only halfway through this igneous shell of steel!")
pUnit:SetScale(0.3)
pUnit:CastSpell(7301)
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellFrostbolt", 11000, 0)
pUnit:RegisterEvent("Leviathan_SpellBreath", 20000, 0)
pUnit:RegisterEvent("Leviathan_SpellClaw", 8000, 0)
pUnit:RegisterEvent("Leviathan_SpellCone", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellPlague", 17000, 0)
pUnit:RegisterEvent("Leviathan_Morph3", 1000, 0)
-- This is pretty much the same structure as 75% phase, but a different
-- model ID and set of spells/chat message.
end
end
--Morph three, Doom Lord Kazzak display ID, WarriorPhase enabled, 25 to 1 percent--
function Leviathan_Morph3(pUnit,Event)
if pUnit:GetHealthPct() <= 25 then
print "Group through stage 3, final stage."
pUnit:RemoveEvents()
pUnit:SetModel(17887)
pUnit:SendChatMessage(12, 0, "I might be growing weaker with every fist thrown against my tattered skin, but you have now unleased the might of my vengence!")
pUnit:SetScale(0.15)
pUnit:CastSpell(43716)
pUnit:RegisterEvent("Leviathan_Talk", 15000, 0)
pUnit:RegisterEvent("Leviathan_SpellCleave", 11000, 0)
pUnit:RegisterEvent("Leviathan_SpellBlackCleave", 13000, 0)
pUnit:RegisterEvent("Leviathan_SpellClap", 12000, 0)
pUnit:RegisterEvent("Leviathan_SpellRend", 19000, 0)
pUnit:RegisterEvent("Leviathan_SpellAgony", 17000, 0)
pUnit:RegisterEvent("Leviathan_Morph4", 1000, 0)
end
end
--Last 1 percent--
function Leviathan_Morph4(pUnit,Event)
if pUnit:GetHealthPct() <= 1 then
print "Group through stage 4, Boss at 1%."
pUnit:RemoveEvents()
pUnit:SendChatMessage(12, 0, "The pain, the agony.. Please spare of me! I beg you!")
pUnit:SetScale(0.3)
pUnit:CastSpell(1020)
-- The boss casts a bubble on himself (Divine Shield).
-- Notice that CastSpell is used here to auto target himself.
pUnit:SendChatMessage(12, 0, "Oh! Spare me such pain?")
end
end
function Leviathan_Death(pUnit)
-- Function called On the death of the NPC.
-- This is registered at the bottom of the script and explained
-- more there.
print "Group killed Leviathan"
pUnit:SendChatMessage(12, 0, "Master, please forgive me...")
pUnit:RemoveEvents()
end
function Leviathan_Talk(pUnit, Event)
Choice=math.random(1, 3)
-- math.random is your friend. Use it to make your fight unique
-- Can be used to cast spells, walk places, patrol, talk, etc.
if Choice==1 then
-- Executed if the random choice = 1
pUnit:SendChatMessage(14, 0, "You are quite strong my friend! Feel the power of the elements!")
pUnit:CastSpell(31895)
end
if Choice==2 then
-- Executed if the random choice = 2
pUnit:SendChatMessage(14, 0, "If you run, I might just spare your lives!")
pUnit:CastSpell(31895)
end
if Choice==3 then
-- Executed if the random choice = 3
pUnit:SendChatMessage(14, 0, "The elements that my Master, Supremus, has given me.. They will blow you away!")
pUnit:CastSpell(31895)
end
end
-- Two ends because of the Choice
function Leviathan_OnLeaveCombat(pUnit, event)
-- Function called upon leaving combat, registered at the beginning
pUnit:RemoveEvents()
end
function Leviathan_OnKilledTarget(pUnit)
-- Function called when the NPC kills a player.
pUnit:SendChatMessage(12, 0, "Feel my Wrath!")
pUnit:PlaySoundToSet(9250)
end
-- The start registers as I call them. These are 'special'
-- The ID's (1,2,3,4) are to determine what the event is
-- (1 = oncombat, 2=onleavecombat, 3=onkilledtarget, 4=ondeath)
-- More ID's can be found with a simple search of a lua functions list
-- or something similar.
-- These can also be used to register GO's, GossipEvents, etc.)
RegisterUnitEvent(22884, 1, "Leviathan_OnEnterCombat")
RegisterUnitEvent(22884, 2, "Leviathan_OnLeaveCombat")
RegisterUnitEvent(22884, 3, "Leviathan_OnKilledTarget")
RegisterUnitEvent(22884, 4, "Leviathan_Death")