Scripting a klaxon light with a door & switch

Post » Tue Dec 06, 2011 11:33 am

Uhh... long story short, I'll start with onw question and add to this post if I think of another question on this topic:

I'm failling to find answers elsewhere; can I say...
if MyRef.Playgroup Open 1 == 1

... or is there another way to find out a ref's current playgroup animation? I only ask if that works because after trying a few things, that was the only line of scripting that DIDN'T return an error message, and it runs in the game, but it's not doing what I want it to do, but I can't tell if that line is what's wrong or something else.

Any help is appreciated, as always! :D Thanks.

--------------------------------------------------------------

[EDIT:] Alright, what I'm TRYING to do is have a switch that activates a door (simple), but I want a Klaxon light that flashes when the door is OPENING, OPEN and CLOSING, but not when it's closed.

So one thing I'm wondering is how to script two animations in a row; the Klaxon light has three animations:

Forward......the light quickly fades in from off to on.
Left............the flashing light loop (on).
Backward...the light fades out slowly from on to off.

I can't figure out how to play the forward animation + wait for it to finish (albeit only 1/10th of a second) + play the left animation in a loop.

My next problem is stopping the Klaxon when the door is shut. I can't run a simple OnActivate with the switch, because that would stop the light when the door starts closing, but because I'm picking and want to expand my knowledge as usual, I want it to stop flashing when the door is done closing.

To further complicate things, I'd love it if I could (what else) get the light to play the backward animation as the door reaches the closed state, ending with it off (no animation).

This is the closest I've come in scripting after talking to a few friends and Willie's help here in this thread:
Begin GameMode	If (rLight.IsAnimPlaying) && (rDoor.GetOpenState == 3)		rLight.PlayGroup backward 1		rGlow.PlayGroup backward 1	EndIfEnd

rDoor = the door
rLight = the klaxon light object
rGlow = the klaxon light marker

My new problem is that, yes, this runs when the door is shut & light is animating, but because it's a Begin GameMode script it runs every frame of game play, so when it starts the backward animation on the light and glow, in the next frame it runs the script again, realizes that the backward animation (IsAnimPlaying) is playing and restarts the script, leaving the light in a strange looking perpetual fade out state.

Firstly, the simpler answer, I know how to script an animation (Playgroup) but how do I script it to stop animating? Playgroup 0?
Secondly, the more fun answer. Hopefully what I'm asking makes sense at this point. How do I tweak the above script to play the backward animation on the light & glow ONCE, effectively keeping the light off exclusively when the door is closed?

I LOVE THIS FORUM! Thanks to anyone who can help. You don't have to know all about this to help, anything can be useful. ^_^
User avatar
JD bernal
 
Posts: 3450
Joined: Sun Sep 02, 2007 8:10 am

Post » Tue Dec 06, 2011 12:22 pm

*bump*

Nuf' said.
User avatar
Lavender Brown
 
Posts: 3448
Joined: Tue Jul 25, 2006 9:37 am

Post » Tue Dec 06, 2011 11:11 pm

Use the WIKI: http://geck.gamesas.com/index.php/PlayGroup

PlayGroup does NOT return a value, so what happens is the 'open' animation is played on the reference and the "1 == 1" is probably ignored.

Most people code to use the IsAnimPlaying command. It returns a value if any animations are playing on the referenced object.
http://geck.gamesas.com/index.php/IsAnimPlaying
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm

Post » Tue Dec 06, 2011 12:51 pm

I.... huh, actually IsAnimPlaying works for me in this case... but what if something had more than one animation, but it wasn't a door so I couldn't use GetOpenState either... is there a way to return a value that will tell which animation is playing?
User avatar
Campbell
 
Posts: 3262
Joined: Tue Jun 05, 2007 8:54 am

Post » Wed Dec 07, 2011 12:30 am

New problem... alright, as promised I'll just explain what's going on... I'll re-write the first post in a moment......
User avatar
Chloe :)
 
Posts: 3386
Joined: Tue Jun 13, 2006 10:00 am

Post » Tue Dec 06, 2011 6:38 pm

There is no way to know what animation is playing. Unless you are scripting which animation to play using PlayGroup. Then you could set a variable so you know which one is playing in the script.

But if this is a door, you can use http://cs.elderscrolls.com/constwiki/index.php/GetOpenState to tell you what the door is currently doing,
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Wed Dec 07, 2011 2:53 am

I had the same problem in my Vault64 mod. When the jail door is open, I have the klaxon light go on and spin. when its closed, I have it off.

I simply went with using enable and disable. And placed a working-on klaxon and a turned-off klaxon.
The 'backward' and 'forward' animations, from what I could tell, were not being used in the game, so I guessed them to be bugged since they do not work that well.

For the most part, people are not going to 'notice' what you are trying to achieve. At least for how much work its going to take to get the 'turning on' and 'turning off' animations to work.
If you insist on it, then I would suggest using a timer to play the 'Forward', and then the 'Left'. When you turn it off, play the 'Backward' and then disable it.

You can see how the animations work in game by going to the console, clicking on the light so its name appears on screen, then typing:
playgroup forward
playgroup left
playgroup backward

You will see the animations are a bit buggy. (if I remember this all correctly :shrug: )
User avatar
Chris Johnston
 
Posts: 3392
Joined: Fri Jul 07, 2006 12:40 pm

Post » Tue Dec 06, 2011 10:46 am

One more thing then, is there a script for stopping all animation? So, a line that will stop the light/glow from flashing no matter what animation is playing?
User avatar
Jessie Butterfield
 
Posts: 3453
Joined: Wed Jun 21, 2006 5:59 pm

Post » Tue Dec 06, 2011 11:39 am

I found out one thing, PlayGroup has an InitFlag (0, 1 or 2) where 0 = current animation completes first, then the new animation starts, and 1 = new animation starts immediately.

So if I'm getting this right...
rLight.Playgroup Forward 1rLight.Playgroup Left 0

...that should let the light "fade in" and then run the loop. Right?

Then I suppose changing my script in the first post there to:
rLight.PlayGroup backward 0rGlow.PlayGroup backward 0

...would let the left animation complete first, *then* play the backward animation, which should also stop it from restarting the animation every frame (as explained), right? Or will it just do the same thing, except wait until the backwards animation is complete rather than doing it EVERY frame? *babbling* Any of this making sense anymore? :rofl:

I'm gonna go test some things out... but I still want to know if there's a script to stop all animations.
User avatar
kristy dunn
 
Posts: 3410
Joined: Thu Mar 01, 2007 2:08 am

Post » Tue Dec 06, 2011 6:37 pm

If there is an 'Idle' animation group or something similar, that is the only way to 'stop' the animation from playing. But, its really not stopping it, its playing the 'off' animation.
If the object does not have an off animation, then you cannot stop it from playing. Well, perhaps a Reset3DState command 'might' stop it from playing. :shrug:
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Tue Dec 06, 2011 11:21 am

I was working with Klaxon lights a while back and could never get them to work. Since this topic is active, I'm going to try again.

First off, I have the vanilla "KlaxonLight" in a cell that has the vanilla "KlaxonLightScript" running on it. In-game, nothing happens.
The vanilla "KlaxonLight" is an activator. So I made a copy and called it MyKlaxonLight. I gave it a name and tried to activate it in-game. Unlike all other activators I've ever worked with, this one didn't even show up as something the player could interact with. No light, no touch, no nothing. Could one of you experts explain to me how to get a simple klaxon light to turn on, and why I can't activate it by touching it? It acts as though it is a static object. I am very confused.
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Tue Dec 06, 2011 1:45 pm

You need to set an activate parent for the default Klaxon lights. A door, or switch.
User avatar
Melly Angelic
 
Posts: 3461
Joined: Wed Aug 15, 2007 7:58 am

Post » Wed Dec 07, 2011 12:58 am

You need to set an activate parent for the default Klaxon lights. A door, or switch.


Ok, but why can't you use the light itself if it is an activator? Is it somehow hard-coded differently than other activators?
User avatar
k a t e
 
Posts: 3378
Joined: Fri Jan 19, 2007 9:00 am

Post » Tue Dec 06, 2011 7:27 pm

Not all activators are interactive.

You could just hide a switch inside it and make it look like it is though.
User avatar
Rebecca Dosch
 
Posts: 3453
Joined: Thu Jan 18, 2007 6:39 pm

Post » Tue Dec 06, 2011 7:35 pm

Not all activators are interactive.

You could just hide a switch inside it and make it look like it is though.

Well, I just learned something new. Its not a big deal or anything. As you know from other threads, I'll spend time on something fruitless just because I'm curios.
User avatar
Oscar Vazquez
 
Posts: 3418
Joined: Sun Sep 30, 2007 12:08 pm

Post » Tue Dec 06, 2011 11:44 pm

Well, I just learned something new. Its not a big deal or anything. As you know from other threads, I'll spend time on something fruitless just because I'm curios.


Yeah I learned the hard way. Something was an activator and I was all like 'man that would be a cool thing to use to do such and such' but I got it in the game and couldn't do anything with it.
User avatar
Trish
 
Posts: 3332
Joined: Fri Feb 23, 2007 9:00 am

Post » Wed Dec 07, 2011 1:30 am

Yeah I learned the hard way. Something was an activator and I was all like 'man that would be a cool thing to use to do such and such' but I got it in the game and couldn't do anything with it.


I was thinking I could make a cool looking panic button or some such with it. Just size it down and put it on a control panel. Still could I guess if I follow your prior post.
User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Wed Dec 07, 2011 2:21 am

The mesh attached to the activator must have a collision zone on it in order for you to be able to interact iwth it.

In Vault 13 (part of the solar scorcher mod) I am using a terminal to turn the klaxon lights on and off...
User avatar
Tracy Byworth
 
Posts: 3403
Joined: Sun Jul 02, 2006 10:09 pm

Post » Tue Dec 06, 2011 6:18 pm

Yeah all my light switches aren't really switches. I use crazy things and scale them down then hide a switch in the wall behind it. Works perfectly.
User avatar
Isaiah Burdeau
 
Posts: 3431
Joined: Mon Nov 26, 2007 9:58 am

Post » Tue Dec 06, 2011 11:37 am

If the object does not have an off animation, then you cannot stop it from playing. Well, perhaps a Reset3DState command 'might' stop it from playing. :shrug:



For your information:

Reset3DState WORKED LIKE A CHARM.

I needed to make a klaxon light turn off after having it animate for a moment. This was the script command that actually turned the light off after I'd set the variables in my control script to match the non-animating state.

Yes this is an old thread but, it bears follow-up IMO because it was a positive resolution.
User avatar
jasminĪµ
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am

Post » Wed Dec 07, 2011 2:44 am

This script made for a fairly decent klaxon light which turns on, spins for a few seconds, and then turns off.

You make a klaxon light "activator" object of your own as well as the light object by renaming them in the GECK and selecting the button to make a new object. A light object that could be copied in this way is KlaxonGlow, and the activator object is KlaxonLight. Ignore the fact that the one thing is technically an activator and not a static, it's not an important detail for this.

Then, you put a script like this onto both of the objects, and you place them in the world in the same sort of shape as the only MS04KlaxonLight in the game is placed (right-click MS04KlaxonLight in the editor, select Use Info, then double click the entry that appears, and watch it load in the render window).

The "PhalanxExitTermREF.test1" is the script variable I happen to be using to tell the light to get started doing its thing, this MUST live external to this object script. You would use and set your own script variable or quest variable or maybe even global if you wanted to waste one.

This new messageboard of Bethesdas will not allow me to create codeboxes or quotations in my posts, so, here it is in plaintext.


scn HappySpinnyKlaxonSCRIPT

; backward = turning off, left = spinning, forward = turning on

short SpinnyLight

float timer; 3 second
float timer2; 1 second for light turning off
float timer3; 0.3 second for light turning on
float timer4; delay the light turning on at all for 0.5

begin gamemode

if PhalanxExitTermREF.test1 == 1 && SpinnyLight == 0
set SpinnyLight to 1
endif

if SpinnyLight

if SpinnyLight == 1
set timer4 to timer4 + getsecondspassed
if timer4 > 0.5
playgroup forward 0 ; turn the light on animation
set timer3 to 0
set timer2 to 0
set timer to 0
set timer4 to 0
set SpinnyLight to 2
endif
endif

if SpinnyLight == 2
set timer3 to timer3 + getsecondspassed
if timer3 > 0.3 ; the turn-the-light-on animation has finished
set SpinnyLight to 3
playgroup left 2 ; start the light being spinny
endif
endif

if SpinnyLight == 3 ; the light is being spinny
set timer to timer + getsecondspassed
if timer > 3
set SpinnyLight to 4
playgroup backward 2
endif
endif

if SpinnyLight == 4
set timer2 to timer2 + getsecondspassed
if timer2 > 1
reset3dstate
set SpinnyLight to 0
set PhalanxExitTermREF.test1 to 0
endif
endif

endif

end
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Wed Dec 07, 2011 2:17 am

... or is there another way to find out a ref's current playgroup animation?


I saw some code just now in DLC05 (bethesda's script), which made me think of this post.



IF ( DLC05teleportTestObjectREF.isAnimPlaying forward == 0 && DLC05teleportTestObjectREF.isAnimPlaying backward == 0)
User avatar
Chloe :)
 
Posts: 3386
Joined: Tue Jun 13, 2006 10:00 am


Return to Fallout 3