Override Door activation with code?

Post » Mon Jun 18, 2012 7:33 pm

I have a door that asks the player a question, and based on the answer, either lets them enter, or denies entrance.

But, no matter what, the door always lets them enter. How can I block the default behaviour of doors so it does not just activate when my script is done?

My button returns works, as I get the correct messages based on the decision. It just activates the door every time.

 Scriptname LevelersEntranceDoor extends ObjectReference {Script on entrance door to towers}Message Property MesgQuestionBox1  Auto Message Property MesgOkay  Auto Message Property MesgNo  Auto int Buttonint myStateEVENT onActivate(objectReference akActionRef) If akActionRef == Game.GetPlayer()  if myState == 0   button = MesgQuestionBox1.show()   if Button == 0	myState = 1	MesgOkay.show();	DoorReference.Activate(Game.GetPlayer())   elseif Button == 1	MesgNo.show()   endif  else;   DoorReference.Activate(Game.GetPlayer())   debug.MessageBox("Already Accepted, can now enter")  endif EndIfendEVENT
User avatar
Tiffany Holmes
 
Posts: 3351
Joined: Sun Sep 10, 2006 2:28 am

Post » Mon Jun 18, 2012 7:48 am

you'll need a blockactivation on the door until the right answer is given

http://www.creationkit.com/BlockActivation_-_ObjectReference

i'm not sure how you set the door to start as blocked, but you can use it to replace your mystate variable
User avatar
Averielle Garcia
 
Posts: 3491
Joined: Fri Aug 24, 2007 3:41 pm

Post » Mon Jun 18, 2012 6:41 pm

Thanks! That 'mostly' works, I am just having specialized trouble setting the block the first time.

If the player is in the cell that the tower is in when they activate the mod, the script does not work correctly because the blocking is not activating in the OnLoad event. The OnLoad event will not trigger when you 'load' the game. If I re-enter the cell from another load door, it works correctly.

Scriptname LevelersEntranceDoor extends ObjectReference{Script on entrance door to towers}Message Property MesgQuestionBox1  AutoMessage Property MesgOkay  AutoMessage Property MesgNo  Autoint Buttonint myStateEvent OnLoad()if myState == 0  BlockActivation();  Debug.messagebox("Door loaded as blocked")else  BlockActivation(false);  Debug.messagebox("Door loaded as unblocked")endifendEventEVENT onActivate(objectReference akActionRef)If akActionRef == Game.GetPlayer()  if myState == 0   button = MesgQuestionBox1.show()   if Button == 0	myState = 1	MesgOkay.show()	BlockActivation(false);	Activate(Game.GetPlayer());	Debug.messagebox("Answered yes")   elseif Button == 1	MesgNo.show();	Debug.messagebox("Answered no")   endif  else   BlockActivation(false);   Activate(Game.GetPlayer());   Debug.messagebox("Open, already answered yes")  endifEndIfendEVENT
User avatar
Cedric Pearson
 
Posts: 3487
Joined: Fri Sep 28, 2007 9:39 pm

Post » Mon Jun 18, 2012 7:13 am

This is just off the top of my head, but wouldn't the simplest way of doing it be to just set the door to a locked, 'Key Required' state and unlock it iff the player answers correctly?
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Post » Mon Jun 18, 2012 8:21 am

A locked door can be cheated open with a simple 'unlock' command in the console.
User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm


Return to V - Skyrim