Enter/Leave Game/Level Hook

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Fhizban
Posts: 68
Joined: Sun Oct 21, 2012 2:57 pm
Location: Germany
Contact:

Enter/Leave Game/Level Hook

Post by Fhizban »

Hey all,
Quick question: Are there any hooks we can use for scripting, when the party first enters the game. And, are there any hooks when the party enters or leaves a dungeon level?

Otherwise i would have to place a invisible pressure plate on the parties starting/entering location.

why? scripting once-per-dungeon / once-per-level stuff

thanks for any help!
--
Fhizban's Asset Repository - the place where you find all my LoG contributions:
viewtopic.php?f=14&t=3904
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Enter/Leave Game/Level Hook

Post by Decayer »

Any script code outside of a function will run when you enter the dungeon, at least.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Enter/Leave Game/Level Hook

Post by Xanathar »

For the start of dungeon I would go with the pressure plate route (actually, I'm going with that route, as I have this requirement in my mod).

For the start/end of level you have many options:
  • Pressure plates at the end of the stairs and end of teleports - this might be easy or hard depending on your dungeon
  • A timer on any level, checking if the party.level is the same as a level never entered and taking actions - this is ok if you don't require your script to execute exactly as the party enters the level (it will execute some seconds after)
  • An hook to party.onMove and the same check as above.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Enter/Leave Game/Level Hook

Post by Grimwold »

Decayer wrote:Any script code outside of a function will run when you enter the dungeon, at least.
I also do this for start of game scripting...

e.g. I have a script entity called default_party that just includes the following.

Code: Select all

-- add custom party-scripts here

for champID = 1,4 do
  party:getChampion(champID):addSkillPoints(10)
  party:getChampion(champID):insertItem(11,spawn("pitroot_bread"))
  party:getChampion(champID):insertItem(2,spawn("peasant_tunic"))
  party:getChampion(champID):insertItem(3,spawn("peasant_breeches"))
  party:getChampion(champID):insertItem(4,spawn("sandals"))
  if champID < 3 then
    party:getChampion(champID):insertItem(7,spawn("knife"))
  end
end

local startArrow = spawn("arrow")
party:getChampion(3):insertItem(8, startArrow)
startArrow:setStackSize(5)
party:getChampion(3):insertItem(7, spawn("short_bow"))

party:getChampion(2):setPortrait("mod_assets/portraits/dwarvenWarrior.tga")
party:getChampion(1):setPortrait("mod_assets/portraits/paladin.tga")
party:getChampion(3):setPortrait("mod_assets/portraits/prodigalSorcerer.tga")
party:getChampion(4):setPortrait("mod_assets/portraits/quirion.tga")
Some of these are just for testing purposes.

Otherwise I'd use hidden pressure plates as the only downside is that the party have to enter the level via specific locations to activate the hidden pressure plate.
User avatar
Fhizban
Posts: 68
Joined: Sun Oct 21, 2012 2:57 pm
Location: Germany
Contact:

Re: Enter/Leave Game/Level Hook

Post by Fhizban »

thank you all. thats good to know.

okay, a script entity especially for entering the game and pressure plates at the entrance points of dungeon levels, thats how to do it.
--
Fhizban's Asset Repository - the place where you find all my LoG contributions:
viewtopic.php?f=14&t=3904
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Enter/Leave Game/Level Hook

Post by Xanathar »

The pressure plate route can be hard for some dungeons. Think of pits, cross level teleports, etc. :?
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
Fhizban
Posts: 68
Joined: Sun Oct 21, 2012 2:57 pm
Location: Germany
Contact:

Re: Enter/Leave Game/Level Hook

Post by Fhizban »

@Xanathar arrrgggh, yes you are right - so much stuff to think about!

how about this: another script entity that runs automatically with an if-then structure that checks the current dungeon level first?

Code: Select all

if party.level == 1 then
if var_init == false then
--do dungeon level 1 init stuff
var_init = true
end
end
--
Fhizban's Asset Repository - the place where you find all my LoG contributions:
viewtopic.php?f=14&t=3904
Post Reply