Page 1 of 3

Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 3:59 am
by Neikun
From the modding resource:
rangedAttack: the ranged attack to perform when “ranged_attack” animation event is triggered. Must be one of the following: “lightning_bolt”, “lightning_bolt_greater”, “ice_shards”, “fireball”, “fireball_greater”, “poison_bolt”, “frost_arrow”.

Why are we limited to these? How would I go about using frostbolt instead?

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 4:07 am
by Batty
Probably limited to those because those are the only ones monsters used in the main game, I think.

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 4:08 am
by Neikun
I figured as much. But we must be able to expand on it. An Icy Uggardian using ice shards will use it even if out of range. :\

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 4:25 am
by Batty
Errrrr, I guess you'd have to cancel the spell the monster was gonna cast by using the onRangedAttack hook, then spawn your frostbolt from the monster's x, y, facing?

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 5:07 pm
by LordGarth
I already posted this on one of my posts.

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 any your spells. Custom spells or regular. Then the monster will shoot two spells. The one it would normally and the new one.

LG

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 6:01 pm
by Xanathar
Great solution.
Just to improve it a little bit:

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

Should do the trick in less lines, plus, thanks to the return, cancel the original spell.

Re: Question(s) on rangedAttack

Posted: Sat Nov 10, 2012 10:39 pm
by Komag
If in some other case you still needed a few separate lines, you can use elseif instead of fully separate if...end (so long as it makes sense to do so and it's not a case where it might be logical to do BOTH things)

Re: Question(s) on rangedAttack

Posted: Sun Nov 11, 2012 3:39 am
by Neikun
I don't understand how to implement these scripts.
I tried throwing Garth's in the monster's script, but it causes the file not to open.
Not a clue as to where to stick Xanathar's either.

Edit: got Garth's to load the file. (was missing an end.)
It however creates an error message in the console.
How can I get Xanathar's to work?

Re: Question(s) on rangedAttack

Posted: Sun Nov 11, 2012 4:34 am
by Batty
Xanathar script would look like this:

Code: Select all

onRangedAttack = function(self)
     local dx, dy = getForward(self.facing)
     spawn("frostbolt", self.level, self.x + dx, self.y + dy, self.facing)
     return false
end,
Haven't tried it but it looks good.

Re: Question(s) on rangedAttack

Posted: Sun Nov 11, 2012 4:35 am
by Neikun
welp. the function(self) part was what I was missing lol.
Thanks Batty. Testing now.

PERFECT!
Thanks everyone. Frozen Uggardian should be ready to pack shortly. What should we name it?
Lets do it logically and disect the word before voting.
Ug Gardian
Gardian phonetically sounds like 'guardian' and I feel that's what it means.
That means Ug means something fire related?

So lets vote on one syllable 'words' to name the cold uggardian.

I vote 'er' Ergardian