Jump to content

CK question. (Npc lock/unlock doors)


Recommended Posts

I’m building a tavern and I want a guard at the door to unlock/lock the door. Similar to how the Riften guard unlocks the door the first time you go to Riften. So basically I have the quest set up so the player pays the entree fee via dialogue but can’t for the life of me figure how to then make the guard unlock the door. 
 

maybe someone could give me a different idea??? I really just want an entree fee paid before you enter the establishment. 

Link to comment
1 hour ago, dooders said:

I want a guard at the door to unlock/lock the door

Look at the Riften scene and see how Bethesda did it.

 

Will need a quest, alias for the doorman, dialogue for the doorman, and the lock/unlock would be done by script fragment in either the dialogue itself or by setting stage on the quest from dialogue (fragment to setstage on the quest) which then triggers the unlock itself or the guard to activate an AI package that does this on reaching goal.

 

The Riften guard uses a forcegreet routine to do this, so look up forcegreet dialogue triggered by distance to the doorman or the door (or a trigger volume near both).

Link to comment
1 hour ago, Seijin8 said:

Look at the Riften scene and see how Bethesda did it.

 

Will need a quest, alias for the doorman, dialogue for the doorman, and the lock/unlock would be done by script fragment in either the dialogue itself or by setting stage on the quest from dialogue (fragment to setstage on the quest) which then triggers the unlock itself or the guard to activate an AI package that does this on reaching goal.

 

The Riften guard uses a forcegreet routine to do this, so look up forcegreet dialogue triggered by distance to the doorman or the door (or a trigger volume near both).

I didn’t want to keep bothering you with my non stop questions but thank you once again. I have the forcegreet and dialogue all set up. So if I put the script in the dialogue itself, how do I get him to lock the door again when the player leaves? I guess if it’s a forcegreet that happens every time the player comes near 
 

I could add another set of dialogue that says thanks for visiting or something like that and add the locking script to that dialogue branch? Would that even work? Or would I have to set it up kind of like renting a bed for 24 hours. You would rent the establishment for 24 hours? 

Link to comment
31 minutes ago, dooders said:

I didn’t want to keep bothering you with my non stop questions but thank you once again. I have the forcegreet and dialogue all set up. So if I put the script in the dialogue itself, how do I get him to lock the door again when the player leaves? 

Lots of potential ways, though which is best for you will depend on anything else you want this to do.

 

1) If the locked door goes to a new cell or new location, then a simple spell script on the player could check for area transitions and upon finding the player has left the cell/location, just locks the door automatically.

 

2) If the idea is to lock the door after a certain amount of time has passed, that is easy to do with a scripted update loop on a quest script or spell effect attached to the player.

 

3) The same trigger volume mentioned previously could do this as well, though you'd have to be careful that it was placed in a way and scripted in a way to note when the player was coming/going.

 

4) Not recommended, but just to show options, you could also RegisterForLOSGain from the player to the doorman, or create a package on the doorman that knows you are leaving and locks after you go (might do this by having a sequential AI package with fragments to do each piece or by using the quest stages to handle this.

 

I really don't know which (if any) of these would work best for your situation.

Link to comment

1) is probably the route I will go. Seems like the best way to achieve what I’m looking for. 
 

2) seems like a good way to do an idea I had with servers forcegreeting after a certain Amount of time spent in the tavern. 
 

I currently have random NPCs teleporting into the tavern entrance hall. Will the door being locked effect that? They are teleporting in and not having to deal with the door so they shouldn’t have an issue??

Link to comment

If it's supposed to be locked again after single uses, why not just attach a script to the door, listen to OnActivate and then call Lock?

Event OnActivate(ObjectReference akActionRef)
    if !IsLocked() && akActionRef == PlayerRef
        RegisterForSingleUpdate(3.0)
    endif
EndEvent

Event OnUpdate()
    Lock()
EndEvent

You could also prevent using AI packages and/or quest stages by simply doing:

Function Fragment_0(ObjectReference akSpeakerRef)
    Door.Lock(false)
EndFunction

And attach this fragment to the dialogue response that is supposed to unlock the door, with "Door" being a property referencing the door's ObjectReference object.

Link to comment
10 hours ago, Hawk9969 said:

If it's supposed to be locked again after single uses, why not just attach a script to the door, listen to OnActivate and then call Lock?


Event OnActivate(ObjectReference akActionRef)
    if !IsLocked() && akActionRef == PlayerRef
        RegisterForSingleUpdate(3.0)
    endif
EndEvent

Event OnUpdate()
    Lock()
EndEvent

You could also prevent using AI packages and/or quest stages by simply doing:


Function Fragment_0(ObjectReference akSpeakerRef)
    Door.Lock(false)
EndFunction

And attach this fragment to the dialogue response that is supposed to unlock the door, with "Door" being a property referencing the door's ObjectReference object.

Thank you for this. Script examples are a huge help right now as I’m still in the early stages of learning papyrus. I have some background in python. I will definitely try this and see if it gets my closer to my goal. I also found a trigger event example that I will be exploring. Thank you both for your help with this. Took me 2 days just to get my teleport script fragment to work. Almost did a back flip when I got it right finally. 

Link to comment

Why are you teleporting them in? NPCs with an AI package telling them to use a transition door don't check for the door's lock status. You can clearly see this behavior from NPCs entering Whiterun even while it's still locked; or you can open the console, click a public unlocked door (such as that of an inn) and type "lock".

Link to comment
14 hours ago, Hawk9969 said:

Why are you teleporting them in? NPCs with an AI package telling them to use a transition door don't check for the door's lock status. You can clearly see this behavior from NPCs entering Whiterun even while it's still locked; or you can open the console, click a public unlocked door (such as that of an inn) and type "lock".

It was originally just to test to see if the quest was working. I decided to keep it since the NPCs are random, and I didn’t want to wait for them to walk all the way from where ever the alias was being filled from. So the AI package starts and they teleport in. The AI package ends and they teleport out. I might make it so it doesn’t run unless the player is in the cell. That way Main game quests are not effected. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use