So here is my problem, I've just started teaching myself LUA and have run into a problem. I've searched tons of posts and alot of people have the same problem where when the mob casts the spell it casts it on itself. I have tried it numerous ways GetClosestPlayer() GetMainTank() and always casts on itself. I am running the most recent trunk version (Could this possibly be the problem?, or perhaps my lua script) Anyhow, hopefully someone can shed some light on it.
Code:
function ManaWyrm_GenCast(pUnit, event)
--1st we declare local variables
local nSpell = math.random(0,100) --number of random general spells for mob, in this case 2. Random 0 and Random 1
local nCheck = math.random(0,3)
local plr = pUnit:GetRandomPlayer(0)
-- Check if we are casting a spell. 75% chance
if nCheck > 0 then
--Check nSpell to see what spell/skill we case
if nSpell > 70 and nSpell < 90 then
if (plr ~= nil) then pUnit:FullCastSpellOnTarget(36100,plr) end
elseif nSpell >= 90 and nSpell < 99 then
if (plr ~= nil) then pUnit:FullCastSpellOnTarget(6950,plr) end
elseif nspell == 99 or nSpell == 100 then
if (plr ~= nil) then pUnit:FullCastSpellOnTarget(16460,plr)end
else
if (plr ~= nil) then pUnit:FullCastSpellOnTarget(17253, plr)end
end
end
end
function ManaWyrm_OnCombat(Unit, event)
Unit:RegisterEvent("ManaWyrm_GenCast",4000,0) -- Goes into ManaWyrm_GenCast every 4 seconds.
end
RegisterUnitEvent(15274, 1, "ManaWyrm_OnCombat")