New Conditionals

From FreeSpace Wiki
Jump to: navigation, search

Material written by karajorma : http://homepage.ntlworld.com/karajorma/FAQ/fredopen.html#conditionals

What are the new conditionals?

In the retail version of FRED2, all events began with the plain old boring when SEXP. You can do a lot with when. In fact until mid-2004 that was all you had. However, there are some times when when just isn't enough. FS2_Open has added several new conditionals that fill in some of the gaps.

Every-Time

Every-Time is a version of when which continuously repeats itself for the entire duration of the mission. Unlike when, an event using every-time can't ever become true or false. It is always incomplete regardless of however many times it has executed. Every-Time can basically be thought of as being the similar to a repeating event using when with a delay of 0. Due to the fact that events using Every-Time are never marked as true or false, it can be used to solve problems with SEXPs like key-reset in repeating events. On the other hand, you should never chain an event to one with every-time or use the event-true/event-false SEXPs with it as due to the fact it is always incomplete those events will never trigger.

When-Argument / Every-Time-Argument

Probably the two most confusing of the new SEXPs for most people, these two SEXPs are also amongst the most powerful. Both SEXPs allow you to do things that previously would have required a lot of tiresome fiddling with variables. In addition, they also allow you to do things in one event that previously could have required hundreds.

Argument-01.jpg
You use these SEXPs like this. Suppose I had a scenario where I wanted something to happen if ever Alpha 1 got within 2000m of any of Cancer, Leo or Libra wings. What you could do is make an event like the one to the left for each wing. Then in a fourth event, I'd check if any of the events had come true and then do whatever I wanted to happen. That works reasonably well but what if there were nine wings instead of three? I'd need ten events in total. Nine events checking to see if Alpha was close and one with an enormous or SEXP checking if any of those events had occurred. As you can see this would take a long time to make, uses up a large number of the SEXPs you're allowed in a mission and would be a pain in the neck to change if you wanted to add something to when the nine events trigger (suppose you later decide that it only matters where Alpha is after a certain capship arrives. You've now got to go back and edit all nine events).
Argument-02.jpg
When-Argument gives you a way to do this more simply. The SEXP allows you to declare a list of objects that the rest of the event will apply to. The event to the right replaces the four events I needed to check the distance from Leo, Cancer and Libra wings with a single event. If I wanted to do the same thing for nine enemy wings I wouldn't need any more events. I'd just add the names of the six extra wings below Libra.

The event works quite simply. When the mission is running, FS2 looks at the list of ships this event applies to. Wherever it sees the word argument, it sticks in the name of the wing at the top of the list. If the condition is true (i.e Alpha 1 is less than 2000m of Cancer wing) then the event triggers and whatever you've replaced do-nothing with will happen. If not FS2 goes back this time substituting the second name on the list wherever it sees argument. FS2 continues down the list until it reaches the end or finds something that triggers the event.

It's worth noting that there is no requirement for the argument to be a ship or wing name. It can be anything, subsystem name, message name, event name, whatever you want.