There were a number of things wrong with it.
Here, I fixed it all up for you:
Code:
function LichKing_OnCombat(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Do you think you can kill me?")
pUnit:CastSpellOnTarget(60924, pUnit:GetMainTank())
pUnit:RegisterEvent("LichKing_MedHP", 1000, 0)
end
function LichKing_OnLeaveCombat(pUnit, Event)
pUnit:RemoveEvents()
pUnit:SendChatMessage(12, 0, "Run, foolish mortal.")
end
function LichKing_OnDied(pUnit, Event)
pUnit:RemoveEvents()
pUnit:SendChatMessage(12, 0, "You think you have defeated the scourge!? You've barely damaged the Scourge. The true war has yet to begin.")
pUnit:CastSpell(53210)
end
function LichKing_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Foolish Mortal.")
end
function LichKing_MedHP(pUnit, Event)
if pUnit:GetHealthPct() <= 50 then
pUnit:CastSpell(58915)
pUnit:RemoveEvents()
pUnit:RegisterEvent("LichKing_LowHP", 1000, 0)
end
end
function LichKing_LowHP(pUnit, Event)
if pUnit:GetHealthPct() <= 30 then
pUnit:RemoveEvents();
for i=1,3 do pUnit:CastSpell(58915); end
end
end
RegisterUnitEvent(70819, 1, "LichKing_OnCombat")
RegisterUnitEvent(70819, 2, "LichKing_OnLeaveCombat")
RegisterUnitEvent(70819, 3, "LichKing_OnKilledTarget")
RegisterUnitEvent(70819, 4, "LichKing_OnDied")
first of all:
the unit name in functions has to agree with the variable name in the function arguments.
for example:
Code:
function LichKing_OnKilledTarget(Unit, Event)
pUnit:SendChatMessage(12, 0, "Foolish Mortal.")
end
Will not work, because you declare the variable name as Unit in the arguments, but pUnit in the function.
Secondly:
Code:
pUnit:GetRandomPlayer(0) Unit:CastSpellOnTarget(60924, Unit:GetMainTank)
This doesn't work. You have two function calls on the same line, which... doesn't work.
Also, Unit:GetMainTank is a function, so you have to put parenthases after it.
The line pUnit:GetRandomPlayer(0) does nothing here, because you don't do anything with it. So it gets removed.
The end result of this line is:
Code:
Unit:CastSpellOnTarget(60924, Unit:GetMainTank())