Help w Papyrus: Key Eating Doors

Post » Mon Jan 27, 2014 5:28 am

I've been to a few forums and nobody has been able to help me so far...

Basically I want to code some of my locked doors to check if i have the proper key, unlock like normal, remove a single copy of the key from the player's inventory, and display a message saying something like "The old rusty key snapped in the lock" The player would then have to click an OK in a prompt and they would be on their way. This way I could distribute any number of copies of "Old Rusty Key" and not have any one key tied to any one door within a single dungeon just like ye olde zelda games.

I don't want to make a whole bunch of unique keys (old rusty blah 01, old rusty blah 02, etc) it plays tediously and then you have to collect specific keys for each specific door. It would clutter the inventory and it would feel less like a puzzle and more like pulling teeth. Especially if you missed one at the start and have to backtrack.

Truth be told I'm rather new to the Creation Kit and this is my first dungeon. I'm not really code savey, but I do feel this is an important feature my dungeon will require.

Would anyone care to grant me their aid?

User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm

Post » Mon Jan 27, 2014 2:04 am

Perhaps something like this would work:

Spoiler

Message Property kMessage AutoMiscObject Property kKey AutoEvent OnInit()	Lock()	SetLockLevel(255)?	BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)	If(akActionRef.GetItemCount(kKey) > 0)		kMessage.Show()		Lock(False)		akActionRef.RemoveItem(kKey, 1, True) ;Set True to False if you want to display the message notifying the player of one key being removed.		BlockActivation(False)	EndIfEndEvent 
User avatar
BRAD MONTGOMERY
 
Posts: 3354
Joined: Mon Nov 19, 2007 10:43 pm

Post » Sun Jan 26, 2014 7:16 pm

I like this idea.

I think you can get away with creating just one rusty key object. On all the door references that you want locked, double click on them in the world, go to the "lock" tab, select your key, and make it require the key to open.

Then, on each door reference, attach this script:

Scriptname LockDoorsScript extends ObjectReferenceBool OpenedKey RustyKeyActor PlayerEvent OnInit(){Set permanent variables.}	RustyKey = GetKey()	Player = Game.GetPlayer()EndEventEvent OnActivate(ObjectReference akActivator){Check for keys.}	If Opened == False && Player.GetItemCount(RustyKey) >= 1		Lock(False)		Player.RemoveItem(RustyKey, 1)		Debug.Notification("The rusty key snapped in the lock.")		Opened = True	EndIfEndEventEvent OnCellAttach(){If the door reset after we opened it, re-unlock it}	If Opened == True && IsLocked()		Lock(False)	EndIfEndEvent
User avatar
Courtney Foren
 
Posts: 3418
Joined: Sun Mar 11, 2007 6:49 am


Return to V - Skyrim