Page MenuHomeFeedback Tracker

selectWeapon script command not functioning.
Assigned, WishlistPublic

Description

When using the command unit selectWeapon "Binocular"; in a script it does not seem to be functioning. The unit does not select his binoculars.

I have tested this script in Arma 2 and it works perfectly, and it use to work in Arma 3 but not at the moment its not.

Others on the dev branch forums have also commented that unit selectWeapon "throw"; does not work also.
{F23012} {F23013}

Details

Legacy ID
4062836127
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

I have made a repro demo that demonstrates this bug.

Additional Information

Nothing at this stage.

Event Timeline

PartyHead edited Steps To Reproduce. (Show Details)Jan 7 2014, 3:45 PM
PartyHead edited Additional Information. (Show Details)
PartyHead set Category to Scripting.
PartyHead set Reproducibility to Always.
PartyHead set Severity to None.
PartyHead set Resolution to Open.
PartyHead set Legacy ID to 4062836127.May 7 2016, 5:42 PM

both addWeapon and selectWeapon need unit to be local, you should revise your mission accordingly.

I have never had problem with selectWeapon.

Updating this with my finding to steer devs in right direction :)

The selectWeapon command works no problem. In fact if you do something like

bob selectWeapon "Binocular"; hint currentWeapon bob; sleep 1; hint currentWeapon bob

The first hint will show "Binocular" and the 2nd will show the current weapon AI is holding. So the problem is that AI changes to the "Binocular" momentarily and then defaults back to what it is holding. The problem is with AI refusing to use binoculars when ordered.

If you remove all weapons from AI and give it binocs, it will obey. Same happens in trying to persuade AI to use handgun. It will just hold on to the rifle.

Hope this helps.

Today's update fixed AI switching to handgun but it still refuses to switch to Binoculars.

@Killzone_Kid:

can't reproduce what you write.
Just tested on 10/01/2014 DEV version.
The following code, put into unit init field:

handle = this spawn {
sleep 1;
_this selectWeapon "Binocular";
hintc format["%1", currentweapon _this];
};

shows current weapon being the original weapon and not binocular even immediately after selectweapon execution.
So i think selectweapon is broken.
It worked fine till version 1.08 though.

---

Run the attached repro (selectweapon_bug_2.Stratis.zip).

@fabrizioT B_soldier_F doesnt have binoculars in the inventory, you are trying to make AI select non existent weapon. Add them first and it works:

this addweapon "binocular";
handle = this spawn {
sleep 1;
_this selectWeapon "Binocular";
hintc format["%1", currentweapon _this];
};

@Killzone_Kid:

Bah. You're right.
I originally tested the code with "Throw", then swapped to "Binocular" to keep on track with original report.
Forgot checking unit inventory.

Code:

handle = this spawn {
sleep 1;
_this selectWeapon "Throw";
hintc format["%1", currentweapon _this];
};

is not working right anyway.
I've seen this ticket of yours, looks related:
http://feedback.arma3.com/view.php?id=14177

@fabrizioT "Throw" ticket is kinds related but I fear selectWeapon not quite working with it is due to different system used in A3, mainly that you have a separate key for throwing items. Making throw stay would mean you could throw grenades with your LMB and not "G" key

@DarkDruid:
Any chance we'll got this fixed soon?

@KillZone 'So the problem is that AI changes to the "Binocular" momentarily and then defaults back to what it is holding. The problem is with AI refusing to use binoculars when ordered.'

And one would like to use 'selectWeapon' to do exactly that. So that means 'selectWeapon' is broken doesn't it? At this moment 'selectWeapon' seems pretty useless. I had the same problem with trying to force the AI to use a launcher.

@joost AIs have their own mind. If you take all weapons from AI it will select Binocs when ordered, so no selectWeapon is not broken, AI is. selectWeapon also works on player 100%.

I'm a little confused by your point Killzone. If selectWeapon only works when one weapon is available, it's broken isn't it? 'SELECT' implies choosing from multiple options.

I think the OP wishes (and I certainly do) a command that forces an AI to arm a specific weapon from its inventory list consisting of multiple weapons. It uses the selected weapon as primary weapon connected to a controllable condition (this goes for binocs, launchers, rifles, handguns and maybe grenades)

If such a command were created I think it would be useful to name it 'selectWeapon'.

selectWeapon is definitely broken at the moment and if you want to see what it is suppose to work and look like just convert my repro mission attached to this report into an Arma 2 mission and watch what the unit in the mission does, which is how it should work in Arma 3. This command hasn't always been broken in Arma 3 it did use to work how its suppoes to once, and has been broken since the last stable patch before the recent one.

@Killzone_Kid can you please stop cluttering up this report with useless information that is of no help to the Dev's DarkDruid has already replied back on the Dev scripting forum that they acknowledge it is broken and they will take a look into it.

The fact that a unit will select binoculars when binoculars are all the unit has does not mean selectWeapon is working as you say 100%. The function of selectWeapon is to select between weapons which it does not do at the moment, so therefore yes it is definitely and 100% broken.

@PartyHead: good to hear that it once worked as expected (I never played ArmA2, OFP only). Mixed infantry attacking vehicles get massacred because infantry with launchers fire too late (rifles firing first). I want to use 'selectWeapon' on infantry with launchers to force them to fire early on targeted vehicles.

@PartyHead Dude Druid acknowledged that *something* is broken, not that *it* is broken I can read too you know. But whatever, if you think I don't want this fixed, you are wrong. If you think I am not helping, fine I'll leave.

@KillZone, don't take it personal, but I have the feeling that your input in this case was not helping.

  • Your points seem 'academic' and too much about semantics, whether it's 100% broken or 80% broken or whatever
  • Your examples address very specific unusual circumstances where it does work or requires elaborate workarounds

This gives me a feeling of frustration, because, for example, I'm not interested in removing allweapons of AI or use selectWeapon only on the player.

I think the reporters of a ticket are more interested in either proof that something is working/not working as intended or a reasonable workaround for specific situations.

I think Killzone_Kid gave valid and useful hints here.

To me selectweapon "Throw" was working fine within ArmA3 1.08 and not later, so i think that whatever is broken, it was broken within DEV builds just after 1.08.

Also having same issue. I am attempting to give a civilian the binoculars and have them stand using it. When i use the code below, he does not select it. I've switched to the unit as player and its the only item in his inventory.

Code in INI line:
this addWeapon 'Binocular'; this selectWeapon "Binocular";

BTW if you are wondering why i am using a civilian, its because i am attempting to use this unit as a decoy and not alert my AI team when i have to search for him as a bomb spotter. I am adding a addaction and script to then arrest the unit.

@JCae

try this:

0 = this spawn {
_this addWeapon "Binocular";
waitUntil {"Binocular" in weapons _this};
_this selectWeapon "Binocular";
};

The reason it doesn't work for you is AI doesn't have binocs in inventory when you order it to select it. By making sure it has binocs before hand solves it.

That worked Killzone, thank you!

Bohemia added a subscriber: Bohemia.May 7 2016, 5:42 PM

I'm having a lot of problem arming launchers with the selectWeapon command - I opened a thread on it, but now I've seen this one. I guess it's a related problem right? KillZone - you're a pillar of the Arma3 community - you've been amazingly helpful with so many scripting issues - so, respect where respect is due! Kudos.