PHASES
Phases are great to use in a script. With phases you can make the boss do spells at an x amount of %. This is great because then you need to make tactics for a boss. By example a custom made boss. You are in a raid and the raid leader says something like: "Back up everyone! He's almost at x %" or something like that. How cool is that. Well, enough talking, I'm going to learn you how to make and use phases.
4.1 Phases at x amount of %
4.2 Phases at timing
PHASES AT X AMOUNT OF %
The first topic we will discuss about phases is phases at x amount of %. This is the most used kind of phase. I will show you how a basic phase at x amount of % looks like.
Code:
function Boss_Phase1(pUnit, Event)
if pUnit:GetHealthPct() <= 50 then
pUnit:RemoveEvents()
end
end
This looks like a phase with no events. Let me explain everything to you.
function Boss_Phase1(pUnit, Event), I've tought you this in the first chapter. So I don't need to explain further about it. The only thing that has changed is the name to "Boss_Phase1". It's easier to remember to use "Phase1", "Phase2" instead of other names. But remember that the name must be the same as in the registering part.
if, if is a GREAT statement in all of LUA. "if" is used to make things are true or false. Further explanation is following.
pUnit:GetHealthPct(), if is before this actually. This shows that "if" the pUnit (boss) gets the percent of health (GetHealthPct()) then it will start the phase.
<= 50, this means that the phase will start at exact 50%. You can use "<" instead of "<=". "<" is used that it won't start at the exact percent and "<=" will start at the exact percent.
then, if you are using "if" then you must use "then" at it. This shows that "if" blabla "then". Really easy to understand.
pUnit:RemoveEvents(), you are probarly wondering, why am I putting "pUnit:RemoveEvents()" in the middle of a script? I'll tell you why. When the boss reaches 50% HP, he will start a whole new phase, so that means he must remove all the events, with events I'm including the spells. He will not cast the same spells anymore and starts with other spells or the same spell. Use your imagination!
end
end, two ends? Why? Because "function" and "if" are a statement. If you are using them in one event, you need to let it end on two ends.
Now you know the basics of how to make a phase at x amount of %. We will start adding some new things in the phase. I will show at the end of this part how to register it so don't worry about that.
Example:
Code:
function Boss_Phase1(pUnit, Event)
if pUnit:GetHealthPct() <= 50 then
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "You're only halfways!")
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
pUnit:RegisterEvent("Boss_Spell1", 5000, 0)
end
end
You have learned about the chat message, spells and registering. As you noticed you can register spells at a phase too. It's like it is starting a new script, isn't it.
Now you know how to make a phase at x amount of %. I will show you how to register it. Because without registering then it won't work!.
Example:
Code:
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
pUnit:RegisterEvent("Boss_Spell", 5000, 0)
pUnit:RegisterEvent("Boss_Phase1", 1000, 0)
end
function Boss_Spell(pUnit, Event)
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
end
function Boss_Phase1(pUnit, Event)
if pUnit:GetHealthPct() <= 50 then
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "You're only halfways!")
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
pUnit:RegisterEvent("Boss_Spell1", 5000, 0)
end
end
function Boss_Spell1(pUnit, Event)
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
end
It actually isn't hard to register phases. It's just you need to register it every second, or 5 seconds, whatever you want. The point is that you can register it once because then the phase won't work. You always need to put a 0 at the registering part of phases at x amount of %. At timing it's different, but I will explain that later.
Now you should know how to:
Make a phase at x amount of %
Register a phase at x amount of %
PHASES AT TIMING
Now you know how to make phases at x amount of %. Now it's time to make phases with timing, they are pretty fun too, the only thing is the timing what is pretty hard sometimes. I'll be showing how a basic phase with timing and without any events looks like:
Code:
function Boss_Phase1(pUnit, Event)
pUnit:RemoveEvents()
end
As you can see I haven't put "if pUnit:GetHealthPct() <= x" at it. It doesn't need that because this is timing. And if you don't got "if" then you don't need an extra end, simple isn't it? I will make a phase now who gots events:
Code:
function Boss_Phase1(pUnit, Event)
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "You have to count now instead of watching my percents!")
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
pUnit:RegisterEvent("Boss_Spell1", 5000, 0)
end
This looks pretty much as the phase with percents. The only thing is that "if pUnit:GetHealthPct() <= x" is gone and the extra end. But, there is another things that is different, and that is registering.
You should register phases with timing once instead of forever. And the milliseconds should be different too.
Example:
Code:
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
pUnit:RegisterEvent("Boss_Spell", 5000, 0)
pUnit:RegisterEvent("Boss_Phase1", 25000, 1)
end
function Boss_Spell(pUnit, Event)
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
end
function Boss_Phase1(pUnit, Event)
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "You have to count now instead of watching my percents!")
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
pUnit:RegisterEvent("Boss_Spell1", 5000, 0)
end
end
function Boss_Spell1(pUnit, Event)
pUnit:FullCastSpellOnTarget(SpellID, pUnit:GetMainTank())
end
pUnit:RegisterEvent("Boss_Phase1", 25000, 1), This means phase1 will start in 25 seconds. I actually have nothing to say about this further.
Actually, we are almost at the end of our tutorial. Now you should know how to make a basic boss script. I will be showing an example of a little boss script I made and it has all the features where we have discussed about!
Enjoy
Code:
function Legares_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
pUnit:RegisterEvent("Legares_FireBreath", 6000, 0)
pUnit:RegisterEvent("Legares_BlastWave", 9000, 2)
pUnit:RegisterEvent("Legares_Phase1", 27000, 1)
end
function Legares_FireBreath(pUnit, Event)
pUnit:CastSpell(36876)
end
function Legares_BlastWave(pUnit, Event)
pUnit:FullCastSpell(23039)
end
function Legares_Phase1(pUnit, Event)
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "Are you giving up now?!")
pUnit:FullCastSpellOnTarget(57628, pUnit:GetRandomPlayer(1))
pUnit:RegisterEvent("Legares_FireBreath", 6000, 0)
pUnit:RegisterEvent("Legares_Phase2", 1000, 0)
end
function Legares_FireBreath(pUnit, Event)
pUnit:CastSpell(36876)
end
function Legares_Phase2(pUnit, Event)
if pUnit:GetHealthpct() <= 50 then
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "You're only halfway!")
pUnit:CastSpellOnTarget(56939, pUnit:GetMainTank())
pUnit:RegisterEvent("Legares_BlastWave", 5000, 0)
pUnit:RegisterEvent("Legares_Phase3", 1000, 0)
end
end
function Legares_BlastWave(pUnit, Event)
pUnit:FullCastSpell(23039)
end
function Legares_Phase3(pUnit, Event)
if pUnit:GetHealthPct() <= 1 then
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "I'm dieing... leave me... alone...")
pUnit:FullCastSpell(23039)
end
end
function Legares_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
function Legares_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
function Legares_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
RegisterUnitEvent(EntryID, 1, "Legares_OnCombat")
RegisterUnitEvent(EntryID, 2, "Legares_OnLeaveCombat")
RegisterUnitEvent(EntryID, 3, "Legares_OnKilledTarget")
RegisterUnitEvent(EntryID, 4, "Legares_OnDeath")
Bookmarks