PDA

View Full Version : Problem with a Lua Script



anasterion
20-02-10, 04:34 AM
Hey guys!
made my first lua script today, iam not able to find errors in it but i cant get the phases working :/ could someone take a look at the script and tell me whats wrong? the npc casts the spells like i wanted, but the phases wont be registered


function Saurfang_OnCombat(Unit, Event)
Unit:SendChatMessage(14, 0, "YOU CANNOT ESCAPE MY ANGER!!!")
Unit:RegisterEvent("Saurfang_Berserk", 1, 1)
Unit:RegisterEvent("Saurfang_Boilingblood", 60000, 20)
Unit:RegisterEvent("Saurfang_Bloodlink", 60000, 10)
Unit:RegisterEvent("Saurfang_Phase1", 5000, 1)
Unit:RegisterEvent("Saurfang_Phase2", 5000, 1)
end

function Saurfang_Phase1(Unit, Event)
if Unit:GetHealthPct() <= 75 then
Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
Unit:CastSpell(72173)
Unit:CastSpell(15578)
end
end

function Saurfang_Phase2(Unit, Event)
if Unit:GetHealthPct() <= 33 then
Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
Unit:CastSpell(46008)
Unit:CastSpell(41185)
Unit:SetScale(2)
end
end

function Saurfang_Berserk(Unit, Event)
Unit:CastSpell(26662)
Unit:SendChatMessage(14, 0, "Feel the pain!!")
end


function Saurfang_Boilingblood(Unit, Event)
Unit:FullCastSpellOnTarget(72178, Unit:GetClosestPlayer())
end

function Saurfang_Bloodlink(Unit, Event)
Unit:CastSpell(72371)
Unit:SendChatMessage(14, 0, "Your Hate makes me even STRONGER!!")
end

function Saurfang_OnLeaveCombat(Unit, Event)
Unit:RemoveEvents()
end

function Saurfang_OnKilledTarget(Unit, Event)
Unit:SendChatMessage(14, 0, "Who expected this? hahaha!")
Unit:CastSpell(72356)
end

function Saurfang_OnDied(Unit, Event)
Unit:SendChatMessage(14, 0, "You...cannot...win against...the...Lich...King!")
Unit:RemoveEvents()
end

RegisterUnitEvent(37813, 1, "Saurfang_OnCombat")
RegisterUnitEvent(37813, 2, "Saurfang_OnLeaveCombat")
RegisterUnitEvent(37813, 3, "Saurfang_OnKilledTarget")
RegisterUnitEvent(37813, 4, "Saurfang_OnDied")

mag1212
20-02-10, 04:38 AM
function Saurfang_Phase1(Unit, Event)
if Unit:GetHealthPct() <= 75 then
Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
Unit:CastSpell(72173)
Unit:CastSpell(15578)
end
end

function Saurfang_Phase2(Unit, Event)
if Unit:GetHealthPct() <= 33 then
Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
Unit:CastSpell(46008)
Unit:CastSpell(41185)
Unit:SetScale(2)
end
end
u shall only use 1 end

anasterion
20-02-10, 06:18 AM
function Saurfang_Phase1(Unit, Event)
if Unit:GetHealthPct() <= 75 then
Unit:SendChatMessage(14, 0, "You are stronger than i thought you are!")
Unit:CastSpell(72173)
Unit:CastSpell(15578)
end
end

function Saurfang_Phase2(Unit, Event)
if Unit:GetHealthPct() <= 33 then
Unit:SendChatMessage(14, 0, "That was nothing, take this!!!")
Unit:CastSpell(46008)
Unit:CastSpell(41185)
Unit:SetScale(2)
end
end
u shall only use 1 end

thought i have to end the if to, saw it in a tutorial, k i will try that ty

mag1212
20-02-10, 06:23 AM
nope its 1 function so u only need 1 end

Bing
29-07-10, 01:48 PM
Mag is right, the reduction of those two ends should make the phases register!