I tried this based on LocalFire's good suggestion and what I've picked up from other people's monsters.lua.
Code: Select all
onRangedAttack = function(self)
local dx, dy = getForward(self.facing)
local SpellCall = math.random(1,2)
if SpellCall == (1) then
spawn("water_bolt", self.level, self.x + dx, self.y + dy, self.facing)
return false
end,
else
if SpellCall == (2) then
spawn("improved_frostbolt", self.level, self.x + dx, self.y + dy, self.facing)
return false
end,
Something is amiss and I haven't figured out what. When I try to load my mod the error "unexpected symbol near ," appears. It's the first time I've tried such a long script in the midst of a "cloneObject" hook.
I have a question, besides trying to get this working, how can I change something like this to have 3 options rather than just two. I can't just keep tacking "else" lines, but there must be some sort of "or" that I can use. I'd like to change this script to include a third ranged spell.