Changeing damage on Spells

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Changeing damage on Spells

Post 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 ;)
Dunkler
Posts: 73
Joined: Thu Jul 10, 2014 3:20 pm

Re: Changeing damage on Spells

Post 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.
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Changeing damage on Spells

Post 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
Dunkler
Posts: 73
Joined: Thu Jul 10, 2014 3:20 pm

Re: Changeing damage on Spells

Post by Dunkler »

Thank you :) works now!
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Changeing damage on Spells

Post 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.",
}

GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Changeing damage on Spells

Post by GoldenShadowGS »

why are you using 0.5 to modify the coordinates, I think they need to stay as integers probably.
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Changeing damage on Spells

Post 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:
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Changeing damage on Spells

Post by minmay »

You should use integer coordinates and then use setWorldPosition() to put the fireball in the exact position you want.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Changeing damage on Spells

Post by Aisuu »

Thank you guys for the help :)
Post Reply