I've only recently started using Lua to script mobs, so I'm not 100% sure if this will work, but you could maybe try creating a sort of timer with a random "tick" interval using math.random.
Kinda hard for me to explain what I mean, here's the code:
Code:
--begin timer code
local timerInterval = 0; --this is how many seconds it takes for the timer to run
local currentCount = 0; --this is the number of seconds we've waited so far
function MobName_onEnterCombat(unit, event) --pick a number from 1-10, this will be the
timerInterval = math.random(1,10) * 1000 --delay in seconds (multiply by 1000 for milliseconds)
currentCount = 0;
unit:RegisterEvent("MobName_Tick", 1000, 0) --our "timer" fires once per second
end
function MobName_Tick(unit, event)
currentCount = currentCount + 1000 --increment the counter by 1 second
if currentCount >= timerInterval then --if the counter is equal to or greater than
doStuffHere(); --the interval, we cast our spell
timerInterval = math.random(1,10) * 1000 --and then reinitialize our timer with another random interval.
currentCount = 0;
end
end
--end timer code
Not the most graceful way to do it, sure, but it should get the job done :P
Although, again, I'm not sure if it will work since I haven't used Lua outside of writing addons very much, so I don't know if you can define a local variable outside of a function.