Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: wistler on August 22, 2019, 04:21:18 pm
-
Hi,
I have a mission where beam turrets are continuously firing on a target as a beam-fire SEXP.
I have this SEXP set to repeat and it works fine. My problem is when I want the turret to stop firing once an event becomes true.
The beam keeps firing because the repeat number is high, I’ve tried disabling the turret, beam-lock-all, everything.
As an alternative, what’s tthe easiest way of having an event repeat itself every x number of seconds until another event becomes true?
Any advise would be appreciated.
-
Use trigger instead of repeat, set that "number" to something super high (99999) and intervals to the rate of fire.
As condition, take (and (is event true delay x) not (is event true delay y)).
-
Can't see if I haven't seen the event proper, but Nightmare is correct: You need limiting condition which is always a good idea with repeating events.
[attachment eaten by a Shivan]
-
That's worked a treat, thanks guys.
-
Use trigger instead of repeat
I'm wondering why that was needed. I can't see how it makes any difference in this case. The event 0rph3u5 posted for instance should work either way.
-
If it is triggered (when the condition becomes true once) it will fire until the turret is destroyed when using repeat. Triggered looks each time whether the condition is still true.
-
Nope, that's not actually true. The difference between Repeat Count and Trigger Count is a little more subtle than that.
Both will check if the event's trigger evaluates to true every time they fire. The difference is WHEN they check. Let's take 0rph3u5's event as an example. As the event will wait until triggered the first time. Then it will wait 30 seconds and check if the trigger evaluates to true. This occurs whether using a repeat or trigger count. The difference manifests if the event evaluates to false. With trigger count, the game will treat the event like every other event and evaluate it again every frame until it triggers again. With repeat count it will wait the interval count (i.e 30 seconds) and only then will it evaluate it again.
It is actually possible to use both together at the same time in fact.
There's a more detailed explanation here (https://www.hard-light.net/forums/index.php?topic=66502.msg1313166#msg1313166).
-
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".
Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.
-
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".
Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.
^This. I next to never encountered something where Repeat was doing any good.
-
Kara you've explained this difference many times, and probably very well, but I gotta tell you, I have no ****ing idea what it is and cannot retain your explanations for more than a couple seconds. My brain just grunts 'trigger count good, repeat count bad'
e: Let me see if I can get it down
Repeat: do it, then keep doing it until the repeat delay is up, and then start evaluating again do it until it becomes false, then wait the repeat delay and check again; if still false, wait that delay again and check; ad infinitum when it becomes true, do it once, then wait the repeat delay and check whether to do it again; if not, wait the repeat delay and check; ad infinitum
Trigger: do it once, wait the trigger delay, and start evaluating every frame again
-
The mad thing about the repeat is that there was no stopping the turrets from firing, even locking the turrets and beam-lock-all doesn’t make a difference.
I can’t imagine repeat has many practical uses.
-
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".
Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.
Yep. Repeat Count is the original Volition creation and once I discovered it doesn't work the way people thought it did, I coded up trigger count which does work that way. For the most part, the reason I didn't simply replace one with the other was because of backwards compatibility. I suspect I could have replaced one with the other without much of a change. They are virtually identical in most cases.
As you said, there are some rare cases (timer related for the most part) where you'd only want things to be tested every x seconds where repeat count would be better. For example, suppose you were doing a mission near a pulsar and you decided if the player didn't have enough shields the screen would white out or EMP for a second or two. Trigger Count would need a separate timer variable but you could simply tell Repeat Count to check the shield strength every 20 seconds.
But yes, there is nothing Repeat Count can do that Trigger Count + Variables can't.
-
I finally understand. Once the event is false the game foolishly decides to wait the whole repeat interval to try again, unless you use trigger count, where it will check every frame, regardless.