Activator + Script = Total Madness

Post » Wed Jun 20, 2012 12:50 am

I have an Object Ref of an Activator, with almost options set to None and unticked, with this script :

Scriptname AASSActivatorScript extends ObjectReferenceImport DebugActor Property PlayerRef  AutoIdle Property AASSAnim  AutoIdle Property IdleStop_Loose  Autoint IdlePlayingEVENT OnInit()   RegisterForUpdate(0.1)EndEVENTEVENT OnUpdate()if ( IdlePlaying == 1 )	 Notification("Controls Disabled")	 DisablePlayerControls()	 PlayerRef.PlayIdle(AASSAnim)	 IdlePlaying = 2elseif ( IdlePlaying >= 2) && ( IdlePlaying < 40)	 IdlePlaying += 1elseif ( IdlePlaying >= 40)	 PlayerRef.PlayIdle(IdleStop_Loose)	 EnablePlayerControls()	 IdlePlaying = 0endifEndEVENTEVENT OnActivate(ObjectReference ActionRef)   if ( IdlePlaying == 0 ) && ( ActionRef == PlayerRef )	IdlePlaying = 1   endifEndEVENT

It usually works perfectly on the very first try : Player in 3rd person view activates = Controls disabled & Player plays anim = Anim ends after a while, Player gets controls.

But then the others activations lead to chaos :

- Nothing happens on activation, or after a very long time, and/or
- Anim begins, ends nearly immediatly, Player can move(!), Anim continues to play randomly, Player has controls randomly
- If Player is supposed to play another Anim, he plays the one of this script
- Activation in 1st person view : Player is TELEPORTED to the door HeadMarker of the last entered Interior Cell ??!

Could someone explain me what the hell is happening ?
User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Tue Jun 19, 2012 1:36 pm

Put some debug.messagebox in your script to determine when it's bug
What event is not activated when he must be
Or when your script don't enter in the IF and show what is value of your condition
User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Tue Jun 19, 2012 10:45 pm

Teleport happens with some idles in 1st person. They are not supposed to be used by player and especially not in 1st person. Another thing regarding your script, you shouldn't register for constant update. Make it so that when activate happens then do RegisterForSingleUpdate(0), do what's needed and then again register for single update but give it delay (4) seconds, I guess that is what you wanted to achieve with 0.1 sec update time and testing when variable reach 40. You can also make two states and switch between them. Take a look at some trap scripts to learn how to use states with activators.
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Tue Jun 19, 2012 2:24 pm

What is most likely happening is your incredibly short OnUpdate timing is clogging the script system with pending OnUpdate events, several of which are running simultaneously. Looking at your script, there doesn’t appear to be any reason to use OnUpdate at all, try this:

Spoiler

Scriptname AASSActivatorScript extends ObjectReferenceimport DebugIdle Property AASSAnim AutoIdle Property IdleStop_Loose AutoEvent OnActivate(ObjectReference ActionRef)  Actor playerRef = Game.GetPlayer()  If (ActionRef == playerRef)	; Switch script state so later activations won’t go to this event	GotoState("IdlePlaying")	Notification("Controls Disabled")	DisablePlayerControls()	playerRef.PlayIdle(AASSAnim)	; Wait for four seconds – or however long you want the idle to run	Utility.Wait(4)	playerRef.PlayIdle(IdleStop_loose)	EnablePlayerControls()	; Switch script state back so this event will run again on the next activation	GotoState("")  endIfendEventstate IdlePlaying  Event OnActivate(ObjectReference ActionRef)	; If someone activates this object while the idles are playing, this event will fire instead, causing it to be ignored  EndEventendState

Basically, when you activate the object, you can use waits and such to just linearly run through what you want to have happen without looping through an OnUpdate block (or a game mode block in the legacy system). The script states are there to ensure that even if the player or something else activates the object while the idles are running that the activation is ignored by your script.
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Tue Jun 19, 2012 5:35 pm

Thank you very much for all your replies.

So i've made a mix between my old script and the one provided, with higher RFU(0.5) and States, and it works, all the time, at perfection - no more hacked animation & controls, very quick responses to activation, anim ending and controls back. Blessings of Arkay upon ye !

I've also fixed the teleportation problem with ForceThirdPerson().
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am

Post » Tue Jun 19, 2012 6:59 pm

Thank you very much for all your replies.

So i've made a mix between my old script and the one provided, with higher RFU(0.5) and States, and it works, all the time, at perfection - no more hacked animation & controls, very quick responses to activation, anim ending and controls back. Blessings of Arkay upon ye !

I've also fixed the teleportation problem with ForceThirdPerson().

That update period is probably still too fast and may cause issues if other scripts start running at the same time. Why are you sure you need it? The example script you posted only seemed to be waiting for four seconds before playing another idle and enabling the controls, which is exactly what the http://www.creationkit.com/Wait_-_Utility function is designed to do without having to loop or use update events (and being easier to read and understand).
User avatar
Bek Rideout
 
Posts: 3401
Joined: Fri Mar 02, 2007 7:00 pm

Post » Tue Jun 19, 2012 7:42 pm

Sorry for the delay, i had not seen your reply. Well i use a RFU(0.5) because in fact i use the same script to localize Objects around the Player, and was thinking that this part should be quick. I don't really know if this is making troubles, but i will though follow your advice and change the RFU to a higher one. Thanks.
User avatar
Jeneene Hunte
 
Posts: 3478
Joined: Mon Sep 11, 2006 3:18 pm


Return to V - Skyrim