Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: LoneKnight on July 28, 2011, 02:42:32 pm

Title: How to check for Player firing Primary and Secondary banks?
Post 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.
Title: Re: How to check for Player firing Primary and Secondary banks?
Post by: Lester on July 28, 2011, 02:50:41 pm
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.
Title: Re: How to check for Player firing Primary and Secondary banks?
Post by: LoneKnight on July 28, 2011, 02:57:03 pm
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!
Title: Re: How to check for Player firing Primary and Secondary banks?
Post by: LordPomposity on July 28, 2011, 03:22:41 pm
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.
Title: Re: How to check for Player firing Primary and Secondary banks?
Post by: Spoon on August 01, 2011, 06:03:47 am
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. (;
Title: Re: How to check for Player firing Primary and Secondary banks?
Post by: karajorma on August 01, 2011, 01:43:17 pm
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.