Page 1 of 1

monsters using custom spells

Posted: Mon Oct 29, 2012 11:56 pm
by LordGarth
Hello all,

I got a monster that uses magic ranged attack to use a custom spell along with its standard magic attack

onRangedAttack = function(self)
if self.facing == 0 then
spawn("armagedon", self.level, self.x, self.y-1, self.facing)
end
if self.facing == 1 then
spawn("armagedon", self.level, self.x+1, self.y, self.facing)
end
if self.facing == 2 then
spawn("armagedon", self.level, self.x, self.y+1, self.facing)
end
if self.facing == 3 then
spawn("armagedon", self.level, self.x-1, self.y, self.facing)
end

just replace armagedon with the name in the defineObject for your custom spell

This is what the Lord of Chaos in my game will be using by the way muahhahahahahahhaah. ouch
Better have healing pots ready and find all of the tomes of health.

:lol: :evil: :twisted:


LG

Re: monsters using custom spells

Posted: Tue Oct 30, 2012 1:50 am
by Grimwold
two things come to mind... the first is, you should check out the function getForward()... it would save you several lines of code.

Your whole function can be re-written in 2 lines:

Code: Select all

local dx,dy = getForward(self.facing)
spawn("Armageddon", self.level, self.x + dx, self.y + dy, self.facing)