Game Development Community

Linking Key Item To A Locked Door

by Peter Churness · in Game Mechanics Kit · 08/16/2009 (7:07 pm) · 6 replies

I was having an issue linking a key to a locked door and thought I may have missed something in the merge process, but discovered the issue is in the demo as well. Here's what's happening:

First, you'll see in this screenshot that the GarageDoorLocker01 object has the BlueKeyItemData set as the key to unlock.
www.therebelplanet.com/images/posts/keyitemdatablock.jpg
But then if I hit the '...' button to select a key for this door I get the list of available keys:
www.therebelplanet.com/images/posts/selectkeyfordoor.jpg
But then when I select the blue key from the list, it sets the key object, not the datablock:
www.therebelplanet.com/images/posts/item_not_datablock.jpg
Thus it no longer works - can't find the blue key because its looking for a datablock, but the editor assigns the object not the datablock when selecting.

Am I doing something wrong?


#1
08/17/2009 (12:16 am)
I had the same problem. I had to manually edit the mission file to match the key datablock.
#2
08/17/2009 (8:41 am)
@Peter and Kerry
Thanks for that.
I will check it.
#3
08/20/2009 (5:03 pm)
Thanks Yuri

Any progress?
#4
08/21/2009 (8:46 am)
@Peter
>Any progress?

Yes, I've checked it. The problem is in current inventory system. It stores not the items objects, but only names of their datablocks and count. So it's wrong to refer to actual objects since they destroyed immediately after being put in the inventory.

The solution is very easy, in file serverlogickingMechanicsopenable.cs replace
setTemplateField("AbstractOpenable", "keyToUnlock", "", "objectLink", "Misc", "", "Item");
to
setTemplateField("AbstractOpenable", "keyToUnlock", "", "", "Misc", "", "Item");

The will be only string input for datablock name, not so elegant as objectLink reference to the object, but it's impossible with current inventory.


P.S. I've added this change to 1.2.3 version
#5
08/21/2009 (12:04 pm)
Thanks Yuri. That works.

But would be nice to still be able to just click the key and get the datablock name populating the field. I found in the code where it seems you could add some logic for it. Here's my work around in tools/logickingEditor/scripts/objectsList.ed.cs:

function LogickingEditorObjectsList::selectButtonOnPush(%this)
{
   if (%this.selectedObject.class $= "InventoryItem") {
   	%this.caller.selectObject(%this.selectedObject.getDatablock());
   } else {
   	%this.caller.selectObject(%this.selectedObject);
   }

	// add a little pause to give engine time to close the windown correctly when double click selection appears
	%this.setActive(false);
	LogickingEditor.schedule(100, "toggleWindow", LogickingEditorObjectsList);
	EWorldEditor.clearHighlighting();
}

I just tested it and it works. However, I don't know if it will have any unforseen consequences in other parts of the GMK functionality. Can you tell me if this fix will work?

Thanks - and GREAT product by the way...

Peter
#6
08/24/2009 (3:04 pm)
Peter,

it will work, however other object's templates can also use "objectLink" property for reasons of selecting actual object not datablock. Probably it will be right thing to modify "objectLink" and add "datablockLink" or something. I will think about it.