Code:
local Name = "Pontus" --Is there any reason, that this is a variable? If so, it should be a string.
local NPCID = 100001
---------------Standard---------------------
function Pontus_OnCombat(pUnit, event, player)
pUnit:SendChatMessage(12, 0, "Ni kommer försent!")
pUnit:RegisterEvent("Pontus_Phase1", 1000, 0)
end
function Pontus_OnLeaveCombat(pUnit, event, player)
pUnit:SendChatMessage(14, 0, "Har ni gjort färdigt era gymnasiearbeten?")
pUnit:RemoveEvents()
end
function Pontus_OnDeath(pUnit, event, player)
pUnit:SendChatMessage(12, 0, "Det här ska ni skita i...")
pUnit:RemoveEvents()
end
----------------------------------------------
--------------------Phases--------------------
function Pontus_Phase1(pUnit, event, player)
if pUnit:GetHealthPct() == 80 then
pUnit:RemoveEvents() --To prevent the function to be called, once we go to phase 2.
pUnit:SendChatMessage(12, 0, "Ni slösar bort eran tid!")
pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
pUnit:SetCombatCapable(1)
pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.096680, -3096.876953, 268.675476, 100003))
pUnit:RegisterEvent("Pontus_Phase2", 1000, 0)
end
end
function Pontus_Phase2(pUnit, event, player)
if pUnit:GetHealthPct() == 60 then
pUnit:SendChatMessage(12, 0, "Håll Käften!")
pUnit:CastSpell(64189)
pUnit:SetCombatCapable(0)
pUnit:RegisterEvent("Pontus_Phase3", 1000, 0)
end
end
function Pontus_Phase3(pUnit, event, player)
if pUnit:GetHealthPct() == 40 then
pUnit:SendChatMessage(12, 0, "Ni kommer få indraget CSN!")
pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.284668, -3103.452881, 268.674347, 100003))
pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
pUnit:RegisterEvent("Pontus_Volley", 10000, 0)
pUnit:CastSpell(57381)
pUnit:RegisterEvent("Pontus_Phase4", 1000, 0)
pUnit:SetCombatCapable(1)
end
end
function Pontus_Phase4(pUnit, event, player)
if pUnit:GetHealthPct() == 20 then
pUnit:SendChatMessage(12, 0, "SKA JAG TA KONTAKT MED ERA FÖRÄLDRAR?")
pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.408448, -3098.933350, 286.500397, 100003))
pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
pUnit:CastSpell(68872)
pUnit:SetCombatCapable(0)
end
end
-----------------------------------------------
------------------------Spells----------------
function Pontus_RandomAoeGround(pUnit, event, player)
pUnit:FullCastSpellOnTarget(50752, pUnit:GetRandomPlayer(0))
end
function Pontus_Volley(pUnit, event, player)
pUnit:CastSpell(57381)
end
----------------------------------------------
RegisterUnitEvent(100001, 1, "Pontus_OnCombat")
RegisterUnitEvent(100001, 2, "Pontus_OnLeaveCombat")
RegisterUnitEvent(100001, 4, "Pontus_OnDeath")