Page 1 of 1

shootProjectile() offset values not working?

Posted: Fri Oct 05, 2012 7:08 pm
by JohnWordsworth
I was just creating a few spells for the fun of it really, and I attempted to create a spell which fires 3 daggers in a straight-line across a single space (so 3 daggers fired forwards, but all in the same starting space. I had assumed that by setting offsetX to different values, I could throw them in a horizontal line.

However, I don't know if I am just not using the correct values or the function is indeed broken. Has anyone else had any luck firing projectiles using shootProjectiles using offset values != 0?

Re: shootProjectile() offset values not working?

Posted: Fri Oct 05, 2012 8:04 pm
by Blichew
Try this:

(not exactly what you wanted, but hey, it works - kinda... )

Code: Select all

defineSpell{
	name = "knives",
	uiName = "Throw Knives",
	skill = "spellcraft",
	level = 1,
	runes = "AC",
	manaCost = 1,
	onCast = function(champ, x, y, direction, skill)
		local dx,dy = getForward(party.facing)
		local x,y = party.x + dx, party.y + dy
		if party.facing == 0 or party.facing == 2 then
			shootProjectile("throwing_knife", party.level, x+0.2, y, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
			shootProjectile("throwing_knife", party.level, x, y, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
			shootProjectile("throwing_knife", party.level, x-0.2, y, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
		else
			shootProjectile("throwing_knife", party.level, x, y-0.2, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
			shootProjectile("throwing_knife", party.level, x, y, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
			shootProjectile("throwing_knife", party.level, x, y+0.2, party.facing, 10, 1.5, 1, 0, 0, 0, 10, false, true)
		end
	end
}

Re: shootProjectile() offset values not working?

Posted: Sat Oct 06, 2012 4:04 am
by JohnWordsworth
Ahh, this looks spot on. Never thought of using non-integer values for the x,y coordinates. Can't wait to test tomorrow :). Many thanks!