Jump to content

Stupid Locking of a door


Floatsup

Recommended Posts

I have a perticular door in my layout that has access to an Amory. I want to keep this locked unless the player has the key. I ve tried putting automatic close door scripts on it. Setup every single NPC, to lock door, at start, middle and end of thier apponted sandbox. Nothing works exactly right though.

 

Basically what happens is change of shift, if the player is in the same cell with the door. It stays open. NPC's wont go over to the dm thing and lockit, and the script won't shut it. Probable because of the way im checking to see if its open.

 

scn FLGENAutoClosingDoorArmory

float doorTimerArmory
short closeDoorArmory

Begin GameMode
if closeDoorArmory == 1
	if doorTimer > 0
  set doorTimerArmory to doorTimerArmory - getSecondsPassed
	elseif GetOpenState == 1 ; if the door is still open
		SetOpenState 0 ; close the door
		set closeDoor to 0
	endif
endif
End

Begin OnActivate
if GetOpenState == 3 ; if the door is closed
		set doorTimerArmory to 5
		set closeDoorArmory to 1
		endif
Activate
End

 

Thats all it is, I know the code works, because if i have the key, it works like a regular automatic door. So I was thinking of putting a new variable in to see if the player is in the same cell, and if true then shut, but what do you use a || double pipe char for this?

Anyway still scratching my head, and if anyone has worked with npc's to lock a door I would love to know what you did. Is there an idle marker or something you can use?

 

Cheers

Edited by Floatsup
Link to comment
Share on other sites

why must the npc lock the door?

 

is it acceptable to you for the door to automatically unlock when you approach it based on whether or not you have that key and then automatically lock when you walk away?

 

if so make a cubic activator (its the cube with the "T" on the menu bar in geck) and apply the attached script to it

 

your door must be persistent, with the activator placed in world double click the activator to edit the reference then use right arrow at the top to navigate to linked reference.

hit the button that lets you select the reference in the window and select your door. the reticle will change colors when its over the door so you know its lined up so double click it to select it.

 

it should now say your door is the linked ref so click ok and position the activator around the door and armory.

 

when the player enters this activator box the door will unlock if they have your key

when the player leaves this box the door will automatically close and once its closed itlll automatically lock to a must have key state again.

 

so the idea with the activator positioning is to have the armory in there completely so the door stays unlocked while your in there, but to have it go beyond the door on the outside of the armory so your all the way out of the way of the door before it starts to close behind you. also by having it go a little past the door that means when you enter the edge of the activator to enter the armory the enterblock commands fire to open it up.

 

 

SCN AAAautodoorSCRIPT

int specialactivate
ref MyLinkedDoor

Begin OnTriggerEnter Player ; when the player enters the activator box the door unlocks
set MyLinkedDoor to GetLinkedRef
if player.getitemcount THENAMEOFTHEKEYTOTHISDOOR >= 1
	MyLinkedDoor.unlock
;		MyLinkedDoor.setOpenState 1 ; to have the door open automatically instead remove the semicolon at the beginning of this line
endif
END

Begin OnTriggerLeave Player ; When the player leaves the activator close the door and tell the gamemode block to lock it once its closed
MyLinkedDoor.setOpenState 0
set specialactivate to 1
END


Begin Gamemode ; if the door is closed and set to lock, lock it and stop waiting to lock it
if ( specialactivate == 1 ) && ( MyLinkedDoor.GetOpenState == 3 )
	MyLinkedDoor.lock 120
	set specialactivate to 0
endif
END

 

Note* you will need to make 1 change to this script to get it to work, replace "THENAMEOFTHEKEYTOTHISDOOR" with the ObjectID name of the key you want to control it.

Edited by angelwraith
Link to comment
Share on other sites

Yeah I'll take a look at your script, but the entire thing is I DONT WANT the player to have access to the door. Unless he has faction, then he will be granted the key. Right now the key is in a desk, but this is all going to change. Very soon. Starting the locking up tight of my mod and starting to make it into a working factory at this point. Where the player can either work with us a bit, gain a little faction, fame, and fortune. Or we can eat him. All depends.

 

I'm just kidding about the eating part though. I shoot most ghouls on site, but does open up possiblities. LOL, I love modding.

Link to comment
Share on other sites

ok well the script provided will keep the door locked unless the player enters that activator and has the key in possession.

 

if you want however for the door to lock ONLY for the player use the following script. and make that activator box large enough around the door to where they dont have enough time to get to it before the closing animation in done.

 

what it does:

locks the door ONLY when the player enters the activator box without the key.

opens the door when they leave the activator box so everyone else can get through again.

 

 

SCN AAAautoDoorLockOnPlayerEnterSCRIPT

int specialactivate
ref MyLinkedDoor

Begin OnTriggerEnter Player ; When the player enters the activator close the door and tell the gamemode block to lock it once its closed
set MyLinkedDoor to GetLinkedRef
if player.getitemcount THENAMEOFTHEKEYTOTHISDOOR == 0
MyLinkedDoor.setOpenState 0
set specialactivate to 1
endif
END

Begin OnTriggerLeave Player ; when the player leaves the activator box the door unlocks
MyLinkedDoor.unlock
;	MyLinkedDoor.setOpenState 1 ; to have the door open automatically instead remove the semicolon at the beginning of this line
END

Begin Gamemode ; if the door is closed and set to lock, lock it and stop waiting to lock it
if ( specialactivate == 1 ) && ( MyLinkedDoor.GetOpenState == 3 )
	MyLinkedDoor.lock 120
	set specialactivate to 0
endif
END

 

Note* in this script as well, you will need to make 1 change to get it to work, replace "THENAMEOFTHEKEYTOTHISDOOR" with the ObjectID name of the key you want to control it.

Edited by angelwraith
Link to comment
Share on other sites

I'll set it up in about 20 mins, thanks for the response. It's been driving me nuts. 90% of the time it is locked, but if you catch the gaurds on shift change, it just remains open. If you leave the area, for lets say 10 mins, and come back to the room. The door is shut and locked. But while your in the cell, the door would never shut, and the NPC's would never lock the door. So I appreciate it. Know it sounds trivial, but I'm working through some little things now, while mind hurts from generating quests. owwie owwie. :wallbash:
Link to comment
Share on other sites

Angel,

 

Thank you very much. Worked like a champ. Never used that tool before. Now that is a handy thing. Really appreciate it, and kudo's to you my man.

 

I was pulling my hair out, one strains at time over this trivial thing too.

 

Ok back to get some more done before wife comes home, and gets on my case about the closet thing. lol

 

Cheers

Link to comment
Share on other sites

  • Recently Browsing   0 members

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