Jump to content

Making a door unlock conditionally


Sealurk

Recommended Posts

Hey everybody, hoping you can help me with a frustrating problem I'm having with the mod I'm currently building. I've been trying for some time now to make this work and after a dozen different attempts I have to admit I'm stumped.

 

Basically what I'm trying to achieve is this: after the player has activated a set number of unique safes within the mod, a door unlocks and opens. The player must be free to open the safes in any order, as many times as they wish and generally do what they like as long as each safe is activated at least once - the player must not be able to open the door by repeatedly opening just one safe. Additionally, this is probably not going to be done in one visit (would defeat the point of the mod, but I won't preclude this possibility either) but rather over the course of the game, or at least a substantial span of time.

 

In fairness, scripting really does not come naturally to me, but I have tried everything I can think of so far. I would guess a quest would be useful, and I've toyed with a global variable. If anybody can offer any kind of help or assistance I would be hugely grateful as I'm otherwise quite happy with how the mod has turned out and I'd hate to have to abandon it because the most critical part doesn't work!

Edited by Sealurk
Link to comment
Share on other sites

Either a quest variable or a global variable would work. You can put something like the example below in the object script for your safe. It assumes you have a global called MySafeCount (initialized to 0) and the number of safes that must be opened to unlock the door is 5.

SHORT DoOnce

BEGIN OnOpen

  if MySafeCount < 5
    if DoOnce == 0
      set DoOnce to 1
      set MySafeCount to MySafeCount + 1
      if MySafeCount >= 5
        MyDoorREF.unlock
      endif
    endif
  endif

END

One caveat: the OnOpen block will only run if the safe NIF has an "open" animation. The vanilla safe NIFs do, so unless you're using a custom NIF with no "open" animation it should work. To get around that you could use OnActivate instead of OnOpen, but then the door would unlock after you activate five unique safes, even if you fail the lockpick attempt on all five, which probably isn't what you want.

Link to comment
Share on other sites

Your script worked beautifully, so the most crucial part is finally sorted. Many thanks! Now I just have to fix the rest of the mod, but that's fairly easy in comparison.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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