Page 1 of 1

[Scripting] Start Outro if creature has been killed

Posted: Wed Jan 08, 2014 4:35 pm
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.

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

Posted: Thu Jan 09, 2014 12:42 am
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.

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

Posted: Thu Jan 09, 2014 10:13 am
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?

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

Posted: Thu Jan 09, 2014 10:55 am
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"

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

Posted: Thu Jan 09, 2014 11:53 am
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 ...?