I have created a script for a custom npc (40000 ID but he is basicaly a death knight captain with his name changed.Here is the script:
Code:
function DeathKnightCommander_OnCombat(Unit, Event)
Unit:SendChatMessage(12, 7, "We will never give up.We are The Scourge!")
Unit:RegisterEvent("DeathKnightCommander_UnholyPresence", 1000, 1)
Unit:RegisterEvent("DeathKnightCommander_BloodStrike", 7000, 20)
Unit:RegisterEvent("DeathKnightCommander_PlagueStrike", 10000, 20)
Unit:RegisterEvent("DeathKnightCommander_BloodPlague", 10000, 20)
Unit:RegisterEvent("DeathKnightCommander_Enrage", 1000, 1)
end
function DeathKnightCommander_UnholyPresence(pUnit, Event)
pUnit:CastSpell(55222)
end
function DeathKnightCommander_BloodStrike(Unit, Event)
Unit:FullCastSpellOnTarget(52377, Unit:GetRandomPlayer())
end
function DeathKnightCommander_PlagueStrike(Unit, Event)
Unit:FullCastSpellOnTarget(61600, Unit:GetMainTank())
end
if Unit:FullCastSpellOnTarget(61600, Unit:GetMainTank()) then
function DeathKnightCommander_BloodPlague(Unit, Event)
Unit:FullCastSpellOnTarget(57601, Unit:GetMainTank())
end
end
function DeathKnightCommander_Enrage(pUnit, Event)
if Unit:GetHealthPct() <=10 then
pUnit:CastSpell(42705)
end
end
function DeathKnightCommander_OnLeaveCombat(Unit, Event)
Unit:RemoveEvents()
end
function DeathKnightCommander_OnKilledTarget(Unit, Event)
Unit:SendChatMessage(12, 7, "Another win for the Scourge!")
end
function DeathKnightCommander_OnDied(Unit, Event)
Unit:RemoveEvents()
end
RegisterUnitEvent(40000, 1, "DeathKnightCommander_OnCombat")
RegisterUnitEvent(40000, 2, "DeathKnightCommander_OnLeaveCombat")
RegisterUnitEvent(40000, 3, "DeathKnightCommander_OnKilledTarget")
RegisterUnitEvent(40000, 4, "DeathKnightCommander_OnDied")
so i scripted him that after 7 seconds after he enter combat to do Blood strike.But after 7 seconds he is restarting his hp is going to full and he is going back to spawning location.So basicaly after 7 seconds instead of doing blood strike he is reseting. What did i have done wrong? pls someone help me.