Freeze party in place at will (Via mahric)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Freeze party in place at will (Via mahric)

Post by msyblade »

Still playing mahric's Wine Merchant Basement (I am just enamored with this mod), and he released his source files for us. One little trick I really wanted to get from him was freezing the party in place to allow storyline fleshing, etc. I pm'd him to ask and this is how simple he made it.

create a counter in your dungeon set to 1,call it whatever you like. (I used cMove)

Then, clone your party in your init.lua with an onMove hook for the counter. If the counter is at 0, onMove returns false. connect a plate where you want to stop the party, to decrement the counter. BAM, onMove returns false.Set a timer to increment the cMove counter, for the time you need to do what you want. Then BAM!, party has control again. Here's the party clone script to put in the init.lua (Make sure to reference the counter correctly, or onMove will crash to desktop.

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",

   onMove = function(self, dir)
      if (cMove:getValue() == 0) then
         return false
      end
         return true
   end,
}
And it's that simple! Thanx again Mahric!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Freeze party in place at will (Via mahric)

Post by JohnWordsworth »

Heh, that's a really nice way of generalising it so that then any part of your dungeon can turn that feature on/off at will.

I don't know for sure, but I expect if you want to prevent the potential crash to Desktop, you could just check for nil before calling the method like so.
SpoilerShow

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",

   onMove = function(self, dir)
      if (cMove ~= nil and cMove:getValue() == 0) then
         return false
      end

      return true
   end,
}
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Freeze party in place at will (Via mahric)

Post by Komag »

I always set variables like that at dungeon start so there is no chance of it being nil, just as a habit

script entity called partyMoveScript

Code: Select all

cMove = 0
function freezeParty()  cMove = 0  end
function thawParty()  cMove = 1  end
- plate triggers timer and freezeParty()
- timer triggeres thawParty() and self (deactivate)

my party object:

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",
   onMove = function(self, dir)
      if partyMoveScript.cMove == 0 then  return false  end
   end,
}
(you don't need the "return true" part, that's just default)
Finished Dungeons - complete mods to play
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Freeze party in place at will (Via mahric)

Post by JohnWordsworth »

Ahh, I assumed that cMove was a script_entity. I always do a nil check when accessing script entities from object hooks, as you write one in Notepad++ and the other in the editor and if you get the name wrong say - crash! I do this just incase the script entity has had it's name changed or I've forgot to paste it in. Arguably though, you could say the crash at least tells you if you've forgotten to include partyMoveScript in your dungeon - instead of getting unexpected behaviour from skipping over certain function calls.

Didn't know if you had to return true or not - but it's nice to know you don't have to :).
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Post Reply