Jump to content

There is no way an NPC can unlock doors.


antstubell

Recommended Posts

I based/copied, the Lock/Unlock door on Belethur of Whiterun.

Setup interior cell (shop), 1 NPC = Job Vendor, Town X Faction. Packages Sleeps in building 12am – 9am, Sells 9am-9pm and goes for a drink at Inn 9pm-12am. As with Bele’s shop interior cell door is Locked at whatever level you wish and requires a Key which I made and placed in NPC X’s Inventory, same as Bele. Bele works in his shop 8am-8pm then goes on a Patrol around Whiterun for 4hrs, you can see him do this in game, just walks in circles before sleeping somewhere. So Bele has 3 Packages but the only one of interest is when he is in his shop and that Package is “SandboxAndKeepEyeOn” which effectively makes NPC X stay in one place by using the LinkedRef in the Package which I attached to a CounterLeanMarker (same as Bele) and wherever player goes in the cell (shop) NPC X will follow if player is out of Line Of Sight, you can watch Bele do this in his shop.

Door is Novice Locked and Requires Key. At 9am I approach door and it is locked. 9:10, 9:20 still locked. I pick the lock and get the normal “You shouldn’t be in here” response. No joy. Further investigation on Bele’s shop/cell shows as well as the LockList Bele is the owner of the cell/shop and by double-clicking on him in the render window his LocationRefType is “Boss”. I do the same for NPC X. No joy “Get out”. I unlock the door leaving NPC X as Boss and Owner, same “You shouldn’t….” even though I haven’t picked the lock. Remove NPC X as cell/shop owner this solves the “get out” response to my entrance but still when door is locked NPC X never unlocks it when package starts and the option “UnlockOnArrival” is TRUE. I decide to make NPC X sleep somewhere else hoping that the “Arrival” to the shop will unlock the door. NPC X arrives and enters shop I go to shop door and it’s still locked. Another attempt – Door is unlocked NPC is not Owner of shop, sleeps elsewhere and the only connection NPC X has to shop is the Package that connects it and the LockList which NPC X is the only member, same as Bele is the only member of his shop’s LockList. I enter shop through unlocked door and am told “Get out”. I remove LockList and I can enter through unlocked door.

 

Conclusions- If you make a LockList with NPC X and whoever else in it you will be told “Get Out”

If NPC X is owner of shop/cell result is “Get Out”

Makes no difference whether NPC X lives in cell or arrives at cell, door will remain locked.

LocationRefType setting has no affect on door.

Package type, tried “Sandbox, SandboxAndWorking, Sit, SandboxAndKeepEyeOn” all with Unlock on arrival as TRUE has no affect on door’s lock status.

 

If anybody has any other ideas what I can try then please let me know. Until then NPC X’s shop is ripe for plunder when NPC X is not there or asleep or is only accessible by picking the lock or having the key.

Link to comment
Share on other sites

You can attach a script to the door that verifies if the given actor is in the given cell, and lock it based on this. Like this:

 

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that leads to the outside.}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)
EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

 

Didn't compile it so I don't know if it works, that's just some code I wrote in five minutes :D

Link to comment
Share on other sites

You can attach a script to the door that verifies if the given actor is in the given cell, and lock it based on this. Like this:

 

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that leads to the outside.}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)
EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

 

Didn't compile it so I don't know if it works, that's just some code I wrote in five minutes :D

The script compiles perfectly but still door is locked after actor arrives. The line "ObjectReference Property OutsideDoor Auto{The linked door that leads to the outside.}" when you say leads to the outside I assumed you meant the inside door which does lead to the outside. I couldn't select this in the render window, recticle wouldn't highlight that door but it did select the outside door which is what I used.

Link to comment
Share on other sites

1 - The door must be locked in the CK

2 - Script goes in the reference of the inside door

3 - OutsideDoor is the door reference which links to the interior FROM the outside

 

Also, Update the code:

 

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that leads to the outside.}

FLOAT Property TimeToLock Auto
{Lock the door at}
FLOAT Property TimeToUnlock Auto
{Unlock at}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)
EndIf

If GetHourOfDay() >= TimeToUnlock && GetHourOfDay() <= TimeToLock
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

FLOAT Function GetHourOfDay()
FLOAT Time = Utility.GetCurrentGameTime()
Time = Time - Math.Floor(Time)
Time = Time * 24

Return Time
EndFunction

 

See if it works and tell me after (I'm too lazy to open the CK right nowhttp://forums.nexusmods.com/public/style_emoticons/dark/biggrin.gif)

Link to comment
Share on other sites

1 - The door must be locked in the CK

2 - Script goes in the reference of the inside door

3 - OutsideDoor is the door reference which links to the interior FROM the outside

 

Also, Update the code:

 

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that leads to the outside.}

FLOAT Property TimeToLock Auto
{Lock the door at}
FLOAT Property TimeToUnlock Auto
{Unlock at}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)
EndIf

If GetHourOfDay() >= TimeToUnlock && GetHourOfDay() <= TimeToLock
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

FLOAT Function GetHourOfDay()
FLOAT Time = Utility.GetCurrentGameTime()
Time = Time - Math.Floor(Time)
Time = Time * 24

Return Time
EndFunction

 

See if it works and tell me after (I'm too lazy to open the CK right nowhttp://forums.nexusmods.com/public/style_emoticons/dark/biggrin.gif)

 

Nice piece of script but doesn't work. I followed NPC from her sleep cell (ideally she is going to sleep in her shop the same cell so how that will work with door locking I don't know), takes her around 28 mins to get to her shop, she enters but when I try door is locked.

Link to comment
Share on other sites

Oh, damn, I forgot to include a "if they are in the cell, unlock" condition.

 

Here's the updated code:

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that links from the outside.}

FLOAT Property TimeToLock Auto
{Lock the door at}
FLOAT Property TimeToUnlock Auto
{Unlock at}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf

If GetHourOfDay() >= TimeToUnlock && GetHourOfDay() <= TimeToLock
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

FLOAT Function GetHourOfDay()
FLOAT Time = Utility.GetCurrentGameTime()
Time = Time - Math.Floor(Time)
Time = Time * 24

Return Time
EndFunction

 

Hope it works now.

 

Also I don't know of only one side of the door would be unlocked (due to how the game engine works). If you try to enter the cell and the door is locked, try using COC to enter the cell and see if the door is unlocked from the inside.

Link to comment
Share on other sites

Oh, damn, I forgot to include a "if they are in the cell, unlock" condition.

 

Here's the updated code:

ScriptName AutoLockDoorWhenActorIsNotHere Extends ObjectReference
{Must be linked to the door that is INSIDE the cell}

Actor Property DoorOwner Auto
{The actor that we want to check for presence in the cell.}
ObjectReference Property OutsideDoor Auto
{The linked door that links from the outside.}

FLOAT Property TimeToLock Auto
{Lock the door at}
FLOAT Property TimeToUnlock Auto
{Unlock at}

Event OnLoad()
RegisterForUpdate(10)
EndEvent

Event OnUpdate()
If GetParentCell() != DoorOwner.GetParentCell()
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf

If GetHourOfDay() >= TimeToUnlock && GetHourOfDay() <= TimeToLock
Lock(TRUE, TRUE)

Else
Lock(FALSE, TRUE)

EndIf
EndEvent

Event OnUnload()
UnRegisterForUpdate()
EndEvent

FLOAT Function GetHourOfDay()
FLOAT Time = Utility.GetCurrentGameTime()
Time = Time - Math.Floor(Time)
Time = Time * 24

Return Time
EndFunction

 

Hope it works now.

 

Also I don't know of only one side of the door would be unlocked (due to how the game engine works). If you try to enter the cell and the door is locked, try using COC to enter the cell and see if the door is unlocked from the inside.

 

The doors don't lock/unlock, both doors, I coc-ed inside and the inside door was locked at the UNLOCK time and NPC was in the cell.

Link to comment
Share on other sites

Well, I'm confused then. I do not know anything about AI, I'm a scripter but, as far as I know, it should work fine. I'll take the code home and meditate a little on it. Now it's a matter of honour, I must find what's wrong http://forums.nexusmods.com/public/style_emoticons/dark/wallbash.gif
Link to comment
Share on other sites

  • Recently Browsing   0 members

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