Page 1 of 1

Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:11 pm
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!

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:17 pm
by Decayer
Any script code outside of a function will run when you enter the dungeon, at least.

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:18 pm
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.

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:42 pm
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.

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:52 pm
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.

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 4:56 pm
by Xanathar
The pressure plate route can be hard for some dungeons. Think of pits, cross level teleports, etc. :?

Re: Enter/Leave Game/Level Hook

Posted: Mon Nov 05, 2012 6:41 pm
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