Jump to content
New Forum Update ×

OnActivate() for locked doors ?

Recommended Posts

Hello, another day, another problem.


I have a simple script where I detect what to do for locked objects, depending if they are terminal or door/container. Of course, I found a problem instantly, OnActivate() doesn't fire on locked doors until they are unlocked and actually opened.


I fill reference alias with the terminal/door/container and that part works. I fill it when player commands companion to hack/lockpick objects.


But then I have script in the alias(that I filled earlier with terminal/door/container) that says:

Event OnActivate(ObjectReference akActionRef)
	Actor myCompanion = CompanionAlias.GetReference() as Actor
	ObjectReference cTarget = Self.GetReference() as ObjectReference
	if(akActionRef == myCompanion && cTarget.GetBaseObject() is Terminal)
                 Debug.Notification("We touched terminal")
		;this part works for locked terminals

	elseif(akActionRef == myCompanion && (cTarget.GetBaseObject() is Door || cTarget.GetBaseObject() is Container))
                 Debug.Notification("We touched door/container")
		;this never fires until door is already lockpicked and then opened normally

	elseif(akActionRef != myCompanion)
		Debug.Notification("aktionref != companion") ; this works

		Debug.Notification("target is not terminal or door")
                ;this works too

	CommandTarget.Clear() ; clearing because we never need it again on same object

What I'm trying to do, is simple, when my companion activates(=starts lockpicking or touches locked door, I do stuff). But I have problems detecting when my companion "activates" locked doors.


I could register for distance but I was hoping there is better way. Any ideas? Again, this works fine for locked terminals and non-locked doors.


Edit: Yes, my companion has needed keywords and can lockpick doors. It's just I can't seem to detect when it's happening which I need.

Edited by vkz89q
Link to comment
Share on other sites

I suspect there's something else going on there.


Look in the DefaultUnlockLinkOnActivate base script:

Scriptname DefaultUnlockLinkOnActivate extends ObjectReference Const
{Default script for opening it's linked ref on activate.  Optionally opens the door as well.}

Bool Property bShouldOpenDoor = TRUE Auto Const
{Whether the door should open when unlocked.  Default = TRUE}

Event OnActivate(ObjectReference akActionRef)
    if GetLinkedRef().IsLocked()
    	if bShouldOpenDoor

If OnActivate() only fires on doors after they are unlocked, that script shouldn't do anything. Am I right about that?


Have you checked to see if OnActivate() fires when you touch a locked door? It could be a companion issue rather than an OnActivate() one. It's possible (I'm guessing here) that the companion-picks-lock sequence is scripted to happen without an OnActivate(), and it's just unlock()-ing the door at the end of the anim.

Edited by Greslin
Link to comment
Share on other sites

Damn, you are right. If I tell my companion to open door, then quickly order her to do something else(so the alias gets filled), when I touch the door (while it's still locked) I get notification "aktionref != companion".


So it is a companion thing... well, this sucks.


Okay, Instead of walking to door and lockpicking it, she will now use telekinesis to poof the lock open with nice effect. Screw immersion :laugh:

Edited by vkz89q
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...