Hi there, I started making my first lua script yesterday and it's not going to bad, however I've hit a block. I have scripted the boss, Algalon, to summon a guardian when he hits 50% hp, and enrage when he hits 30%, however, when he hits 50% he continues to spawn adds untill he is dead and at 30% he casts enrage over and over also spamming the area with his yelling. I have tried changing the following numbers. If I leave them at 0, the above problem persists. I thought if I changed them to 1, once the mob hit 50 or 30% he would do it once and stop, however the function does not run at all.
Code:
Unit:RegisterEvent("Algalon_Enrage", 1000, 0)
Unit:RegisterEvent("Algalon_Guardians", 1000, 0)
I was wondering if anybody knew what the issue was.
Here is my lua so far.
Code:
function Algalon_OnCombat(Unit, Event)
Unit:SendChatMessage(14, 0, "Stand back mortals. I am not here to fight you.")
Unit:RegisterEvent("Algalon_BigBang", 40000, 1)
Unit:RegisterEvent("Algalon_Enrage", 1000, 0)
Unit:RegisterEvent("Algalon_Guardians", 1000, 0)
end
function Algalon_OnDied(Unit, Event)
Unit:SendChatMessage(12, 0, "Perhaps it is your imperfection, that which grants you free will, that allows you to percivere over all cosmically calculated odds. You prevailed where the Titan's own perfect creations have failed.")
Unit:RemoveEvents()
end
function Algalon_OnKilledTarget(Unit, Event)
Unit:SendChatMessage(14, 0, "I do what I must.")
end
function Algalon_OnLeaveCombat(Unit, Event)
Unit:RemoveEvents()
end
function Algalon_BigBang(Unit, Event)
Unit:FullCastSpellOnTarget(64443, Unit:GetClosestPlayer())
Unit:SendChatMessage(14, 0, "Witness the fury of cosmos!")
end
function Algalon_Ascend(Unit, Event)
Unit:FullCastSpellOnTarget(64487, Unit:GetClosestPlayer())
end
function Algalon_Guardians(Unit, Event)
if Unit:GetHealthPct() <= 50 then
local x = Unit:GetX();
local y = Unit:GetY();
local z = Unit:GetZ();
local o = Unit:GetO();
Unit:SpawnCreature (9999998, x, y, z, o, 14 ,60000);
Unit:SendChatMessage(14, 0, "The stars come to my aid.")
end
end
function Algalon_Enrage(Unit, Event)
if Unit:GetHealthPct() <= 30 then
Unit:SendChatMessage(14, 0, "Behold the tools of creation!")
Unit:CastSpell(44779)
Unit:SetScale(1)
end
end
RegisterUnitEvent(9999999, 1, "Algalon_OnCombat")
RegisterUnitEvent(9999999, 4, "Algalon_OnDied")
RegisterUnitEvent(9999999, 3, "Algalon_OnKilledTarget")
RegisterUnitEvent(9999999, 2, "Algalon_OnLeaveCombat")
Thank you in advance.