Page 1 of 1

Lizard casting a spell: how to do correctly.

Posted: Sun Nov 11, 2012 5:51 am
by crisman
I wanted a lizard casting a spell when attacking, in my case, the fireburst.
But I noticed when it does a turn attack it will keep casting it in front of it, and not where is actually attacking.
So I've figured out how can this be solved. It's a bit tricky, and not immediate, and someone might find it useful.
The code is:

Code: Select all

onAttack = function(self, attack)
local dx, dy = getForward(self.facing)
if attack == "attack" then
	spawn("fireburst", self.level, self.x+dx, self.y+dy, 0)
elseif attack == "turnAttackLeft" then
	spawn("fireburst", self.level, self.x+dy, self.y-dx, 0)
elseif attack == "turnAttackRight" then
	spawn("fireburst", self.level, self.x-dy, self.y+dx, 0)
end
   end,
I really think this can be applied to all monsters that do a turn attack (ogre, warden), if the name of the attack is the same.

Re: Lizard casting a spell: how to do correctly.

Posted: Sun Nov 11, 2012 12:47 pm
by Komag
oh that could be useful to know, would be good in the script repository :)

Re: Lizard casting a spell: how to do correctly.

Posted: Sun Nov 11, 2012 5:50 pm
by LordYig
This is some "Nice to known" trick.

Add some particle effect and you have a nice dragon like lizard breathing fire ;)
(But i don't know if this last part is doable with the lizard model...)

Re: Lizard casting a spell: how to do correctly.

Posted: Sun Nov 11, 2012 7:50 pm
by crisman
Ok! I've added to the repository! :D