[Scripting] Start Outro if creature has been killed

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
KSE
Posts: 4
Joined: Wed Jan 08, 2014 4:30 pm

[Scripting] Start Outro if creature has been killed

Post by KSE »

Could someone PLEASE provide the script to start the outro movie after a monster (e.g. the boss) has been killed. i tried to do it myself via trial and error but can't figure it out. i created a 5 level mini-campaign and i just want to finally finish it.
User avatar
DesperateGames
Posts: 90
Joined: Sun Oct 06, 2013 1:54 pm

Re: [Scripting] Start Outro if creature has been killed

Post by DesperateGames »

Hello KSE,

the function to start the Outro / complete the game is as follows:
completeGame([cinematicsFile])
Completes the game and optionally plays back a cinematics file. cinematicsFile must be a valid cinematics filename. Note, in the Dungeon Editor this function only prints “Game Completed” to the console.
(Quoted from scripting reference).

Now there are multiple ways how you could achieve that this function gets called when your boss monster dies. The direct approach would be to create a special monster definition in monsters.lua of your dungeon that has an "OnDie"-scripting hook. This will allow you to execute code / functions when a certain monster dies. This would be the example code in monsters.lua if you would use the default spider as boss monster and you have your outro in the file "ending.lua" in the cinematics folder:

Code: Select all

cloneObject{
	name="MyBossSpider",
	baseObject="spider",
	onDie=function(monster)
		completeGame("ending.lua")
		end
}
If you place the MyBossSpider-Monster in the dungeon and kill it, it should result in the Outro playing instantly when the monster dies. If you want, you can also activate a timer from the OnDie-Hook, which then calls the completeGame-function with a little delay, which feels nicer in my opinion.
KSE
Posts: 4
Joined: Wed Jan 08, 2014 4:30 pm

Re: [Scripting] Start Outro if creature has been killed

Post by KSE »

Thanks.

Now, when i kill my monster, the game crashes and i get the message "file not found: outro.lua". But the "outro.lua" is inside the cinematics folder in my documents\Almost Human\Legend of Grimrock\Dungeons\Heartbleed\mod_assets\cinematics\. I also tried to create an cinematics folder within the installation folder of Grimrock (in Programs), but i get the same error.

My code is (in monsters.lua)

cloneObject{
name="testmonster",
baseObject="snail",
onDie=function(monster)
completeGame("outro.lua")
end
}

i'm calling the script via a script entity which includes

function outro()
completeGame("outro.lua")
end

is that correct?
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: [Scripting] Start Outro if creature has been killed

Post by antti »

I think the issue here is probably that you need to include the path to the outro as well. Like this: "mod_assets/cinematics/outro.lua"
Steven Seagal of gaming industry
KSE
Posts: 4
Joined: Wed Jan 08, 2014 4:30 pm

Re: [Scripting] Start Outro if creature has been killed

Post by KSE »

I finally managed to get it to work. Thanks. Does somebody know the filname of the main theme? I know that Grimrock comes with two music files: intro.ogg and ...?
Post Reply