[Suggestion] Allow guns to be toggled by variables or cycled through by pressing a key
gyrohero opened this issue ยท 4 comments
I suggest using the existing animation variable framework to add the possibility for enabling/disabling guns with variables. Most applications would probably use customVariables to switch on/off, acting like a safety. This would allow pilot-controlled weapons to be selectively activated, so that multiple guns can be controlled by the same seat without firing all of them simultaneously. Some applications may use non-custom variables like ground_onGround to enable/disable firing.
To accomplish this, I propose creating a list of safetyVariables that affect a gun in the vehicle part JSON. Then another list, desiredVariableStates, will contain booleans defining which of those variables need to be on/off in order for the gun to fire.
E.g.
"safetyVariables" : ["Rocket", "Left/Right"], //These would match the names of customVariables or other variables
"desiredVariableStates" : [true, false] //The booleans associated with each of the variables above
This would be in the vehicle part JSON entry for a rocket pod on the left wing of an aircraft. In order for it to fire, "Rocket" would need to be toggled on and "Left/Right" would need to be toggled off
Having these criteria be list-based allows more possible weapons configurations given the 4 allowed customVariables (2^4=16) as opposed to having one variable per gun.
So, I'm torn. While this is indeed a way to implement guns, I can see players complaining about them having to go into the panel to turn the gun on and off. I get the feeling they'll expect a MCHeli-eqsue system where they can just press a key to cycle through the guns currently available to them.
Thoughts?
I'd personally be fine with either way of doing it.
On the one hand, the way that I suggested would allow firing multiple guns at the same time if desired. That's probably excessive, but some aircraft (like WW2-era fighters) used wing-mounted machine guns that fired at the same time, so it could be a nice-to-have. Another benefit of this method would be that there is always a graphical representation of which guns are enabled (although you'd have to go into the panel to see it). If you end up going with doing it this way, you could also add the customVariables into the control configuration so that each variable can be toggled via a keyboard shortcut or joystick/controller button. You still wouldn't be able to toggle through weapons easily though.
On the other hand, the single key cycling through would almost definitely be the easiest for players. For a graphical representation, one solution could be to show the icon of the currently-selected gun in the bottom-right of the screen (similar to many FPS HUDs). The multiple-guns-firing thing could be decided at the pack level if you add a variable to the vehicle part JSON for guns along the lines of gunIndex. Index 0 could be reserved for no gun selected (safe). Pressing the key to cycle will just iterate the indices until it reaches the highest used index. If a pack author wants multiple guns to be fireable at the same time, they can give them the same index. Guns that aren't given an index will always be fireable by the seat that controls them. The variable that keeps track of which index is currently selected can be made accessible so that PAs can make their own representations of which gun is selected as well.
Assuming the implementation isn't too difficult, the latter option does seem better.
Question on the gun cycling: Would it be equitable to make all guns that the player can control from a seat and that are the same type of gun fire at the same time? Say if you have a plane with a single 30mm cannon, but with two 7.6mm MGs, and a drop-torpedo. In that case, you'd start off with no guns active, then cycle through the guns based on the order they were added to the vehicle (or perhaps based on the order there were specified in the JSON? Either or could work.). So you'd end up firing the 30mm, then switching to the two 7.6mm units, and the the torpedo.
As to what gun is active, I can either do the icon of the item in the corner, or the name of the gun in text. Item icon would mean less text and a smaller footprint, but might cause issues with packs where the item icon isn't a good representation of what gun is active. Personally leaning towards the text-based solution myself, as it's what MCHeli does and what folks are probably used to.
Thoughts?