How to script a switch so the player cannot use it?

Post » Wed Jun 20, 2012 10:39 am

I have a switch and I would like for just one specific NPC to be able to activate it. Not the player, not any followers, nobody else. Just the one NPC. I tried using an 'OnActivate' block, then seeing if the akActionRef was the NPC, but the result was that after the switch was hit the first time, it activated itself constantly and never stopped.

I gave up, and since have been wondering how to do this. Aparantly my old methods of scripting (From Fallout) wont work here. I figure it should be simple... How would I do this?

Thanks,
Alexander J. Velicky
User avatar
Emmi Coolahan
 
Posts: 3335
Joined: Wed Jan 24, 2007 9:14 pm

Post » Wed Jun 20, 2012 5:24 am

From the wiki's documentation of http://www.creationkit.com/BlockActivation_-_ObjectReference:
Because of the way script events work, chances are that the object has already done (or ignored) its default activation processing by the time the script receives the event, so calling BlockActivation() on the object in the OnActivate block will not affect the current activation.

Something like this, however, may do the trick:
ScriptName NoPlayerActivation extends ObjectReferenceEvent OnInit()	BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)	If (akActionRef != Game.GetPlayer())		Activate(akActionRef, true)	EndIfEndEvent

Cipscis
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Wed Jun 20, 2012 4:20 am

Well... you are supposed to use an 'OnActivate' block. You must have scripted it incorrectly and led to an infinite loop.

Don't know how it is in FallOut, but in Oblivion, if an object had an 'OnActivate' block in its script, then it was impossible to activate it normally. You had to add in an 'Activate' inside the 'OnActivate' block.

If that is what you did, then I hate to disappoint you but in Skyrim, having an 'OnActivate' block does not prevent normal activation. Which may lead to that infinite loop if you were under the impression that you needed to script in 'Activate' somewhere ('Activate' keeps triggering 'OnActivate' which keeps using 'Activate', etc).

You might want to look at http://www.creationkit.com/BlockActivation_-_ObjectReference if you really want to prevent normal activation.
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Post » Wed Jun 20, 2012 2:54 am

Would that cause an endless loop, I wonder? It sounds like that is what happened the first time: activating an object via script would trigger the OnActivate block again, and again, and again. So you may need to use a variable or a state to ensure that it only happens once.

Edit: ninja'd--I was replying to Cipscis.
User avatar
Anna Krzyzanowska
 
Posts: 3330
Joined: Thu Aug 03, 2006 3:08 am


Return to V - Skyrim