Page MenuHomeFeedback Tracker

Impementation of setUnitLoadout causes incompatibilities with vanilla and mod features
New, NormalPublic


The implementation of setUnitLoadout is not optimal and causes a lot of incompatibilities with mods even with vanilla features. Take the following scenario:

  1. Have a unit with a Mk6 Mortar Tube as backpack, which has already been used so it is not full of ammo.
  2. Change the units loadout (maybe change the vest or the weapon) with setUnitLoadout giving nil as value for the backpack so the unit keeps its backpack.
  3. In this case the ammo of the mortar will be replenished, even though the backpack was not supposed to be modified.

Why does this happen?
The execution of setUnitLoadout deletes the unit’s previous loadout completely and re-adds every item and container. This means every “special state” (textures, variables, attached objects) the previous container had (in this example the backpackContainer) will be lost. Lots of mods and Arma vanilla itself use the backpack to store stuff like static weapon ammo, TFAR frequencies, ACE gunbag weapons, textures from various mods to name just a few. Others have a reference to the backpackContainer in some form (as far as I know ACRE iterates all weaponHolders to look for its backpack radios to check whether they still exist).
This problem makes setUnitLoadout unusable assuming you want to stay compatible with big mods like ACE, TFAR, ACRE or even the ingame functionality. This is unfortunate, considering that setUnitLoadout is the ONLY command which allows scripters to add weapons with attachments to a container. The only workaround hack I know would be letting an AI drop its weapon into the container.

Is there a solution?
Change the implementation of setUnitLoadout so that it doesn’t change parts of the loadout for which no new values were provided. This should include changing the backpack content but not the backpack itself.
Something like this: player setUnitLoadout [nil,nil,nil,nil,nil,[nil,["30Rnd_65x39_caseless_mag",2,30]],nil,nil,nil,nil]; should only modify the content of the backpack. Not the backpackContainer or anything else.

On a personal note:

This is infuriating... I was really looking forward to use setUnitLoadout in one of my mods to fix combabilities and just make the code a lot sleeker, just to realize after finally having time for the refactoring that this doesn’t fix any of my problems.
How can it be that the inventory system was enhanced with things like attachments over five years ago but scripters still cannot utilize basic functions to exploit those enhancements to add more functionality to the game?
No exposed functionality to add weapons with attachments to containers.
No exposed functionality to remove single backpacks from containers.
No exposed functionality for a lot of just basic things in the inventory system.


Operating System
Windows 10 x64
Steps To Reproduce
  1. Equip player with partial full Mk6 Mortar Tube as backpack.
  1. Execute the following (or similar)
private _l = getUnitLoadout player;
// player carries a partial full Mk6 Tube
_l set [5, nil]; // 5 index of backpack
player setUnitLoadout _l; 
// folded tube is now full of ammo
  1. Check ammo of mortar

Event Timeline

DerZade created this task.Nov 4 2018, 1:05 PM
DerZade updated the task description. (Show Details)Nov 5 2018, 12:33 PM