Code:
function WizF_OnEnterCombat(pUnit,Event)
pUnit:SendChatMessage(14, 0, "You will perish for disrupting my studies!")
pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
pUnit:RegisterEvent("Blizzard", 15000, 0)
pUnit:RegisterEvent("Fireball", 3002, 0)
pUnit:SetCombatMeleeCapable(1)
end
function Fireball(pUnit, Event)
local plr = pUnit:GetRandomPlayer(0)
if plr == nil then
else
pUnit:FullCastSpellOnTarget(61909, plr) -- Fireball
end
end
function Blizzard(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Gettin' chilly in here.")
local pla = pUnit:GetRandomPlayer(0)
if pla == nil then
else
pUnit:FullCastSpellOnTarget(59584, pla) -- Blizzard
end
end
function ArcaneExplosion(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Don't move, this won't take long.")
pUnit:FullCastSpell(29973) -- Arcane Explosion is AOE so we don't need to target somone...
end
function WizF_OnLeaveCombat(pUnit, event)
pUnit:RemoveEvents()
end
function WizF_Death(pUnit)
pUnit:SendChatMessage(14, 0, "All those hours of studying, all for what? TO die in the hands of these lesser beings.")
pUnit:RemoveEvents()
end
function WizF_OnKilledTarget(pUnit)
pUnit:SendChatMessage(14, 0, "This is a lesson.")
end
RegisterUnitEvent(80000, 1, "WizF_OnEnterCombat")
RegisterUnitEvent(80000, 2, "WizF_OnLeaveCombat")
RegisterUnitEvent(80000, 3, "WizF_OnKilledTarget")
RegisterUnitEvent(80000, 4, "WizF_Death")
Thats your 2nd script you posted fixed, now for the spawning.
Code:
function WizF_OnEnterCombat(pUnit,Event)
pUnit:SendChatMessage(14, 0, "You will perish for disrupting my studies!")
pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
pUnit:RegisterEvent("Blizzard", 15000, 0)
pUnit:RegisterEvent("Fireball", 3002, 0)
pUnit:SetCombatMeleeCapable(1)
end
function Fireball(pUnit, Event)
local plr = pUnit:GetRandomPlayer(0)
if plr == nil then
else
pUnit:FullCastSpellOnTarget(61909, plr) -- Fireball
end
end
function Blizzard(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Gettin' chilly in here.")
local pla = pUnit:GetRandomPlayer(0)
if pla == nil then
else
pUnit:FullCastSpellOnTarget(59584, pla) -- Blizzard
end
end
function ArcaneExplosion(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Don't move, this won't take long.")
pUnit:FullCastSpell(29973) -- Arcane Explosion is AOE so we don't need to target somone...
end
function ScarMag_Summon(pUnit, Event)
if pUnit:GetHealthPct() <= 95 then
local x = pUnit:GetX();
local y = pUnit:GetY();
local z = pUnit:GetZ();
local o = pUnit:GetO();
pUnit:SpawnCreature (80006, x, y, z, o, 14,0);
pUnit:RemoveEvents()
pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
pUnit:RegisterEvent("Blizzard", 15000, 0)
pUnit:RegisterEvent("Fireball", 3002, 0)
pUnit:SetCombatMeleeCapable(1)
end
end
function WizF_OnLeaveCombat(pUnit, event)
pUnit:RemoveEvents()
end
function WizF_Death(pUnit)
pUnit:SendChatMessage(14, 0, "All those hours of studying, all for what? TO die in the hands of these lesser beings.")
pUnit:RemoveEvents()
end
function WizF_OnKilledTarget(pUnit)
pUnit:SendChatMessage(14, 0, "This is a lesson.")
end
RegisterUnitEvent(80000, 1, "WizF_OnEnterCombat")
RegisterUnitEvent(80000, 2, "WizF_OnLeaveCombat")
RegisterUnitEvent(80000, 3, "WizF_OnKilledTarget")
RegisterUnitEvent(80000, 4, "WizF_Death")
You had your remove events all messed up, and on spawn of the npc you were using Unit and pUnit.