addWeaponWithAttachmentsCargoGlobal

This commit is contained in:
He-Man 2019-08-15 19:47:58 +02:00
parent be2877ec24
commit 2aeef8fa13
5 changed files with 11 additions and 79 deletions

View File

@ -12,7 +12,7 @@
5 onMapSingleClick !="onMapSingleClick '';" !="\"onmapsingleclick\""
5 addMagazine !"addMagazineCargo" !="player addMagazine [_item,_count];" !="player addMagazine \"sledge_swing\";" !="player addMagazine \"Hatchet_swing\";" !="player addMagazine \"stick_swing\";" !="_wh addMagazineAmmoCargo[_item, 1, _count];" !="CBA_fnc_addMagazine" !="\\fnc_addMagazine" !="\"addMagazine" !="vehicle player addMagazineTurret" !="vehicle player addMagazineTurret" !="EPOCH_fnc_addMagazineOverflow" !="_vehicle addMagazineTurret [_ammotype, _turret, _ammocount]" !="_container addMagazineAmmoCargo _x;"
5 addMagazineCargo !="_dogHolder addMagazineCargo [\"RabbitCarcass_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"Pelt_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"Venom_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"SnakeCarcass_EPOCH\", 1]" !="_dogHolder addMagazineCargo [\"ChickenCarcass_EPOCH\", 1]" !="_acceptHolder addMagazineCargo [_wAmmo, 1] ;" !="CBA_fnc_addMagazineCargo" !="\\fnc_addMagazineCargo" !="\"addMagazineCargo" !="cba_fAddMagazineCargo"
5 addItem !="{player addItemToVest _x} forEach _vestItems;" !="player addItem _item;" !="_plyr addItemToVest _missionItem;" !="axeVIP addItemToVest _item;" !="_plyr addItemToVest _missionItem;" !="EPOCH_fnc_addItemOverflow" !="CBA_fnc_addItem" !="\\fnc_addItem" !="\"addItem" !="fnc_addItemCargo" !="wH = _nearByHolder select 0;\n};\nif !(isNull _wh) then {\n_wh addItemCargoGlobal [_item,1];\n};\n};\n};\n\n_fnc_findItemInContainers = " !="player addItem 'ItemRope';" !="_container addItemCargoGlobal [_x,1];"
5 addItem !="{player addItemToVest _x} forEach _vestItems;" !="player addItem _item;" !="_plyr addItemToVest _missionItem;" !="axeVIP addItemToVest _item;" !="_plyr addItemToVest _missionItem;" !="EPOCH_fnc_addItemOverflow" !="CBA_fnc_addItem" !="\\fnc_addItem" !="\"addItem" !="fnc_addItemCargo" !="wH = _nearByHolder select 0;\n};\nif !(isNull _wh) then {\n_wh addItemCargoGlobal [_item,1];\n};\n};\n};\n\n_fnc_findItemInContainers = " !="player addItem 'ItemRope';" !="_container addItemCargoGlobal [_x,1];" !="_container addItemCargoGlobal [_type,_cnt];"
5 addBackPack !="fnc_addBackpackCargo" !="_newPlyr addBackpack _bpack;"
5 addMissionEventHandler !="CBA_clientID = [0, 2] select isMultiplayer;\naddMissionEventHandler [\"PlayerConnected\", {\nparams [\"_id\", \"_uid\", \"_name\"" !="addMissionEventHandler [\"EachFrame\", {call cba_common_fnc_onFrame}];" !="addMissionEventHandler [\"HandleDisconnect\"," !="addMissionEventHandler [\"Loaded\"," !="addMissionEventHandler ['Draw3D',_var + \"call Epoch_gui3DCooldownEH;\"];" !="addMissionEventHandler ['Draw3D',_var + \"call epoch_gui3dModelPosEH;\"];" !="addMissionEventHandler ['Draw3D',_var + \"call epoch_gui3dWorldPosEH;\"];" !="addMissionEventHandler [\n\"ended\",\n{\n\nBIS_fnc_missionHandlers_end = _this;" !="private _ehId = addMissionEventHandler [_event select [2], _code];" !="addMissionEventHandler [\"PlayerViewChanged\", {if (cameraView isEqualTo \"GROUP\") then {vehicle player switchCamera \"Internal\";};}];" !="addMissionEventHandler [\"EachFrame\",\n{\n;\n\n\nmissionNamespace setVariable [\"BIS_"
5 removeMissionEventHandler !="removeMissionEventHandler [\"Draw3D\", _id];" !="removeMissionEventHandler [_event select [2], _x select 1];"

View File

@ -53,19 +53,7 @@ if !(_bpack isequalto "") then {
}
else {
if ((_x select 0) isequaltype []) then {
_x params ["_arr","_cnt"];
_type = _arr deleteat 0;
_container addWeaponcargoglobal [_type,_cnt];
{
if !(_x isequalto "" || _x isequalto []) then {
if (_x isequaltype []) then {
_container addMagazineAmmoCargo [_x select 0,1,_x select 1];
}
else {
_container addItemCargoGlobal [_x,1];
};
};
} foreach _arr;
_container addWeaponWithAttachmentsCargoGlobal _x;
}
else {
_x params [["_type",""],["_cnt",1]];

View File

@ -49,19 +49,7 @@ if !(_bpack isequalto "") then {
}
else {
if ((_x select 0) isequaltype []) then {
_x params ["_arr","_cnt"];
_type = _arr deleteat 0;
_container addWeaponcargoglobal [_type,_cnt];
{
if !(_x isequalto "" || _x isequalto []) then {
if (_x isequaltype []) then {
_container addMagazineAmmoCargo [_x select 0,1,_x select 1];
}
else {
_container addItemCargoGlobal [_x,1];
};
};
} foreach _arr;
_container addWeaponWithAttachmentsCargoGlobal _x;
}
else {
_x params [["_type",""],["_cnt",1]];

View File

@ -38,34 +38,11 @@ params [["_vehicle",objnull],["_items",[]]];
// Weapon cargo
case 0: {
if (_x isEqualType []) then {
if ((count _x) >= 4) then {
_vehicle 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)
{
_vehicle addItemCargoGlobal[_x, 1];
} forEach _attachments;
if (_wMags) then{
if (_wMagsArray isEqualType [] && (count _wMagsArray) >= 2) then{
_vehicle addMagazineAmmoCargo[_wMagsArray select 0, 1, _wMagsArray select 1];
};
};
if ((count _x) == 2) then {
_vehicle addWeaponWithAttachmentsCargoGlobal _x;
}
else {
_vehicle addWeaponWithAttachmentsCargoGlobal [_x,1];
};
};
};

View File

@ -25,8 +25,8 @@
private [
"_wepsItemsCargo","_magsAmmoCargo","_containers","_allContainers","_cargo","_magsAmmoCargox","_wepsItemsCargox","_magsAmmoCargoMinimized","_cargoIndex","_wepsItemsCargoNormalized","_selectedWeaponComponents","_selectedWeapon",
"_weaponComponents","_weapon","_newComponents","_inventory","_ItemCargo","_ItemCargox"];
"_wepsItemsCargo","_magsAmmoCargo","_containers","_allContainers","_cargo","_magsAmmoCargox","_wepsItemsCargox","_magsAmmoCargoMinimized","_cargoIndex",
"_inventory","_ItemCargo","_ItemCargox"];
params [["_vehicle",objnull],["_unpack",true]];
// may not be needed but should prevent <null> in DB.
_wepsItemsCargo = weaponsItemsCargo _vehicle;
@ -81,29 +81,8 @@ _magsAmmoCargoMinimized = [[],[]];
(_magsAmmoCargoMinimized select 1) pushBack (_x select 1);
} forEach _magsAmmoCargo;
// convert and normalize
_wepsItemsCargoNormalized = [];
{
_selectedWeaponComponents = _x;
_selectedWeapon = _selectedWeaponComponents deleteAt 0;
// find actual weapon components - todo this BIS call maybe slow
_weaponComponents = _selectedWeapon call BIS_fnc_weaponComponents;
// base weapon (without attachments)
_weapon = _weaponComponents deleteAt 0;
_newComponents = [];
{
// remove attachments that are already linked via config
if (_x isEqualType "" && {(tolower _x) in _weaponComponents}) then {
_newComponents pushBack "";
} else {
_newComponents pushBack _x;
};
} forEach _selectedWeaponComponents;
_wepsItemsCargoNormalized pushBack ([_selectedWeapon] + _newComponents);
} forEach _wepsItemsCargo;
_inventory = [
_wepsItemsCargoNormalized,
_wepsItemsCargo,
_magsAmmoCargoMinimized,
getBackpackCargo _vehicle,
_ItemCargo,