Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: LoneKnight on July 28, 2011, 02:42:32 pm
-
I'm trying to set up a sexp that is triggered by the Player firing their primary or secondary banks. I originally thought it would be possible with checking through Key-Pressed, and simply enter Spacebar, Left CTL, etc to register for whether or not the Player fires, but
1. People can remap their controls.
2. Left and Right Click don't appear in the key-pressed conditions list.
Is there a way to check for any primary fire, regardless of what button is pressed to trigger it?
EDIT: I'm trying to add all of the fail conditions for a stealth mission I'm building.
-
primary-fired-since and secondary-fired-since are your friends. Set the delay to something low, as in 50ms and beware of bank numbers. Bank 1 is actually bank 0 in the sexp itself.
-
I tried working earlier with primary-fired-since but left the delay at 0, assuming that it was better to keep it at 0, and nothing happened. But once I changed the delay to 50 ms it worked perfectly! Thanks so much!
-
primary-fired-since and secondary-fired-since are the best way of doing this, but FYI if you use key-pressed and the player has remapped their controls, FS2 will take that into account and the SEXP will trigger anyways. Also, "Button 1" and "Button 2" correspond to left- and right-click, respectively.
-
I tried working earlier with primary-fired-since but left the delay at 0, assuming that it was better to keep it at 0, and nothing happened. But once I changed the delay to 50 ms it worked perfectly! Thanks so much!
That's the thing with this sexp, it pretty much asks "Has the player fired primary/secondary bank 0/1/2 in the past <number> of ms", It's not a delay. (;
-
As you say, the idea is to check if the key has been pressed within a certain amount of time, not if a certain amount of time has passed since the key was last pressed. A delay wouldn't make any sense. You could easily check for that using the key-pressed SEXPs.