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

a script to trigger when a rune is cast

Post by Karinas23 »

Much like getting teleported when you cast the balance rune at the en d of the main game....( i dont know shit about scripting )

Basically i want a door to open when a specific rune is cast while stood on a specific tile. any idea how id go about that
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 »

Karinas23
Define the spell in your spells.lua
SpoilerShow

Code: Select all

defineSpell{
   	name = "karinas_spell",
   	uiName = "Karinas Spell",
	requirements = {"concentration", 1},
   	gesture = 147,
 	manaCost = 5,
	icon = 0,
	spellIcon = 0,
	description = "door to open when a specific rune is cast while stood on a specific tile.",
   	onCast = function(champion, x, y, direction, elevation, skillLevel)
		customSpellScript.script.karinaSpellCast(champion, x, y, direction, elevation, skillLevel)
   	end,
}
Then place a script entity in your dungeon called 'customSpellScript' and paste this into it...
SpoilerShow

Code: Select all

function karinaSpellCast(champion, x, y, direction, elevation, skillLevel)
	
	local square = findEntity("karinaSpellSquare")
	
	if (party.level == square.level
	and party.x == square.x
	and party.y == square.y
	and party.elevation == square.elevation) then
		hudPrint("Success!!.... do stuff here.")
		karinaDoor.door:open()
		playSound("level_up")
	else
		hudPrint("You need to be standing on the grass...")
		champion:playDamageSound()
	end
end
Then place an object (forest_floor_01 for example) somewhere in your dungeon and name it 'karinaSpellSquare'

Lastly place a door (castle_door_wood for example) somewhere in your dungeon (probably close by) and name it 'karinaDoor' - DONE!

The spell uses the 3 runes on the left, top left to bottom left.
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 »

ty i will try this....i assume gesture = 147 is the runes required ? as in

123
456
789 ?
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 »

Yup!
The spell uses the 3 runes on the left, top left to bottom left.
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 »

now i can create my doors sealed with rank 5 elemental spells ;p
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 »

Spell just causes an error ;p
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: a script to trigger when a rune is cast

Post by Blichew »

What's the error ?

From the top of my head: is the spell actually "castable" ? I mean does it form a line on the casting grid ?
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 »

its castable....the error happens when i cast it


Image
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: a script to trigger when a rune is cast

Post by Blichew »

Looks like you don't have customSpellScript script_entity in the game.

Could you post spell definition here ? code from customSpellScript script_entity might come handy too... :)
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 »

never mind i got it, the danger of having your own name in scripts....automatically capitalising it without realising
Post Reply