a script to trigger when a rune is cast

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
Karinas23
Posts: 58
Joined: Thu Jul 24, 2014 8:57 pm

Re: a script to trigger when a rune is cast

Post by Karinas23 »

Created 4 versions of the spell and they all work great. Though i guess the way these are defined the spell will only work on the 1 tile and nowhere else since theyre reliant on the tiles ID ?
SpoilerShow
defineSpell{
name = "karinafire_spell",
uiName = "Dispell Fire Seal",
requirements = {"fire_magic", 5},
gesture = 521,
manaCost = 5,
icon = 0,
spellIcon = 0,
description = "A spell to open doors sealed with a Fire Element Seal",
onCast = function(champion, x, y, direction, elevation, skillLevel)
customSpellScript.script.karinaSpellCast1(champion, x, y, direction, elevation, skillLevel)
end,
}

defineSpell{
name = "karinaair_spell",
uiName = "Dispell Air Seal",
requirements = {"air_magic", 5},
gesture = 563,
manaCost = 5,
icon = 0,
spellIcon = 0,
description = "A spell to open doors sealed with an Air Element Seal",
onCast = function(champion, x, y, direction, elevation, skillLevel)
customSpellScript.script.karinaSpellCast2(champion, x, y, direction, elevation, skillLevel)
end,
}

defineSpell{
name = "karinas_spell",
uiName = "Dispell Water Seal",
requirements = {"water_magic", 5},
gesture = 589,
manaCost = 5,
icon = 0,
spellIcon = 0,
description = "A spell to open doors sealed with a Water Element Seal",
onCast = function(champion, x, y, direction, elevation, skillLevel)
customSpellScript.script.karinaSpellCast3(champion, x, y, direction, elevation, skillLevel)
end,
}

defineSpell{
name = "karinas_spell",
uiName = "Dispell Earth Seal",
requirements = {"earth_magic", 5},
gesture = 547,
manaCost = 5,
icon = 0,
spellIcon = 0,
description = "A spell to open doors sealed with an Earth Element Seal",
onCast = function(champion, x, y, direction, elevation, skillLevel)
customSpellScript.script.karinaSpellCast4(champion, x, y, direction, elevation, skillLevel)
end,
}
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: a script to trigger when a rune is cast

Post by Prozail »

It depends on how you want to design things. The following spelldefinition will open any door that has the Word "fireseal" in it's ID like "door_wooden_fireseal_1" when the party is standing in front of it.

Code: Select all


defineSpell{
	name = "dispel_fire_seal",
	uiName = "Dispell Fire Seal",
	requirements = {"concentration", 1},
	gesture = 521,
	manaCost = 5,
	icon = 0,
	spellIcon = 0,
	description = "A spell to open doors sealed with a Fire Element Seal.",
	onCast = function(champion, x, y, direction, elevation, skillLevel)
		local dx,dy = getForward(direction)
		for i in party.map:entitiesAt(x+dx, y+dy) do
				if i.id:match("fireseal") then
					if i.door and i.door:isClosed() then
						i.door:open()
						playSound("level_up")
						return
					end
				end
		end
		--no door found?? check our own square.. (doors are between squares.)
		for i in party.map:entitiesAt(x, y) do
			if i.id:match("fireseal") then
				if i.door and i.door:isClosed() then
					i.door:open()
					playSound("level_up")
					return
				end
			end
		end
	end,
}

Edit: Fixed a slight bug.
Last edited by Prozail on Thu Nov 13, 2014 5:47 pm, edited 1 time in total.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: a script to trigger when a rune is cast

Post by akroma222 »

Ahh nice work Prozail, that is a much more versatile version!!
User avatar
Karinas23
Posts: 58
Joined: Thu Jul 24, 2014 8:57 pm

Re: a script to trigger when a rune is cast

Post by Karinas23 »

Thats much more efficient and doesnt require the ingame script either thank you very much
Post Reply