Jump to content
Sign in to follow this  
blackmamb

Any way to force a specific fire mode?

Recommended Posts

So, as it seems, setWeaponState has actually disappeared, being replaced by setWeaponReloadingTime.

I, on my end, am searching for a way to force the player into a specific fire mode, say "burst". Anybody knows a way to do that?

Cheers.

Share this post


Link to post
Share on other sites

Yeah, but it's totally flawed. Basically, as soon as you pick up a new weapon, the indexes array is completely messed up. So if you have a M16 with a 203 and ACOG, plus have grenades in your gear,

0-> single

1-> burst

2 -> 203

4-> nades

After that it goes on, but the order doesn't make any sense.

Now you get to an ammobox, get an M16 with irons and a 203.

0-> single

1-> nades

And it doesn't make any sense after that.

In the end, it works as long as you don't change the default loadout. After that, it's broken.

Share this post


Link to post
Share on other sites

Never easy is it? But it's a number and we can therefore use math to solve the problem:

_modeIdx = 0;
while{(currentWeaponMode _unit) != "burst"} do {_modeIdx = _modeIdx + 1; _unit action ["SWITCHWEAPON", (vehicle _unit), (vehicle _unit), _modeIdx];};

or

{_x addEventHandler ["Fired", {_modeIdx = 0; while{(currentWeaponMode (_this select 0)) != "burst"} do {_modeIdx = _modeIdx + 1; (_this select 0) action ["SWITCHWEAPON", (vehicle (_this select 0)), (vehicle (_this select 0)), _modeIdx];};}]}forEach allUnits;

Share this post


Link to post
Share on other sites

I wasn't clear. This can't work. The "burst" mode is removed when dropping your weapon, but is not added again. Thus you can't access it anymore via the switchWeapon action.

Edit: oh wait. D'you mean it's actually there but a lot further in the array?

Yup, looks like it works. It's pretty clunky, though, and will need an extra bit of scripting.

So, for an M16, the burst mode is found at the index 18. Interesting.

Thanks a lot, by the way.

Edited by BlackMamb

Share this post


Link to post
Share on other sites

What I think you mean is weapons that don't have a burst mode can't be made to fire in burst mode? Welcome to the world of accurate military simulation :) If you want it any other way, make a replacement config or addon or limit the weapons the player has access to? You might be able to have extra conditions in there that only allow the EH to only work if the weapon has a burst mode, will have a look later.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Also not tested but you may need to spawn the code as it will need a sleep, and instead of {_unit action I think it will need a game logic or you get the pick up weapon action played.

Share this post


Link to post
Share on other sites

Well, back to this, back to where we were. It is broken. Randomly doesn't work on some weapons.

As an example, if you use a SCAR Mk16 EGLM TWS. You start in single fire mode "SCAR_L_Single", you try to switch to single (stupid, I know). It works. The single mode is found at the index 1. Now you switch to Full mode, and execute the exact same code to roll back to single: it goes up to 10000, then the while loop stops, and it doesn't find it. Then you're stucked in some "Safety" mode, even though it shouldn't exist, where you hold your weapon but can't fire it. Note that if you have a side weapon, it'll switch to it. But you won't be able to fire anyway.

Here is the code, used in a radio trigger to test this:

mid = 0;   
while{(currentWeaponMode player) != "SCAR_L_Single"} do {mid = mid + 1; player action ["SWITCHWEAPON", player, player, mid];}; 
player sidechat str(mid);

Other example: try and get the burst mode on an ak74 GL. The loop will stop, return burst, although you will be in semi automatic mode. Of course one could ask why the AK74 would have a burst mode defined in the config.

Edit again: Now that I think about it, it might just be for the AI.

Edited by BlackMamb

Share this post


Link to post
Share on other sites

Possibly, I'm not sure. I use about the same idea, simpler, to reinitialize the stuff and get to the firemode I want.

player selectWeapon (currentWeapon player);

Although the number of clunky workarounds I need to make this work really makes me wish BIS implemented this.

Would make my life so much easier here, and I guess it could be pretty useful for AI mods too.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×