Page 2 of 2

Re: Changeing damage on Spells

Posted: Mon Dec 22, 2014 5:49 pm
by AndakRainor
Well iirc there is a better syntax than the one I use but here it is:

Code: Select all

if direction == 0 then y = y-1 else if direction == 1 then x = x+1 else if direction == 2 then y = y+1 else x = x-1 end end end
before launching anything in the party faces ;)

Re: Changeing damage on Spells

Posted: Mon Dec 22, 2014 6:06 pm
by Dunkler
Is +1 the least value you can use?

Because when i use this numbers the spell launaches a bit too far in front of the party.

For example if i stand in front of a wall the fireball does not damage me, instead it launches inside the wall an explodes there.

Re: Changeing damage on Spells

Posted: Mon Dec 22, 2014 6:51 pm
by GoldenShadowGS
You need to do a check to see if the party is in front of a wall.

Add this to your script and run the function checkwall(), if it returns true, then spawn the fireball on the same square as the party, if it returns false, spawn it one tile in front of the party.

Code: Select all

function checkwall()
	local direction = party.facing
	local x = party.x
	local y = party.y
	local elevation = party.elevation
	local myx = x
	local myy = y
	if direction == 0 then
		myy = y - 1
	elseif direction == 1 then
		myx = x + 1
	elseif direction == 2 then
		myy = y + 1
	elseif direction == 3 then
		myx = x - 1
	end
	if not party.map:checkLineOfFire(x,y,myx,myy,elevation) then
		return true
	else
		return false
	end
end

Re: Changeing damage on Spells

Posted: Wed Dec 24, 2014 4:07 pm
by Dunkler
Thank you :) works now!

Re: Changeing damage on Spells

Posted: Sun Jan 11, 2015 9:12 pm
by Aisuu
GoldenShadowGS wrote:You need to do a check to see if the party is in front of a wall.

Add this to your script and run the function checkwall(), if it returns true, then spawn the fireball on the same square as the party, if it returns false, spawn it one tile in front of the party.
SpoilerShow

Code: Select all

function checkwall()
	local direction = party.facing
	local x = party.x
	local y = party.y
	local elevation = party.elevation
	local myx = x
	local myy = y
	if direction == 0 then
		myy = y - 1
	elseif direction == 1 then
		myx = x + 1
	elseif direction == 2 then
		myy = y + 1
	elseif direction == 3 then
		myx = x - 1
	end
	if not party.map:checkLineOfFire(x,y,myx,myy,elevation) then
		return true
	else
		return false
	end
end
I dont know why, but when I create custom fireball spell, it perfectly works only when party facing north and south. I tryed many different scripts from all over the forum but result is same.
When party face east or west I get this error for this row:
spawn("sk_fireball", party.level, myx, myy, direction, elevation)
bad argument #1 to 'band' (number expected, got nil)

My spell def.:

Code: Select all

defineSpell{
	name = "my_fireball",
	uiName = "Fireball",
	gesture = 1,
	manaCost = 10,
	onCast  = function(champion, x, y, direction, elevation, skillLevel)
		local myx = x
		local myy = y
		if direction == 0 then myy = y - 0.5 end
		if direction == 1 then myx = x + 0.5 end
		if direction == 2 then myy = y + 0.5 end
		if direction == 3 then myx = x - 0.5 end
		if dep.script:checkwall() then	
			spawn("projectile_fireball", party.level, x, y, direction, elevation)
		else
			spawn("projectile_fireball", party.level, myx, myy, direction, elevation)
		end
	end,
	skill = "fire_magic",
	requirements = { "fire_magic", 0},
	icon = 61,
	spellIcon = 7,
	description = "A flaming ball of fire shoots from your fingertips causing devastating damage to your foes.",
}


Re: Changeing damage on Spells

Posted: Sun Jan 11, 2015 9:37 pm
by GoldenShadowGS
why are you using 0.5 to modify the coordinates, I think they need to stay as integers probably.

Re: Changeing damage on Spells

Posted: Sun Jan 11, 2015 10:00 pm
by Aisuu
Fot better visual effect. Funny thing is, that with "1" it works for east and west. But why does it only work with "0.5" fot north and south? :shock:

Re: Changeing damage on Spells

Posted: Sun Jan 11, 2015 10:24 pm
by minmay
You should use integer coordinates and then use setWorldPosition() to put the fireball in the exact position you want.

Re: Changeing damage on Spells

Posted: Mon Jan 12, 2015 10:26 am
by Aisuu
Thank you guys for the help :)