fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

FR: Add a time check to is-facing sexp

Open Durandal-Thoth opened this issue 2 years ago • 3 comments

Pretty straight forward, this is a request to add an optional argument for a length of time (probably in ms) for a ship to be facing another ship for it to return true.

Durandal-Thoth avatar Nov 02 '23 04:11 Durandal-Thoth

This is not really practical. Generally speaking, sexps do not have "memory" like this. It would be necessary to essentially duplicate a sexp in code form, adding extra infrastructure for this special case.

Instead, this can be achieved using sexps within the mission itself. Set up a series of events so that a timestamp is assigned when the is-facing condition is initially satisfied, and cleared when the condition is not satisfied. Then add another event to check whether the timestamp is larger than your desired duration.

Goober5000 avatar Nov 02 '23 05:11 Goober5000

This is actually a good and useful idea and many sexps could benefit from this sort of thing. Generally speaking we should be making FREDing easier and more accessible by constantly lowering the bar of "programming think" required and having a framework in place to do this for various sexps as it comes up seems good and useful to expand our sexp system.

I'm not able to work this for the FSO side until I get BtA done at the very least, but it's something I'd be interested in creating a system for at some point.

Copying The_E's idea from Discord for safekeeping.

if target not facing object: reset timestamp for object and return false if target facing object and timestamp not set: set timestamp for object if target facing object and timestamp set: if timestamp is old enough: return true else return false

MjnMixael avatar Nov 02 '23 19:11 MjnMixael

I neglected to update this ticket back in November, but this request has been implemented as a scripted SEXP:

facing-sct.tbm.txt facing-sexp.tbm.txt

This pattern can be applied to other similar use cases that require time checks.

Goober5000 avatar Feb 10 '24 02:02 Goober5000

A eureka moment made this request a whole lot more tractable, not just for is-facing but for any boolean operator or SEXP tree. And the infrastructure needed was minimal and non-invasive. Amazing how much of a difference the right design can make.

This has now been implemented via #6415.

Goober5000 avatar Nov 10 '24 04:11 Goober5000