acemod / ACE3

Open-source realism mod for Arma 3
https://ace3.acemod.org
Other
1k stars 736 forks source link

weaponsItemsCargo does not return first aid kits or medikits if ace is loaded #8778

Open lawkaita opened 2 years ago

lawkaita commented 2 years ago

Mods (complete and add to the following information):

Description: weaponsItemsCargo does not return medikits or first aid kits if ace is loaded

Steps to reproduce:

Start mission editor, place down a unit, start the game, then in the debug console execute

box = "Box_NATO_Ammo_F" createVehicle (getPos player);
clearMagazineCargo box;
box addWeaponCargo ["FirstAidKit", 1];
box addWeaponCargo ["Medikit", 1];
weaponsItemsCargo box;

The last command will return [].

Expected behavior: With no mods loaded or only CBA loaded, the last command willl return

[["FirstAidKit","","","",[],[],""],["Medikit","","","",[],[],""]]

Where did the issue occur? Editor (Singleplayer)

Additional context: This bug causes CBA_fnc_removeWeaponCargo to delete medikits and first aid kits, since it gets the cargo data with weaponsItemsCargo _container and then does clearWeaponCargoGlobal _container.

severgun commented 2 years ago

This is because of that https://github.com/acemod/ACE3/blob/master/addons/medical_engine/CfgWeapons.hpp and here type = 0; https://github.com/acemod/ACE3/blob/master/addons/medical_treatment/CfgWeapons.hpp Comment say that this is to hide them from arsenal. In BI arsenal scope = 1; can be used for that, but not in ACE one.

Also to be honest, I don't understand why in vanilla medkit returned as weapon item. This is not a scope, bipod, laser or loaded mag. Maybe CBA function should be fixed somehow?

LinkIsGrim commented 2 years ago

Couldn't scopeArsenal = 0 be used to hide them instead? Also, it's not like the items are hidden in the ACE Arsenal. There's not much reason to hide them in the BIS Arsenal.

lawkaita commented 2 years ago

For some reason getWeaponCargo will still list the medikits and first aid kits, so anyone trying to use CBA_fnc_removeWeaponCargo can use that as a temporary workaround.

Dystopian commented 1 year ago

type = 0 solution can also break mission config. In editor double-click any vehicle with FAK/Medikit in inventory (e.g. Quadbike), then press OK and then save mission. The object gets mission config like this:

class CustomAttributes {
    class Attribute0 {
        property="ammoBox";
        expression="[_this,_value] call bis_fnc_initAmmoBox;";
        class Value {
            class data {
                singleType="STRING";
                value="[[[[""FirstAidKit""],[4]],[[],[]],[[],[]],[[],[]]],false]";
            };
        };
    };
};

The value attribute has 4 array elements here: [ [["FirstAidKit"],[4]], [[],[]], [[],[]], [[],[]] ] - weapons, magazines, items and backpacks. And FAK is weapon here.

If load such mission with ACE medical and take such FAK from vehicle it won't be converted to ACE medicals.

If load mission without ACE Medical:

Source: \a3\3den\UI\Attributes\AmmoBox.sqf in attributeSave case checks weapon type: getnumber (configfile >> "cfgweapons" >> _class >> "type") in [4096,131072]. If it's true it becomes an item and goes to value array #2 else to value array #0.

On mission start bis_fnc_initAmmoBox does clearweaponcargoglobal _entity; clearitemcargoglobal _entity; first. Then it does addweaponcargoglobal of items in value array #0 and additemcargoglobal of items in value array #2. addWeaponCargoGlobal silently ignores item type and adds it as weapon.

m1kesk commented 1 year ago
[cursorObject, ["FirstAidKit", "Medikit", "MineDetector", "ToolKit"], false, true] call BIS_fnc_addVirtualItemCargo;

Function does return all objects, but "FirstAidKit" and "Medikit" are missing in cargo.