Random Scripting

Posted by Aznvt33 on Fri 16 Mar 2007 03:50 PM — 3 posts, 13,946 views.

#0
I wanna do a script where I cast a random staffcast while bashing, except I have no idea how to use the math.random function.

There are 4 different staffcasts:

STAFFCAST DISSOLUTION AT <adventurer/denizen> (magical damage)
STAFFCAST LIGHTNING AT <adventurer/denizen> (electric damage)
STAFFCAST SCINTILLA AT <adventurer/denizen> (fire damage)
STAFFCAST HORRIPILATION AT <adventurer/denizen> (cold damage)

I'm thinking that I should make an alias for each one, and use math.random to assign a number for each alias and Execute ("the proper alias"). How would I do this?
USA #1
You could have a function that does something like this...


function random_cast(target)
  local spells = {
   "dissolution",
   "lightning",
   "scintilla",
   "horripilation",
  }

  local spellNum = math.random(1, #spells)

  return "staffcast " .. spells[spellNum] .. " at " .. target
end


Then whenever you want to cast a random spell, have your alias call this function, passing in the target you want, and send the result to the world.
#2
Thanks, I figured it out. Works great.