Question about built-in 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!
Post Reply
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Question about built-in spells

Post by MrChoke »

I am looking at how onCast() works for in-game objects. I thought it specified an object defined to be the spell. But for quite a few spell definitions this is not the case. They may have defineObject defintions close to the value given in onCast or sometimes no object. Take fireball for example:

Here is its "defineSpell":

Code: Select all

defineSpell{
	name = "fireball",
	uiName = "Fireball",
	gesture = 1236,
	manaCost = 43,
	onCast = "fireball",
	skill = "fire_magic",
	requirements = { "fire_magic", 3, "air_magic", 1 },
	icon = 61,
	spellIcon = 7,
	description = "A flaming ball of fire shoots from your fingertips causing devastating damage to your foes.",
}
So its onCast is "fireball". That means there should be an object called fireball, right? There is not. There is a LUA file called fireball.lua. In it are three types of fireballs: small, medium, large:

Code: Select all

defineObject{
	name = "fireball_small",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "fireball_small",
		},
		{
			class = "Light",
			color = vec(1, 0.5, 0.25),
			brightness = 10,
			range = 5,
			castShadow = true,
		},
		{
			class = "Projectile",
			spawnOffsetY = 1.35,
			velocity = 10,
			radius = 0.1,
			hitEffect = "fireball_blast_small",
		},
		{
			class = "Sound",
			sound = "fireball",
		},
		{
			class = "Sound",
			name = "launchSound",
			sound = "fireball_launch",
		},
	},
}

defineObject{
	name = "fireball_medium",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "fireball_medium",
		},
		{
			class = "Light",
			color = vec(1, 0.5, 0.25),
			brightness = 15,
			range = 7,
			castShadow = true,
		},
		{
			class = "Projectile",
			spawnOffsetY = 1.35,
			velocity = 10,
			radius = 0.1,
			hitEffect = "fireball_blast_medium",
		},
		{
			class = "Sound",
			sound = "fireball",
		},
		{
			class = "Sound",
			name = "launchSound",
			sound = "fireball_launch",
		},
	},
}

defineObject{
	name = "fireball_large",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "fireball_large",
		},
		{
			class = "Light",
			color = vec(1, 0.5, 0.25),
			brightness = 15,
			range = 7,
			castShadow = true,
		},
		{
			class = "Projectile",
			spawnOffsetY = 1.35,
			velocity = 10,
			radius = 0.1,
			hitEffect = "fireball_blast_large",
		},
		{
			class = "Sound",
			sound = "fireball",
		},
		{
			class = "Sound",
			name = "launchSound",
			sound = "fireball_launch",
		},
	},
}
So which one is used and when???

Note many others, like "heal", "openDoor", "causeFear", etc... don't define anything. I guess we have to experiment in-game to see what these do. Example, how much does "heal" heal? They must be completely hard-coded not even in the LUA files.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Question about built-in spells

Post by minmay »

This is explained in the scripting reference.
onCast(champion, x, y, direction, elevation, skillLevel): built-in spell function name or a custom spell function.
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.
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Question about built-in spells

Post by MrChoke »

minmay wrote:This is explained in the scripting reference.
onCast(champion, x, y, direction, elevation, skillLevel): built-in spell function name or a custom spell function.
Yes, I saw that. That would be for a custom spell versus using a "built-in" one. The built-in ones seem to be a bit of a black box I guess since you can't see in any scripting reference on what these do. Example, what size fireball does the default spell shoot, small medium or large? And does it vary? This stuff must be all be built into the engine I guess.
Post Reply