Keys in locks. Dungeon Master 2 style.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
spectre900
Posts: 124
Joined: Fri Sep 14, 2012 1:47 am

Keys in locks. Dungeon Master 2 style.

Post by spectre900 » Fri Apr 04, 2014 3:49 am

Playing around in the .lua files, I finally manage to create some "alcoves" to make keys and locks to act the same way they do in Dungeon Master 2, in other words they stay inside the lock and is retrievable. (I searched around the forums and asked, but could not find anything solid on this so I dunno if this had been made before, but whatever, here it is.)

These are for all the keys currently in Grimrock Vanilla.

Short Video (slightly outdated). https://www.youtube.com/watch?v=9P9MMZUBrNI
Pics:
SpoilerShow
Image
Image
Edit: Added all into one single file that is simply more accessible and easier to use.

How to use:
* Copy and paste text from the "objects.lua" into your mod's custom "objects.lua" file.
* Extract the model files into your "Models" folder in your custom dungeon assets.
* Find your new locks under "Props" in the editor.
* Place on a wall and link the lock_alcove to whatever you want.
* Prison locks are only used for the prison wall set as those walls are much "deeper" and normal locks will leave a big gap between them an the wall if placed in that wall set.

Can use and edit any way you want!

All models and .lua edits for download here: https://www.dropbox.com/s/nj9lafcobnxyh ... 0locks.rar

Credits:
* AdrTru for helping me with the Models.
* Isaac for providing lots of help and info.


To make a key click sound when inserting a key, link the alcove to a script entity containing the following:

Code: Select all

function playKeyClick()
   playSound("key_lock")
end
Last edited by spectre900 on Sat May 03, 2014 1:39 am, edited 13 times in total.

User avatar
Dr.Disaster
Posts: 2845
Joined: Wed Aug 15, 2012 11:48 am

Re: Keys in locks. Dungeon Master style.

Post by Dr.Disaster » Fri Apr 04, 2014 4:48 am

spectre900 wrote:Playing around in the .lua files, I finally manage to create some "alcoves" to make keys and locks to act the same way they do in Dungeon Master, in other words they stay inside the lock and is retrievable.
FYI: keys work the same in LoG and DM. Once inserted into a lock they are gone and can't be removed again.

User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Keys in locks. Dungeon Master style.

Post by msyblade » Fri Apr 04, 2014 5:32 am

I am pulling my hair out trying to recall which game had this lock mechanic. Any guesses? Lands of Lore? Stonekeep? It's driving me nuts!I feel like it was more obscure. . .Bloodwych? (Atari ST) Ishar? Aarrgh. . .

Also, Isaac made a lockpicking mod (DM style) awhile back, you might hunt it down, or Isaac will see this post and point you to it.
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
Isaac
Posts: 2949
Joined: Fri Mar 02, 2012 10:02 pm

Re: Keys in locks. Dungeon Master style.

Post by Isaac » Fri Apr 04, 2014 7:50 am

msyblade wrote:I am pulling my hair out trying to recall which game had this lock mechanic. Any guesses? Lands of Lore? Stonekeep? It's driving me nuts!I feel like it was more obscure. . .Bloodwych? (Atari ST) Ishar? Aarrgh. . .

Also, Isaac made a lockpicking mod (DM style) awhile back, you might hunt it down, or Isaac will see this post and point you to it.
It works, but it was so early (for me), that I would not recommend it now. I do plan to use it in an upcoming mod, but I will rewrite it from scratch first.
*I've no idea though, if the mod will be LoG1 or 2; probably 2, and might not even be needed in that case.

What I made does not exist as a published mod. What does exist is the lockpick model and textures; (free to use), and a video of the prototype lockpick mod in action.

http://www.youtube.com/watch?v=feu_pOWk43E

http://www.nexusmods.com/grimrock/mods/98

User avatar
spectre900
Posts: 124
Joined: Fri Sep 14, 2012 1:47 am

Re: Keys in locks. Dungeon Master style.

Post by spectre900 » Fri Apr 04, 2014 11:46 am

Dr.Disaster wrote:
spectre900 wrote:Playing around in the .lua files, I finally manage to create some "alcoves" to make keys and locks to act the same way they do in Dungeon Master, in other words they stay inside the lock and is retrievable.
FYI: keys work the same in LoG and DM. Once inserted into a lock they are gone and can't be removed again.
You sure? Oh, maybe Dungeon Master 1 did not have it, but I know DM2 have it as I've pretty much played that game to death since childhood. ^^; (never actually fully beaten it though =/ )

Will correct title accordingly.

User avatar
Eleven Warrior
Posts: 726
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Keys in locks. Dungeon Master 2 style.

Post by Eleven Warrior » Fri Apr 04, 2014 2:47 pm

This is my version of key Alcove..

1 - 1 x lever on wall and 1 x lock on wall: Lever is called (fake_lever_1) and Lock called: (KeyAlcove)
When the player uses the fake lever nothing happens ahy :)

**** The name KeyAlcove must be inside the object itself (ID KeyAlcove) ***

2 - 1 x door: What door you want does not matter. Mine is called: fake_library_door

3 - The lock (KeyAlcove) is connected to the Script Function: function checkKey(self)
When the right key is inserted into the Lock the fake lever is destroyed and a new lever is Spawned in it's place, which is then connected to the Door, via Script:

spawn("lever",2, 9,11,3, "bkd1") -- Spawns level at location replaces, fake_lever_1 --
:addConnector("activate", "dungeon_door_wooden_1", "toggle")
:addConnector("activate", "leverSndSet", "ActivateButtonSound")

4 - If the wrong Key is inserted into the KeyAlcove it prints a message and the wrong key can still be retrieved from the Lock. The right Key is destroyed when inserted into the KeyAlcove.
(The KeyAlcove is a custom object of course.)

This system works nicely and I am still fine tuning it. I will now be putting the lock and lever next to each other.. :) I hope you can understand how this system works.. :)

--- Key Object ---

defineObject{
name = "lock_A",
class = "Alcove",
model = "mod_assets/models/wall_lock_A.fbx",
replacesWall = false,
anchorPos = vec(0.02, 1.40, -0.1),
anchorRotation = vec(-70, 90, 0),
targetPos = vec(0,1.4,-0.3),
targetSize = vec(0.5, 0.5, 0.5),
placement = "wall",
onInsertItem = function(self, item)
return ((self:getItemCount() == 0 ) and ( string.find(item.name, "_key")~=nil ))
end,
editorIcon = 8,
}

--- Script Function ---

function checkKey(self)
local alcove = findEntity("KeyAlcove")
if (alcove ~= nil)and(alcove:getItemCount()>0) then
local item for item in alcove:containedItems() do
if item.name == "brass_key" then
-----------------------------------------------------------------

--- My Functions Here --- Key inserted and does the following ---

--- Destroy Items here ---
KeyAlcove:destroy()
spawn("lock_A",2, 9,13,3, "fl1") -- Needed in case they use 2nd Brass Key --
--self:destroy() -- This will Destroy the LOCK REM THIS if you want to ---

item:destroy() -- Destroy the Key --
fake_lever_1:destroy()
Magic_Trap_2:destroy()
Fake_Library_Door_1:destroy()

spawn("lever",2, 9,11,3, "bkd1") -- Spawns level at location replaces, lever_1 --
:addConnector("activate", "dungeon_door_wooden_1", "toggle")
:addConnector("activate", "leverSndSet", "ActivateButtonSound")

-- HudPrints Here and Key lock Sounds and Fx's --

playSound("key_lock")
hudPrint("The Brass Key unlocks the lock to the door.")

-----------------------------------------------------------------
else
hudPrint("Wrong Key")

EDIT: Ohh sorry I almost forgot Credits to ArdTru for the Script and Model.. :)

User avatar
spectre900
Posts: 124
Joined: Fri Sep 14, 2012 1:47 am

Re: Keys in locks. Dungeon Master 2 style.

Post by spectre900 » Fri Apr 04, 2014 7:50 pm

Hmm... just noticed a slight issue with the prison tile set. Any lock placed in a prison dungeon is placed further in, making some keys hang in front of the lock rather than be inside it.

Edit:

I tried to add a lock model to the alcove, but the "height" does not seem to work and the lock is stuck on the ground rather than on the middle of the wall where I want it.
Maybe a different sort of line/text is needed, or does alcove models simply not work that way?

User avatar
Isaac
Posts: 2949
Joined: Fri Mar 02, 2012 10:02 pm

Re: Keys in locks. Dungeon Master 2 style.

Post by Isaac » Fri Apr 04, 2014 8:15 pm

spectre900 wrote:Hmm... just noticed a slight issue with the prison tile set. Any lock placed in a prison dungeon is placed further in, making some keys hang in front of the lock rather than be inside it.

Edit:

I tried to add a lock model to the alcove, but the "height" does not seem to work and the lock is stuck on the ground rather than on the middle of the wall where I want it.
Maybe a different sort of line/text is needed, or does alcove models simply not work that way?
* Height is a property of class "Lock"; what you can do is place a dummy lock (that takes no key) over the alcove, and [optionally] set the alcove's click-able region to match the lock's position; and use the alcove to play the lock sound (over it's own unfortunately).

** A setup like this could also trigger the door to close when you take the key.

User avatar
spectre900
Posts: 124
Joined: Fri Sep 14, 2012 1:47 am

Re: Keys in locks. Dungeon Master 2 style.

Post by spectre900 » Fri Apr 04, 2014 8:22 pm

Isaac wrote: * Height is a property of class "Lock"; what you can do is place a dummy lock (that takes no key) over the alcove, and [optionally] set the alcoves click-able region to match the lock's position; and use the alcove to play the lock sound (over it's own unfortunately).
That's what I do atm. Use locks to get the key-hole model and then add the specific alcove on top, but in the prison wallset the locks are set further into the walls than they are in the temple and dungeon, which causes a mis-alignment.

Guess for now I have to dupe the alcoves and make a set specifically for prison walls. Just clogs up the item lists is all. =/

User avatar
Isaac
Posts: 2949
Joined: Fri Mar 02, 2012 10:02 pm

Re: Keys in locks. Dungeon Master 2 style.

Post by Isaac » Fri Apr 04, 2014 8:24 pm

spectre900 wrote:
Isaac wrote: * Height is a property of class "Lock"; what you can do is place a dummy lock (that takes no key) over the alcove, and [optionally] set the alcoves click-able region to match the lock's position; and use the alcove to play the lock sound (over it's own unfortunately).
That's what I do atm. Use locks to get the key-hole model and then add the specific alcove on top, but in the prison wallset the locks are set further into the walls than they are in the temple and dungeon, which causes a mis-alignment.

Guess for now I have to dupe the alcoves and make a set specifically for prison walls. Just clogs up the item lists is all. =/
It is easy to define a decoration, and use any lock model for it... but you will have to load the lock model into the GMT utility and adjust the height (and depth?) manually; saving the result as a custom model for the alcove.

*Any fake lock alcove should probably return False if there is an object in it.

Post Reply