Jump to content
nerexis

Stripping attachments from cargo's weapons

Recommended Posts

I'm using function:

addWeaponCargoGlobal 

to add weapons to cargo container. However some weapons have built-in attachments, and they are added with them to cargo. Is it possible to strip attachments from weapons added by above function?

Share this post


Link to post
Share on other sites

The easiest way is to add base class instead. You can find hierarchy of base classes in config viewer: "Parents: " entry in lower part of screen. Find the latest item in this list that has config entry scope > 0.

Finding base classes by script can be done using BIS_fnc_returnParents.

  • Like 1

Share this post


Link to post
Share on other sites

BI have a handy function just for that purpose.

_container addWeaponCargoGlobal[ _weapon call BIS_fnc_baseWeapon, 1 ];

 

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for good answers, but still not fixed. Problem is that some weapons haven't got parent class without bipod.

Share this post


Link to post
Share on other sites
5 hours ago, nerexis said:

Thanks for good answers, but still not fixed. Problem is that some weapons haven't got parent class without bipod.

I'd assume those would be the weapons that have built in bipod such as some sniper rifles. Those bipods are not detachable. 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, mrcurry said:

I'd assume those would be the weapons that have built in bipod such as some sniper rifles. Those bipods are not detachable. 

You can detach such bipod when its in your inventory primary weapon slot.

Share this post


Link to post
Share on other sites
1 hour ago, nerexis said:

You can detach such bipod when its in your inventory primary weapon slot.

I just tested it with the Lynx and the Zafir both of which have non-detachable bipods. No you can not detach bipods on all weapons. If you want to get rid of those your options are limited to making an addon or a feature request.

 

It's entirely possible BIS_fnc_baseWeapon does not strip away some weapons' bipod. Do you have any examples of weapons where this happens cause that might require a bug report.

Share this post


Link to post
Share on other sites
4 hours ago, mrcurry said:

It's entirely possible BIS_fnc_baseWeapon does not strip away some weapons' bipod. Do you have any examples of weapons where this happens cause that might require a bug report.

I checked the configFile with this code:

(("isClass(_x) && (getNumber(_x >> 'scope') > 0)" configClasses (configFile >> "CfgWeapons")) apply {configName _x}) select {(_x == (_x call BIS_fnc_baseWeapon)) && (isClass(configFile >> "CfgWeapons" >> _x >> "LinkedItems"))}

It finds weapons which return themselves as base weapons with BIS_fnc_baseWeapon and have LinkedItems config entry.

On my system it returned array

["arifle_MX_SW_F","arifle_MX_SW_Black_F","MMG_01_hex_F","MMG_01_tan_F","MMG_02_camo_F","MMG_02_black_F","MMG_02_sand_F","arifle_MX_SW_khk_F","arifle_SPAR_02_blk_F","arifle_SPAR_02_khk_F","arifle_SPAR_02_snd_F"]

For these wepons there's no good way to add them to container without attachments.

One can use unit or game logic intermediary though: add weapon to unit, strip attachments, add weapon to container. Though this is cumbersome, slow, requires more code and additional objects... only makes sense if absense of attachments is critical.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, pedeathtrian said:

I checked the configFile with this code:


(("isClass(_x) && (getNumber(_x >> 'scope') > 0)" configClasses (configFile >> "CfgWeapons")) apply {configName _x}) select {(_x == (_x call BIS_fnc_baseWeapon)) && (isClass(configFile >> "CfgWeapons" >> _x >> "LinkedItems"))}

It finds weapons which return themselves as base weapons with BIS_fnc_baseWeapon and have LinkedItems config entry.

On my system it returned array


["arifle_MX_SW_F","arifle_MX_SW_Black_F","MMG_01_hex_F","MMG_01_tan_F","MMG_02_camo_F","MMG_02_black_F","MMG_02_sand_F","arifle_MX_SW_khk_F","arifle_SPAR_02_blk_F","arifle_SPAR_02_khk_F","arifle_SPAR_02_snd_F"]

For these wepons there's no good way to add them to container without attachments.

One can use unit or game logic intermediary though: add weapon to unit, strip attachments, add weapon to container. Though this is cumbersome, slow, requires more code and additional objects... only makes sense if absense of attachments is critical.

Thanks for great reply. It makes sense in mods like Exile, where I have problem. My situation is, that I'm using weapons mod, where author did create some modded weapons, but even base class is spawning with default bipod attached (like AAF bipod). In Exile mod things are saved to database, and every game restart, they are loaded from database. This situation makes bipods dupe on every 'load' from database, when mission loads things (weapons) to containers. In my opinion there should be function to strip all attachments when adding weapons to cargo. There are functions like that, but not when adding things to cargo, its like missing feature.

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

×