Usage of CargoSave / Cargofill on storage delete

This commit is contained in:
He-Man 2020-03-03 17:33:04 +01:00
parent 2db08ee0bc
commit 5c1f052c75
2 changed files with 4 additions and 200 deletions

View File

@ -53,109 +53,10 @@ if (_vehSlot != -1 || _storageSlot != "ABORT" || _isTemporary == 1) then{
// if normal storage device dump items on ground.
if (_building isKindOf "Buildable_Storage") then {
// may not be needed but should prevent <null> in DB.
_wepsItemsCargo = weaponsItemsCargo _building;
if (isNil "_wepsItemsCargo") then{
_wepsItemsCargo = [];
};
_magsAmmoCargo = magazinesAmmoCargo _building;
if (isNil "_magsAmmoCargo") then{
_magsAmmoCargo = [];
};
// dump items on ground
_inventory = [
_wepsItemsCargo,
_magsAmmoCargo,
getBackpackCargo _building,
getItemCargo _building
];
_inventory = _building call EPOCH_server_CargoSave;
[_building, _player] call EPOCH_server_save_killedStorage;
deleteVehicle _building;
{
_objType = _forEachIndex;
_objTypes = _x;
_objQty = [];
if (_objType in[2, 3]) then{
_objTypes = _x select 0;
_objQty = _x select 1;
};
{
switch _objType do {
case 0: {
if (_x isEqualType []) then{
_arrCount = count _x;
if (_arrCount >= 4) then{
_gwh addWeaponCargoGlobal[_x deleteAt 0, 1];
_attachments = [];
_wMags = false;
_wMagsArray = [];
// suppressor, laser, optics, magazines(array), bipods
{
// magazines
if (_x isEqualType []) then{
_wMags = true;
_wMagsArray = _x;
}
else {
// attachments
if (_x != "") then{
_attachments pushBack _x;
};
};
} forEach _x;
// add all attachments to vehicle
// TODO replace with adding attachments directly to gun (Arma feature dependant)
{
_gwh addItemCargoGlobal[_x, 1];
} forEach _attachments;
if (_wMags) then{
if (_wMagsArray isEqualType [] && (count _wMagsArray) >= 2) then{
_gwh addMagazineAmmoCargo[_wMagsArray select 0, 1, _wMagsArray select 1];
};
};
};
};
};
case 1: {
if (_x isEqualType []) then{
if ((count _x) == 2) then{
_magazineName = _x select 0;
_magazineSize = _x select 1;
if ((_magazineName isEqualType "STRING") && (_magazineSize isEqualType 0)) then{
_gwh addMagazineAmmoCargo[_magazineName, 1, _magazineSize];
};
};
};
};
case 2: {
if (_x isEqualType "STRING") then{
_qty = _objQty select _forEachIndex;
_gwh addBackpackCargoGlobal[_x, _qty];
};
};
case 3: {
if (_x isEqualType "STRING") then{
_qty = _objQty select _forEachIndex;
_gwh addItemCargoGlobal[_x, _qty];
};
};
};
}forEach _objTypes;
}forEach _inventory;
[_gwh,_inventory] call EPOCH_server_CargoFill;
} else {
// Remove trap object

View File

@ -29,114 +29,17 @@ if (_class isKindOf 'Constructions_lockedstatic_F') then {
_posWH = getPosATL _unit;
// may not be needed but should prevent <null> in DB.
_wepsItemsCargo = weaponsItemsCargo _unit;
if (isNil "_wepsItemsCargo") then {
_wepsItemsCargo = [];
};
_magsAmmoCargo = magazinesAmmoCargo _unit;
if (isNil "_magsAmmoCargo") then {
_magsAmmoCargo = [];
};
// dump items on ground
_inventory = [
_wepsItemsCargo,
_magsAmmoCargo,
getBackpackCargo _unit,
getItemCargo _unit
];
_inventory = _unit call EPOCH_server_CargoSave;
[_unit, _player] call EPOCH_server_save_killedStorage;
deleteVehicle _unit;
_gwh = createVehicle["groundWeaponHolder", _posWH, [], 0, "CAN_COLLIDE"];
_gwh setPosATL _posWH;
[_gwh,_inventory] call EPOCH_server_CargoFill;
_config = 'CfgBaseBuilding' call EPOCH_returnConfig;
_returnItems = getArray(_config >> _class >> "returnOnPack");
{
_gwh addMagazineCargoGlobal _x;
} forEach _returnItems;
{
_objType = _forEachIndex;
_objTypes = _x;
_objQty = [];
if (_objType in[2, 3]) then {
_objTypes = _x select 0;
_objQty = _x select 1;
};
{
switch _objType do {
case 0: {
if (_x isEqualType []) then {
_arrCount = count _x;
if (_arrCount >= 4) then {
_gwh addWeaponCargoGlobal[_x deleteAt 0, 1];
_attachments = [];
_wMags = false;
_wMagsArray = [];
// suppressor, laser, optics, magazines(array), bipods
{
// magazines
if (_x isEqualType []) then{
_wMags = true;
_wMagsArray = _x;
}
else {
// attachments
if (_x != "") then{
_attachments pushBack _x;
};
};
} forEach _x;
// add all attachments to vehicle
// TODO replace with adding attachments directly to gun (Arma feature dependant)
{
_gwh addItemCargoGlobal[_x, 1];
} forEach _attachments;
if (_wMags) then{
if (_wMagsArray isEqualType [] && (count _wMagsArray) >= 2) then{
_gwh addMagazineAmmoCargo[_wMagsArray select 0, 1, _wMagsArray select 1];
};
};
};
};
};
case 1: {
if (_x isEqualType []) then {
if ((count _x) == 2) then {
_magazineName = _x select 0;
_magazineSize = _x select 1;
if ((_magazineName isEqualType "STRING") && (_magazineSize isEqualType 0)) then {
_gwh addMagazineAmmoCargo[_magazineName, 1, _magazineSize];
};
};
};
};
case 2: {
if (_x isEqualType "STRING") then {
_qty = _objQty select _forEachIndex;
_gwh addBackpackCargoGlobal[_x, _qty];
};
};
case 3: {
if (_x isEqualType "STRING") then {
_qty = _objQty select _forEachIndex;
_gwh addItemCargoGlobal[_x, _qty];
};
};
};
}forEach _objTypes;
}forEach _inventory;
};
};