Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: killface on August 19, 2008, 07:28:21 pm

Title: SEXPs: Recurring events
Post by: killface on August 19, 2008, 07:28:21 pm

Alright...I need some guidance.  How would one design a recurring event in Fred 2?  Basically, I want my pilot to have to remain within a 500 meter sphere of a damaged communication beacon to be able to hear the transmissions coming through it.  If the pilot moves to 500-1000 meters away, the messages get scrambled.  If he moves 1000+ meters away, no messages at all.  I'm imagining that there's a looping SEXP that allows for "every time" events that could pull this off, I just need an example of how to use one.
Title: Re: SEXPs: Recurring events
Post by: Droid803 on August 19, 2008, 07:53:31 pm
every-time SEXP should do that, or just set it to loop like 9000 times or more.
Title: Re: SEXPs: Recurring events
Post by: karajorma on August 20, 2008, 04:34:32 am
Don't use every-time. Simply specify a very large number of repeats and a repeat delay of 1 (The options are in the events editor by the side of the main box where you make the SEXPs).
Title: Re: SEXPs: Recurring events
Post by: Snail on August 20, 2008, 04:36:57 am
So when do you use every-time? :confused:
Title: Re: SEXPs: Recurring events
Post by: karajorma on August 20, 2008, 04:48:20 am
Most people use every-time when what they really ought to be using is when with a repeat delay of 0. Every-time is a specialist SEXP that you only should need once in a blue moon. Basically certain SEXPs mark themselves as SEXP_KNOWN_TRUE or SEXP_KNOWN_FALSE. When that happens the SEXP will never be evaluated again. The game has basically replaced that SEXP with the true one.

Every-time forces the game to re-evaluate the SEXP. An occasion when you actually do need every-time escapes me at the moment. But I'm sure you'd bump into them if you started using the ship-create SEXP for instance. As many SEXPs will mark themselves FALSE or TRUE the second they think that they are being used for a ship which doesn't exist in the mission file.
Title: Re: SEXPs: Recurring events
Post by: FUBAR-BDHR on August 20, 2008, 01:26:58 pm
One place I've found every-time to be useful is getting rand-multi and rand-multiple-of to behave like you would expect them to.  Have it constantly evaluating and storing to a variable so when you need to grab the value it won't show any type of pattern.  Even rand-multi by itself isn't all that random and tends to pull the same values when missions are replayed. 
Title: Re: SEXPs: Recurring events
Post by: karajorma on August 20, 2008, 01:48:08 pm
You're not seeding it by any chance? If you supply the optional argument it WILL give you the same set of numbers every time you play the mission. That's actually the entire point of seeding. :D
Title: Re: SEXPs: Recurring events
Post by: FUBAR-BDHR on August 20, 2008, 02:05:02 pm
Nope.  We had this discussion before and came to the conclusion that it probably doesn't work quite right but random events were the "bane of your existence"  http://www.hard-light.net/forums/index.php/topic,53198.0.html
Title: Re: SEXPs: Recurring events
Post by: karajorma on August 20, 2008, 02:11:22 pm
I only have the vaguest recollection of that. Any idea why I said I wouldn't touch it?