Page 1 of 1

Requires a Key to Open a Door

PostPosted: Wed Jun 30, 2010 6:05 am
by MSam
Hey all,

I'm working on a semi-puzzle adventure mod (that should go for about 5 minutes). The idea is you can travel between Morrowind and Oblivion time Ald-ruhn to get some goodies (Ebony Dagger, Daedric Pants, random provocative red gown).

The script I'm having trouble with is enforcing the mandatory rule where you need to have a key to open the door. I don't want those pesky and glorious 'Scrolls of Ekash's Lock Splitter' ruining the puzzle fun. I usually find scripts ingame or in other mods and modify them to suit my problem, but I can't find them in this case. :saddy:

So, would someone be able to whip up a (what I assume is basic?) script where you must have a key in your inventory or the door will not open? I *could* make it so when you pick the key up you get a journal entry and then the door automatically opens, but I was hoping to avoid journals in this. Anyone that helps can have the mod dedicated to them, in loving memory. Like, a living memory. Woohoo!

Thanks in advance,
Sam

Re: Requires a Key to Open a Door

PostPosted: Wed Jun 30, 2010 6:16 am
by Melchior Dahrk
Check the scripted desk in Solstheim. That priest who is hiding all the booze in Fort Frostmoth... I believe that'll have a script similar to what you want. I don't script very well, I do what you do!

Re: Requires a Key to Open a Door

PostPosted: Wed Jun 30, 2010 6:41 am
by Kiteflyer61
I can't remember the exact script I wrote, but there is a script that does what you want in my Alladin's Bottle mod. It's used on the chest that you get the bottle from, but could be adjusted to work on a door the same way. It's a pretty simple script.


KF

Re: Requires a Key to Open a Door

PostPosted: Wed Jun 30, 2010 7:10 am
by Jac
Try this:

Code: Select all
Begin door_script

if ( OnActivate == 1 )
   if ( Player->GetItemCount "key_id" < 1 )
     MessageBox "This door will not open without the proper key."
     return
   else
      Activate
  endif
endif

End

Re: Requires a Key to Open a Door

PostPosted: Wed Jun 30, 2010 7:18 am
by MSam
Aww thanks guys! Joint dedication to you all!

Re: Requires a Key to Open a Door

PostPosted: Thu Jul 01, 2010 2:12 am
by MSam
Oh my Morrowind world has been rekindled!

Next question...is it possible that when you activate an NPC, you get redirected to a creature? So, I talk to a Dark Elf, but I get redirected to an invisible creature elsewhere? I swear there was a mod that did that but it's apparently gone since it was from '05 Morrowind Summit...

Re: Requires a Key to Open a Door

PostPosted: Thu Jul 01, 2010 3:21 am
by Fliggerty
Yes, though there is a bit of a trick to it IIRC.  Essentially you have something like this on the NPC:

Code: Select all
if ( OnActivate == 1 )
    Activate "creature"
endif


But I think there's more to it...it's been a while since I've done that.  Take a look at the script on the book I made in Visceral Discernment, that opens dialogue with an invisible person when you activate it.

Re: Requires a Key to Open a Door

PostPosted: Thu Jul 01, 2010 3:47 am
by MSam
Mmm I had tried that already. I will look into the VD scrip though, thanks!

Re: Requires a Key to Open a Door

PostPosted: Thu Jul 01, 2010 3:56 am
by MSam
Hmm, well I took a look at it in the CS and it looks monsterous.  :sheo:

So it looks like you had an NPC that is enabled and placed next to the player when the book is activated...then another script forces a greeting with the NPC. Going from this...

Code: Select all
begin ik_book_npc_script

short counter
short nolore

if ( menumode )
       return
endif

if ( GetDisabled == 1 )
       set counter to ( counter + 1 )
       if ( counter == 5 )
               SetDelete, 1
               set counter to 0
       endif
endif

if ( GetDistance player <= 200 )
       if ( GetDisabled == 0 )
               ForceGreeting
               Disable
       endif
endif

end

Re: Requires a Key to Open a Door

PostPosted: Thu Jul 01, 2010 8:17 am
by Jac
I'm not sure, but I don't think creatures can use forcegreeting, you may have to use an invisible NPC. But if you skip the activation of the NPC, place the new one and have that one talk to the player it should work:

Code: Select all
if ( OnActivate == 1 )
  PlaceATPC "<new npc id>" 0 0 0
  <npc_id>->ForceGreeting
  return
endif


Just make sure you get rid of the new NPC after it's no longer needed. Fligg's script will work, just take out the ForceGreeting so the NPC doesn't try to talk to the player twice.

Re: Requires a Key to Open a Door

PostPosted: Sat Jul 03, 2010 4:56 pm
by MSam
Hmm the only thing is I want them to be re-directed to a creature so when you trade you get the exact value of your money. I will take a look into working on this more when I get back - but thanks for all your help so far. I always really appreciate when veterans come to the aid of my scripting noobness.