Heres what we want to do:
1. Let the server know when the dragon gets to 50% HP or below
2. Making the dragon's faction change, and stop him from attacking people. (so no one can attack him directly back)
3. Lastly, we want him to have a smooth exit to fit the timeline, as we call it!
Final Product:
Code:
function Dragonboss_Phase3(Unit, Event)
if Unit:GetHealthPct() < 50 then
Unit:RemoveEvents()
Unit:RegisterEvent("Dragonboss_Faction", 1000, 1)
end
end
function Dragonboss_Faction(Unit, Event)
Unit:SetFaction(35)
Unit:SetCombatCapable(1)
Unit:RegisterEvent("Dragonboss_Say", 2000, 1)
Unit:RegisterEvent("Dragonboss_HP", 100, 999999999999)
end
function Dragonboss_HP(Unit, Event)
Unit:SetHealthPct(50)
end
function Dragonboss_Say(Unit, Event)
Unit:SendChatMessage(12, 0, "You bunch of fools.. This means NOTHING!")
Unit:RegisterEvent("Dragonboss_Yell", 3000, 1)
end
function Dragonboss_Yell(Unit, Event)
Unit:SendChatMessage(12, 0, "THIS IS WILL NOT BE THE LAST!!!")
Unit:RegisterEvent("Dragonboss_Despawn", 1000, 1)
end
function Dragonboss_Despawn(Unit, Event)
Unit:CastSpell(12980)
Unit:Despawn(1200,480000)
end
Alright now lets break it down:
When the Dragon's health drops to 50% or lower, it calls the event which changes his faction, disallowing him to be attacked, the event also stops him from attacking other people, every millisecond the dragon's health is set to 50% because of autoswing, (when the faction changes it doesnt stop your autoswing!) this will stop him from dieing! After 2 seconds, the event calls a new event, this event forces him to speak (Nothing special here..). 3 Seconds after he speaks, he will yell out (Also nothing special here!). 1 Second after he yells out, it will call a new event called Despawn, the reason for this is that it gives an effect as though he is teleporting away somewhere safe!
The spell id 12980 is a teleport effect, when cast it seems as if you are disappearing or appearing (just like inside manatombs when you start that escort, npcs jump out of the portal!). He casts the teleport effect and 1.2 seconds later, he vanishes.
And thats that. *dusts hands off*