[Scripting] Start Outro if creature has been killed
[Scripting] Start Outro if creature has been killed
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.
- DesperateGames
- Posts: 90
- Joined: Sun Oct 06, 2013 1:54 pm
Re: [Scripting] Start Outro if creature has been killed
Hello KSE,
the function to start the Outro / complete the game is as follows:
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:
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.
the function to start the Outro / complete the game is as follows:
(Quoted from scripting reference).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.
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
}
Re: [Scripting] Start Outro if creature has been killed
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?
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
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
Re: [Scripting] Start Outro if creature has been killed
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 ...?