Hard Light Productions Forums
General FreeSpace => FreeSpace Discussion => Topic started by: Falcon on April 05, 2004, 01:26:52 pm
-
Is there a way that we can loop certain events like one event enabling another event.
Heres what Im trying to do. I trying to set up an event where I enable the AI by a certain key but when another key is pressed it will deactivate it. And I want this continous to go over and over and over activating and deactivating it whensoever I please.
-
Ah. The bane of FREDders. The linked repeating event.
Quite simply can't be done on retail.
Don't know about FS2_Open though. It didn't work last time I tried but this may have been fixed now.
-
Didn't CP figure out how to do this in retail? I'm pretty sure he did because he said it no longer works in FSO. :nervous:
-
Originally posted by Goober5000
Didn't CP figure out how to do this in retail? I'm pretty sure he did because he said it no longer works in FSO. :nervous:
I tried several different ways and could never make it work. The first event repeats normally. The second event screws up (I can't remember if it just keeps repeating based on the interval time or just happens once but either way it doesn't work properly).
-
Im using the Fredd_open version.
Oh another thing how do you get skyboxes to work to?
In Freed_open
-
Wasn't the FSO code changed to allow a -1 Repeat Count so an event would repeat forever? Err... or was that one of argv's changes that got removed... :nervous:
(<- amateur FREDder, probably wrong)
-
Originally posted by Arc
Wasn't the FSO code changed to allow a -1 Repeat Count so an event would repeat forever? Err... or was that one of argv's changes that got removed... :nervous:
(<- amateur FREDder, probably wrong)
The problem is not getting the event to repeat forever. The problem is getting the second event which is linked to the first to repeat too. It never worked when I tried it. I might give it another try later today and see if it works now.
-
Originally posted by Falcon
Is there a way that we can loop certain events like one event enabling another event.
Heres what Im trying to do. I trying to set up an event where I enable the AI by a certain key but when another key is pressed it will deactivate it. And I want this continous to go over and over and over activating and deactivating it whensoever I please.
Variables are your friend.
1) Create a variable with a default value of zero
2) Create an event that sets the variable's value to 1 whenever you press the key you want.
3) Create a second event that sets the variable back to zero whenever the other key is pressed.
4) Give both of these events repeat counts of 999999999999999.
5) Create a third event that says:
when
=
1
6) Create a fourth event that says:when
=
0
Give the third and fourth events repeat counts of 999999999999999 as well.
Should work.
-
Hmmmm. Never tried that method. I was using chains but I could never get it to work with them. I'll have to give that a try.
-
I've tried that in the past and it doesn't work because FS2 doesn't re-evaluate the when condition after the first time the event has fired. Has this changed?
-
It does for some sexps, not for others. Not sure if the = sexp is included among them.
-
I'll test this when I get back to Birmingham, if the variable method works now it'll allow me to make a cool Inferno mission I've always wanted to script :D
-
One thing I should add about this method: it will repeat the action of the third/fourth event every time the event repeats. So you may have to fiddle with this basic method depending on what sort of action you are trying to accomplish.
In the case of assigning an AI class to a fighter, it doesn't matter if the class is reassigned every second, so this will work as it stands. If the purpose were to fire a beam, one would need to drop the fourth event, and set the repeat interval on the third event to match the usual fire delay of the beam. You probably get the idea.
-
Aha. I thought that might be the case.
-
if you don't want an eternal loop on the action events, why not end them with setting the var to 3, or 2, or a or something?
so you get
when var = 0 then
when var = 1 then
when key1_pressed var = 0
when key2_pressed var = 1
-
:nod:
-
Precisely the sort of tweaking I mean, kasperl. :nod: In my firt post I was laying out the basic method. With my beam example I was giving one example of how it can be modified depending on the action one wants to execute.
-
I tried it. We're back to me being correct in the first place by the looks of it.
The problem is the = SEXP I suspect. I created the mission like this
(http://swooh.com/peon/karajorma/Misc-Pics/FREDDING-Loops.jpg)
Both events have a high repeat count (999999 or something). When run in the mission everything is fine until you press 1. Once that happens the message is repeated continually.
That's exactly what I saw when I tried this the first time using chained events. Unchaining and going on variables did nothing. Obviously the = SEXP is only evalutated once.
-
Okay, try this:
http://www.swooh.com/peon/Goober5000/fs2_open_r.zip
FRED your test mission, then go into Notepad and change the "when" to "every-time". Then load it up in this build and see if it works.
-
Goob, you wouldn't be trying to slip a new feature in during a code-freeze now would you? :D
*flees in terror as Goober's BFGreen charges up*
-
Hmm. Interesting. I did not expect that the when sexp would function that way. How does the every-time sexp work, karajorma?
Goob, you wouldn't be trying to slip a new feature in during a code-freeze now would you?
Shh[/size]
-
Downloading now
-
seems like i am not completely stupid afterall.....
-
Hmmm. Didn't work. It just kept repeating the message same as before. I'm going to have to experiment a little with this to see if I can get it to work. The problem could be due to the speed at which the event is repeating (I didn't set any delay so it could be that which is causing the problem).
At the very least I can knock up a mission to test this every-time thing a little more
-
Goober, if you can get this working, I shall build a small shrine to you. :nod:
-
No shrines, please. :nervous:
Here's a mission that plays around with set-ship-position: you start out facing a meson bomb, and you can press 1 to teleport it left and 2 to teleport it right. I needed only two sexps to make it work. It seems that key-pressed and key-reset are a little wonky when used with "when"... not sure why. "Every-time" works much better.
EDIT: For some fun, try shooting a missle at the meson bomb and then teleporting it away at the last second. It's kinda neat to see the missle swerve around and come back. :)
-
This is interesting. The problem I was getting may not have been due to when.
When I added a message to Goober's mission and it instantly started repeating itself over and over. The flaw may actually have been in the send-message SEXP and not in when at all.
I'll test the mission with when in a little bit.
anyway if you want to see what I mean have a look at this mission (http://swooh.com/peon/karajorma/Misc-Pics/every-time.zip)