lolove12345 Posted August 26, 2021 Share Posted August 26, 2021 (edited) Is there a way to get an NPC to activate an Activator switch in order for a door to open for them. As a workaround I made an activator that's only usable for NPCs, and two activator switches that the Player can use. ** For context it's for a hidden door to a bunker. Patrols with regurarly enter and leave the facilities so I was wondering if I could make them hit a switch in order for them to get out. Scriptname MRRAutoClosingDoor ref rHiddenDoor short bOpenSesame ; Open and Close float fDoorCloseTimer ; For the Trigger float fDoorCloseTimerForSwitch ; For the Switches Begin Gamemode set rHiddenDoor to getlinkedref if bOpenSesame == 0 && rHiddenDoor.GetOpenState != 3 && fDoorCloseTimerForSwitch < 5 set fDoorCloseTimerForSwitch to fDoorCloseTimerForSwitch + getsecondspassed elseif bOpenSesame == 0 && rHiddenDoor.GetOpenState != 3 && fDoorCloseTimerForSwitch >= 5 rHiddenDoor.setopenstate 0 set fDoorCloseTimerForSwitch to 0 endif if bOpenSesame == 1 if fDoorCloseTimer > 0 set fDoorCloseTimer to fDoorCloseTimer - getsecondspassed elseif rHiddenDoor.GetOpenState != 3 rHiddenDoor.setopenstate 0 set bOpenSesame to 0 endif endif end Begin ontriggerenter if isActionRef Player == 0 if rHiddenDoor.getopenstate == 3 ;Closed rHiddendoor.setopenstate 1 ; 1 = Open set bOpenSesame to 1 set fDoorCloseTimer to 5 endif endif end Edited August 26, 2021 by lolove12345 Link to comment Share on other sites More sharing options...
Radioactivelad Posted September 2, 2021 Share Posted September 2, 2021 (edited) Is this a load door or a regular door? Either way I would just have a trigger box with an OnTriggerEnter near the door that transports them in to the bunker (if a load door), or have the trigger box activate the door (if a regular door). You can use a formlist to identify multiple actors with these privileges with only one begin block. Alternatively, and if you *have* to have the NPC tangibly use a switch, you could probably do this with zero scripts at all by giving them a Find or Use Item package targeting the switch, scheduled for when their Patrol package is no longer valid, then when *that* is completed, have an ai package direct them inside the bunker. Edited September 2, 2021 by Radioactivelad Link to comment Share on other sites More sharing options...
Mktavish Posted September 9, 2021 Share Posted September 9, 2021 That's some good scripting you have there . So the npc is going in the bunker fine ... but you just don't know how to get them out ? Which actually I think you could have just put a patrol point in the bunker ... and the npcs would use the door just fine as long as both sides have a finalized navmesh. But hey don't let me dissuade you from exploring nitty gritty scripting options ... you will definitely find more uses for that down the road . And the lazy side of scripting would be to just use an Area Trigger ... scripted to " MyPatrolRef.MoveTo OutsideMarker " Like Radioactivelad said . Link to comment Share on other sites More sharing options...
Recommended Posts