New Spells

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

New Spells

Post by RayB »

I noticed when setting up a spawner you could select a 'frostburst' in the 'item to spawn' box. I got to looking at the Grimrock 1 asset pack and found that a frostburst is defined (makes sense if you can use it in a spawner). However it is not one of the spells. So I decided to create my own frostburst spell using ruin 'I' to fire it.

I was able to create the spell by defining it in my mod and when I use it, the mod says I have fired a fireburst spell. But I get an error saying:

'unknown built in spell: fireburst

If a fireburst graphic is defined in the assets why do I get this error? I used the same script to define the spell that was used in the asset pack to define all the other spells. Is there any way to make this work?

Stuck again!
RayB
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: New Spells

Post by minmay »

I assume you meant to say "frostburst" when you said "fireburst".

It means exactly what the message says: there isn't a built-in "frostburst" spell. If you specify a string for onCast, it must be the name of a built-in spell. If you want to make a custom spell, you need to specify a function instead. For example:

Code: Select all

defineSpell{
	name = "print_cow_noise",
	uiName = "Print Cow Noise",
	gesture = 123,
	manaCost = 5,
	onCast = function(champion, x, y, direction, elevation, skillLevel)
		print("MOO!")
	end,
	skill = "concentration",
	requirements = { "concentration", 1 },
	icon = 67,
	spellIcon = 17,
	description = "Prints a noise commonly made by cows.",
}
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.
RayB
Posts: 140
Joined: Fri Mar 06, 2015 3:45 am

Re: New Spells

Post by RayB »

Thanks much but I had kind of gotten that far with the following script...

defineSpell {
name = "frostburstSpell",
uiName = "Frostburst",
skill = "ice_magic",
level = 2,
runes = "I",
manaCost = 15,
--onCast = "frostburst" --this was my original onCast line. The one that gave the error.
onCast = function(spell)
local cx = party.x local cy = party.y
if party.facing == 0 then cy = cy -1
elseif party.facing == 1 then cx = cx + 1
elseif party.facing == 2 then cy = cy + 1
elseif party.facing == 3 then cx = cx -1
end
spawn("frostburst",party.level,cx,cy,0)
end,
}

It works but the problem is: If I cast the spell into a wall (a blank tile) or a door etc., the spell casts inside the wall instead of blowing up in the party's face and causing the party some damage. I realize if I cast the spell in the same tile the party is in I can accomplish this but I can't think of an easy way to know if the party is facing a door, wall or some other obstruction. I would think it would take a heck of a lot of processing time to test for every possible obstruction and even then I don't know how to test for an unused tile. I thought that if I defined the onCast as a spell the engine would see it as a spell and all this would be taken care of. I was wrong.

P.S. If you could please; tell me how you guy's accomplish putting script into the imbedded little window
with the select-all button and the code indented and all that. That is, if it's not terribly difficult to explain.
If I am going to be using this forum it would be nice to learn how to do things properly.
Post Reply