From 47a7b156b235894342cdc90aa7e7bb28f0f66863 Mon Sep 17 00:00:00 2001 From: Salbei Date: Thu, 16 Jun 2022 01:07:06 +0200 Subject: [PATCH 1/6] first work on it --- addons/getLoadoutsFromUnits/XEH_PREP.hpp | 1 + .../functions/fnc_convertToString.sqf | 4 +- .../functions/fnc_createBaseClass.sqf | 437 ++++++++++++++---- .../functions/fnc_getClothes.sqf | 4 +- .../functions/fnc_getLoadoutAndFormat.sqf | 6 +- .../functions/fnc_getWeapon.sqf | 26 +- .../functions/fnc_onBtnOk.sqf | 2 +- .../functions/fnc_returnBaseItem.sqf | 26 ++ 8 files changed, 399 insertions(+), 107 deletions(-) create mode 100644 addons/getLoadoutsFromUnits/functions/fnc_returnBaseItem.sqf diff --git a/addons/getLoadoutsFromUnits/XEH_PREP.hpp b/addons/getLoadoutsFromUnits/XEH_PREP.hpp index 82fc396..5296715 100644 --- a/addons/getLoadoutsFromUnits/XEH_PREP.hpp +++ b/addons/getLoadoutsFromUnits/XEH_PREP.hpp @@ -10,5 +10,6 @@ PREP(getLoadoutAndFormat); PREP(getWeapon); PREP(onBtnOk); PREP(onLoad); +PREP(returnBaseItem); PREP(vanillaCivDefactionizer); PREP(vanillaMilitaryDefactionizer); \ No newline at end of file diff --git a/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf b/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf index 1ec0bce..1dca5b1 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf @@ -2,9 +2,9 @@ params ["_tabs", "_item", "_type"]; -private _return = nil; +private _return = objNull; if (_item isEqualType "") then { _return = _tabs + format ["%1 = ""%2"";", _type, _item]; }; -_return \ No newline at end of file +_return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf index 556e61e..92bc647 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf @@ -14,103 +14,354 @@ private _baseLoadout = [ [], //Binocular ["", "", "", "", "", ""] //Items (Map, Radio, etc) ]; -private _soldierLoadout = [_loadoutHash, "Soldier_F"] call CBA_fnc_hashGet; -if (_soldiersLoadout isEqualTo []) exitWith { _baseLoadout }; -_types deleteAt (_types find "Soldier_F"); +private _uniforms = []; +private _vests = []; +private _backpacks = []; +private _headgears = []; +private _primaryWeapons = []; +private _primaryWeaponMagazines = []; +private _primaryWeaponMuzzles = []; +private _primaryWeaponOptics = []; +private _primaryWeaponPointers = []; +private _primaryWeaponUnderbarrels = []; +private _primaryWeaponUnderbarrelMagazines = []; +private _secondaryWeapons = []; +private _secondaryWeaponMagazines = []; +private _secondaryWeaponMuzzles = []; +private _secondaryWeaponOpticss = []; +private _secondaryWeaponPointers = []; +private _secondaryWeaponUnderbarrels = []; +private _secondaryWeaponUnderbarrelMagazines = []; +private _handgunWeapons = []; +private _handgunWeaponMagazines = []; +private _handgunWeaponMuzzles = []; +private _handgunWeaponOpticss = []; +private _handgunWeaponPointers = []; +private _handgunWeaponUnderbarrels = []; +private _handgunWeaponUnderbarrelMagazines = []; +private _goggless = []; +private _nvgoggless = []; +private _binocularss = []; +private _maps = []; +private _gpss = []; +private _compasss = []; +private _watchs = []; +private _radios = []; { - private _type = _x; - private _loadout = [_loadoutHash, _type] call CBA_fnc_hashGet; - - //Compare Weapons - { - private _loadoutWeapon = _x; - private _weaponArraySoldier = _soldierLoadout select _forEachIndex; - private _baseLoadoutWeapons = _baseLoadout select _forEachIndex; - - if (_loadoutWeapon isNotEqualTo []) then { - { - if ( - (_x isNotEqualTo "" && {_x isNotEqualTo []}) - && {_weaponArraySoldier isNotEqualTo []} - && {_x isEqualTo (_weaponArraySoldier select _forEachIndex)} - ) then { - _baseLoadoutWeapons set [_forEachIndex, _x]; - _weaponArraySoldier set [_forEachIndex, ""]; - _loadoutWeapon set [_forEachIndex, ""]; - }; - }forEach _loadoutWeapon; - }; - }forEach [ - _loadout select 0, - _loadout select 1, - _loadout select 2 - ]; - - //Compare Clothes - { - private _string = _x; - private _compare = _soldierLoadout select (_forEachIndex +3); - private _array = []; - private _array2 = []; - - if (_string isEqualtype []) then { - _array = _string; - _array2 = _compare; - - _string = _array select 0; - _compare = _array2 select 0; - }; - - if (_string isNotEqualTo "" && {_string isEqualTo _compare}) then { - private _baseArraySet = _string; - - if (_array isNotEqualTo []) then { - _baseArraySet = [_string]; - - _array set [0, ""]; - _string = _array; - - _array2 set [0, ""]; - _compare = _array; - }; - - _baseLoadout set [(_forEachIndex +3), _baseArraySet]; - _soldierLoadout set [(_forEachIndex +3), _compare]; - _loadout set [(_forEachIndex +3), _string]; - }; - }forEach [ - _loadout select 3, - _loadout select 4, - _loadout select 5, - _loadout select 6, - _loadout select 7, - _loadout select 8 - ]; - - //Compare Items - private _tools = _loadout select 9; - private _soldierTools = _soldierLoadout select 9; - private _baseTools = _baseLoadout select 9; - { - if (_x isNotEqualTo "" && {_x isEqualTo (_soldierTools select _forEachIndex)}) then { - _baseTools set [_forEachIndex, _x]; - _tools set [_forEachIndex, ""]; - _soldierTools set [_forEachIndex, ""]; - }; - }forEach _tools; - - _loadout set [9, _tools]; - _soldierLoadout set [9, _soldierTools]; - _baseLoadout set [9, _baseTools]; - - [_loadoutHash, _type, _loadout] call CBA_fnc_hashSet; + private _loadout = [_loadoutHash, _x] call CBA_fnc_hashGet; + + if (_loadout isNotEqualTo []) then { + _loadout params [ + ["_primaryWeapon", []], + ["_secondaryWeapon", []], + ["_handgunWeapon", []], + ["_uniform", []], + ["_vest", []], + ["_backpack", []], + ["_headgear", ""], + ["_googles", ""], + ["_binocluar", []], + ["_items", []] + ]; + + if (_uniform isNotEqualTo []) then { + _uniforms pushBack (_uniform select 0); + }; + + if (_vest isNotEqualTo []) then { + _vests pushBack (_vest select 0); + }; + + if (_backpack isNotEqualTo []) then { + _backpacks pushBack (_backpack select 0); + }; + + _headgears pushBack _headgear; + + if (_primaryWeapon isNotEqualTo []) then { + _primaryWeapons pushBack (_primaryWeapon select 0); + _primaryWeaponMuzzles pushBack (_primaryWeapon select 1); + _primaryWeaponPointers pushBack (_primaryWeapon select 2); + _primaryWeaponOptics pushBack (_primaryWeapon select 3); + _primaryWeaponUnderbarrels pushBack (_primaryWeapon select 6); + + if ((_primaryWeapon select 4) isNotEqualTo []) then { + _primaryWeaponMagazines pushBack (_primaryWeapon select 4 select 0); + }; + + if ((_primaryWeapon select 4) isNotEqualTo []) then { + _primaryWeaponUnderbarrelMagazines pushBack (_primaryWeapon select 5 select 0); + }; + }; + + if (_secondaryWeapon isNotEqualTo []) then { + _secondaryWeapons pushBack (_secondaryWeapon select 0); + _secondaryWeaponMuzzles pushBack (_secondaryWeapon select 1); + _secondaryWeaponPointers pushBack (_secondaryWeapon select 2); + _secondaryWeaponOptics pushBack (_secondaryWeapon select 3); + _secondaryWeaponUnderbarrels pushBack (_secondaryWeapon select 6); + + if ((_secondaryWeapon select 4) isNotEqualTo []) then { + _secondaryWeaponMagazines pushBack (_secondaryWeapon select 4 select 0); + }; + + if ((_secondaryWeapon select 4) isNotEqualTo []) then { + _secondaryWeaponUnderbarrelMagazines pushBack (_secondaryWeapon select 5 select 0); + }; + }; + + if (_handgunWeapon isNotEqualTo []) then { + _handgunWeapons pushBack (_handgunWeapon select 0); + _handgunWeaponMuzzles pushBack (_handgunWeapon select 1); + _handgunWeaponPointers pushBack (_handgunWeapon select 2); + _handgunWeaponOptics pushBack (_handgunWeapon select 3); + _handgunWeaponUnderbarrels pushBack (_handgunWeapon select 6); + + if ((_handgunWeapon select 4) isNotEqualTo []) then { + _handgunWeaponMagazines pushBack (_handgunWeapon select 4 select 0); + }; + + if ((_handgunWeapon select 4) isNotEqualTo []) then { + _handgunWeaponUnderbarrelMagazines pushBack (_handgunWeapon select 5 select 0); + }; + }; + + if (_binocular isNotEqualTo []) then { + _binocularss pushBack (_binocular select 0); + }; + + _goggless pushBack _googles; + + if (_items isNotEqualTo []) then { + _maps pushBack (_items select 0); + _gpss pushBack (_items select 1); + _radios pushBack (_items select 2); + _compasss pushBack (_items select 3); + _watchs pushBack (_items select 4); + _nvgoggless pushBack (_items select 5); + }; + }; }forEach _types; -[_loadoutHash, "Soldier_F", _soldierLoadout] call CBA_fnc_hashGet; +private _uniform = [_uniforms] call FUNC(returnBaseItem); +private _vest = [_vests] call FUNC(returnBaseItem); +private _backpack = [_backpacks] call FUNC(returnBaseItem); +private _headgear = [_headgears] call FUNC(returnBaseItem); +private _primaryWeapon = [_primaryWeapons] call FUNC(returnBaseItem); +private _primaryWeaponMagazine = [_primaryWeaponMagazines] call FUNC(returnBaseItem); +private _primaryWeaponMuzzle = [_primaryWeaponMuzzles] call FUNC(returnBaseItem); +private _primaryWeaponOptic = [_primaryWeaponOptics] call FUNC(returnBaseItem); +private _primaryWeaponPointer = [_primaryWeaponPointers] call FUNC(returnBaseItem); +private _primaryWeaponUnderbarrel = [_primaryWeaponUnderbarrels] call FUNC(returnBaseItem); +private _primaryWeaponUnderbarrelMagazine = [_primaryWeaponUnderbarrelMagazines] call FUNC(returnBaseItem); +private _secondaryWeapon = [_secondaryWeapons] call FUNC(returnBaseItem); +private _secondaryWeaponMagazine = [_secondaryWeaponMagazines] call FUNC(returnBaseItem); +private _secondaryWeaponMuzzle = [_secondaryWeaponMuzzles] call FUNC(returnBaseItem); +private _secondaryWeaponOptic = [_secondaryWeaponOptics] call FUNC(returnBaseItem); +private _secondaryWeaponPointer = [_secondaryWeaponPointers] call FUNC(returnBaseItem); +private _secondaryWeaponUnderbarrel = [_secondaryWeaponUnderbarrels] call FUNC(returnBaseItem); +private _secondaryWeaponUnderbarrelMagazine = [_secondaryWeaponUnderbarrelMagazines] call FUNC(returnBaseItem); +private _handgunWeapon = [_handgunWeapons] call FUNC(returnBaseItem); +private _handgunWeaponMagazine = [_handgunWeaponMagazines] call FUNC(returnBaseItem); +private _handgunWeaponMuzzle = [_handgunWeaponMuzzles] call FUNC(returnBaseItem); +private _handgunWeaponOptics = [_handgunWeaponOpticss] call FUNC(returnBaseItem); +private _handgunWeaponPointer = [_handgunWeaponPointers] call FUNC(returnBaseItem); +private _handgunWeaponUnderbarrel = [_handgunWeaponUnderbarrels] call FUNC(returnBaseItem); +private _handgunWeaponUnderbarrelMagazine = [_handgunWeaponUnderbarrelMagazines] call FUNC(returnBaseItem); +private _goggles = [_goggless] call FUNC(returnBaseItem); +private _nvgoggles = [_nvgoggless] call FUNC(returnBaseItem); +private _binoculars = [_binocularss] call FUNC(returnBaseItem); +private _map = [_maps] call FUNC(returnBaseItem); +private _gps = [_gpss] call FUNC(returnBaseItem); +private _compass = [_compasss] call FUNC(returnBaseItem); +private _watch = [_watchs] call FUNC(returnBaseItem); +private _radio = [_radios] call FUNC(returnBaseItem); + +_baseLoadout set [0, [_primaryWeapon, _primaryWeaponMuzzle, _primaryWeaponPointer, _primaryWeaponOptic, [_primaryWeaponMagazine], [_primaryWeaponUnderbarrelMagazine], _primaryWeaponUnderbarrel]]; +_baseLoadout set [1, [_secondaryWeapon, _secondaryWeaponMuzzle, _secondaryWeaponPointer, _secondaryWeaponOptic, [_secondaryWeaponMagazine], [_secondaryWeaponUnderbarrelMagazine], _secondaryWeaponUnderbarrel]]; +_baseLoadout set [2, [_handgunWeapon, _handgunWeaponMuzzle, _handgunWeaponPointer, _handgunWeaponOptic, [_handgunWeaponMagazine], [_handgunWeaponUnderbarrelMagazine], _handgunWeaponUnderbarrel]]; +_baseLoadout set [3, [_uniform]]; +_baseLoadout set [4, [_vest]]; +_baseLoadout set [5, [_backpack]]; +_baseLoadout set [6, _headgear]; +_baseLoadout set [7, _goggles]; +_baseLoadout set [8, [_binoculars]]; +_baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; + +{ + private _loadout = [_loadoutHash, _x] call CBA_fnc_hashGet; + + if (_loadout isNotEqualTo []) then { + _loadout params [ + ["_primaryWeaponClass", []], + ["_secondaryWeaponClass", []], + ["_handgunWeaponClass", []], + ["_uniformClass", []], + ["_vestClass", []], + ["_backpackClass", []], + ["_headgearClass", ""], + ["_googlesClass", ""], + ["_binocluarClass", []], + ["_itemsClass", []] + ]; + + if (_primaryWeaponClass isNotEqualTo []) then { + if ((_primaryWeaponClass select 0) isEqualTo _primaryWeapon) then { + _primaryWeaponClass set [0, objNull]; + }; + if ((_primaryWeaponClass select 1) isEqualTo _primaryWeaponMuzzle) then { + _primaryWeaponClass set [0, objNull]; + }; + if ((_primaryWeaponClass select 2) isEqualTo _primaryWeaponPointer) then { + _primaryWeaponClass set [0, objNull]; + }; + if ((_primaryWeaponClass select 3) isEqualTo _primaryWeaponOptic) then { + _primaryWeaponClass set [0, objNull]; + }; + + private _mag = _primaryWeaponClass select 4; + if ((_mag select 0) isEqualTo _primaryWeaponMagazine) then { + _mag set [0, objNull]; + _primaryWeaponClass set [0, _mag]; + }; + + private _magU = _primaryWeaponClass select 5; + if ((_magU select 0) isEqualTo _primaryWeaponUnderbarrelMagazine) then { + _magU set [0, objNull]; + _primaryWeaponClass set [0, _magU]; + }; + + if ((_primaryWeaponClass select 6) isEqualTo _primaryWeaponUnderbarrel) then { + _primaryWeaponClass set [0, objNull]; + }; + }; + + if (_secondaryWeaponClass isNotEqualTo []) then { + if ((_secondaryWeaponClass select 0) isEqualTo _secondaryWeapon) then { + _secondaryWeaponClass set [0, objNull]; + }; + if ((_secondaryWeaponClass select 1) isEqualTo _secondaryWeaponMuzzle) then { + _secondaryWeaponClass set [0, objNull]; + }; + if ((_secondaryWeaponClass select 2) isEqualTo _secondaryWeaponPointer) then { + _secondaryWeaponClass set [0, objNull]; + }; + if ((_secondaryWeaponClass select 3) isEqualTo _secondaryWeaponOptic) then { + _secondaryWeaponClass set [0, objNull]; + }; + + private _mag = _secondaryWeaponClass select 4; + if ((_mag select 0) isEqualTo _secondaryWeaponMagazine) then { + _mag set [0, objNull]; + _secondaryWeaponClass set [0, _mag]; + }; + + private _magU = _secondaryWeaponClass select 5; + if ((_magU select 0) isEqualTo _secondaryWeaponUnderbarrelMagazine) then { + _magU set [0, objNull]; + _secondaryWeaponClass set [0, _magU]; + }; + + if ((_secondaryWeaponClass select 6) isEqualTo _secondaryWeaponUnderbarrel) then { + _secondaryWeaponClass set [0, objNull]; + }; + }; + + if (_handgunWeaponClass isNotEqualTo []) then { + if ((_handgunWeaponClass select 0) isEqualTo _handgunWeapon) then { + _handgunWeaponClass set [0, objNull]; + }; + if ((_handgunWeaponClass select 1) isEqualTo _handgunWeaponMuzzle) then { + _handgunWeaponClass set [0, objNull]; + }; + if ((_handgunWeaponClass select 2) isEqualTo _handgunWeaponPointer) then { + _handgunWeaponClass set [0, objNull]; + }; + if ((_handgunWeaponClass select 3) isEqualTo _handgunWeaponOptic) then { + _handgunWeaponClass set [0, objNull]; + }; + + private _mag = _handgunWeaponClass select 4; + if ((_mag select 0) isEqualTo _handgunWeaponMagazine) then { + _mag set [0, objNull]; + _handgunWeaponClass set [0, _mag]; + }; + + private _magU = _handgunWeaponClass select 5; + if ((_magU select 0) isEqualTo _handgunWeaponUnderbarrelMagazine) then { + _magU set [0, objNull]; + _handgunWeaponClass set [0, _magU]; + }; + + if ((_handgunWeaponClass select 6) isEqualTo _handgunWeaponUnderbarrel) then { + _handgunWeaponClass set [0, objNull]; + }; + }; + + if (_uniformClass isNotEqualTo []) then { + if (_uniformClass select 0 isEqualTo _uniform) then { + _uniformClass set [0, objNull]; + }; + }; + + if (_vestClass isNotEqualTo []) then { + if (_vestClass select 0 isEqualTo _vest) then { + _vestClass set [0, objNull]; + }; + }; + + if (_backpackClass isNotEqualTo []) then { + if (_backpackClass select 0 isEqualTo _backpack) then { + _backpackClass set [0, objNull]; + }; + }; + + if (_headgearClass isNotEqualTo "") then { + if (_headgearClass isEqualTo _headgear) then { + _headgearClass = objNull; + }; + }; + + if (_gogglesClass isNotEqualTo "") then { + if (_gogglesClass isEqualTo _goggles) then { + _gogglesClass = objNull; + }; + }; + + if (_binocularClass isNotEqualTo []) then { + if (_binocularClass select 0 isEqualTo _binocular) then { + _binocularClass set [0, objNull]; + }; + }; + + if (_itemsClass isNotEqualTo []) then { + if ((_itemsClass select 0) isEqualTo _map) then { + _itemsClass set [0, objNull]; + }; + if ((_itemsClass select 1) isEqualTo _gps) then { + _itemsClass set [1, objNull]; + }; + if ((_itemsClass select 2) isEqualTo _radio) then { + _itemsClass set [2, objNull]; + }; + if ((_itemsClass select 3) isEqualTo _compass) then { + _itemsClass set [3, objNull]; + }; + if ((_itemsClass select 4) isEqualTo _watch) then { + _itemsClass set [4, objNull]; + }; + if ((_itemsClass select 5) isEqualTo _nvgoggles) then { + _itemsClass set [5, objNull]; + }; + }; + + + [_loadoutHash, _x, [_primaryWeaponClass, _secondaryWeaponClass, _handgunWeaponClass, _uniformClass, _vestClass, _backpackClass, _headgearClass, _googlesClass, _binocluarClass, _itemsClass]] call CBA_fnc_hashSet; + }; +}forEach _types; -_types pushBack "Soldier_F"; -reverse _types; +diag_log str _baseLoadout; -_baseLoadout \ No newline at end of file +_baseLoadout diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf index 4a43f78..ac79128 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf @@ -2,8 +2,8 @@ params ["_clothes"]; -private _return = ""; -if !(_clothes isEqualTo []) then { +private _return = objNull; +if (_clothes isNotEqualTo []) then { _return = _clothes select 0; }; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index f4857a9..9fb4e96 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -36,7 +36,7 @@ private _binocular = if !(_loadout select 8 isEqualTo []) then { }; private _radio = _loadout select 9 select 2; -if (isText (configFile >> "CfgWeapons" >> _radio >> "tf_parent")) then { +if (!isNull _radio && {isText (configFile >> "CfgWeapons" >> _radio >> "tf_parent")}) then { _radio = getText (configFile >> "CfgWeapons" >> _radio >> "tf_parent"); }; @@ -85,4 +85,8 @@ if (!(_loadout select 5 isEqualTo []) && {!(_loadout select 5 select 1 isEqualTo _return pushBack (_tab + _tab + "};"); +diag_log str _return; +_return = _return - [objNull]; +diag_log str _return; + _return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf index c566bdb..8576923 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf @@ -6,33 +6,43 @@ private _return = []; if !(_weaponArray isEqualTo []) then { _weaponArray params [["_weapon", ""], ["_muzzle", ""], ["_pointer", ""], ["_optics", ""], ["_magazine", []], ["_underbarrelMagazin", []], ["_underbarrel", ""]]; - if (_weapon != "") then { + if (!isNull _weapon) then { _return pushBack (_tripleTab + format ["%1Weapon = ""%2"";", _name, _weapon]); - if ((_magazine isEqualType []) && {_magazine isNotEqualTo []} && {(_magazine select 0) != ""}) then { + if ((_magazine isEqualType []) && {_magazine isNotEqualTo []}) then { _return pushBack( _tripleTab + format ["%1WeaponMagazine = ""%2"";", _name, _magazine select 0]); }; - if (_optics != "") then { + if (!isNull _optics) then { _return pushBack (_tripleTab + format ["%1WeaponOptics = ""%2"";", _name, _optics]); }; - if (_pointer != "") then { + if (!isNull _pointer) then { _return pushBack (_tripleTab + format ["%1WeaponPointer = ""%2"";", _name, _pointer]); }; - if (_muzzle != "") then { + if (!isNull _muzzle) then { _return pushBack (_tripleTab + format ["%1WeaponMuzzle = ""%2"";", _name, _muzzle]); }; - if (_underbarrel != "") then { + if (!isNull _underbarrel) then { _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrel]); }; - if ((_underbarrelMagazin isEqualType []) && {_underbarrelMagazin isNotEqualTo []} && {(_underbarrelMagazin select 0) != ""})then { - _return pushBack (_tripleTab + format ["%1WeaponUnderbarrelMagazine = ""%2"";", _name, _underbarrelMagazin select 0]); + if ((_underbarrelMagazin isEqualType []) && {_underbarrelMagazin isNotEqualTo []})then { + _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrelMagazin]); }; }; +} else { + _return append [ + _tripleTab + format ["%1Weapon = """";", _name], + _tripleTab + format ["%1WeaponMagazine = """";", _name], + _tripleTab + format ["%1WeaponOptics = """";", _name], + _tripleTab + format ["%1WeaponPointer = """";", _name], + _tripleTab + format ["%1WeaponMuzzle = """";", _name], + _tripleTab + format ["%1WeaponUnderbarrel = """";", _name], + _tripleTab + format ["%1WeaponUnderbarrel = """";", _name] + ]; }; _return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf b/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf index 733a952..528ce81 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf @@ -50,7 +50,7 @@ _name = [_name] call BIS_fnc_filterString; _structuredText pushBack format ["class %1 {", _name]; _structuredText pushBack (_tab + "class AllUnits {"); -if ("Soldier_F" in _types) then { +if (count _types > 2) then { private _baseLoadout = [_loadoutHash, _types] call FUNC(createBaseClass); _structuredText append ([_baseLoadout, _tab] call FUNC(getBaseLoadoutAndFormat)); diff --git a/addons/getLoadoutsFromUnits/functions/fnc_returnBaseItem.sqf b/addons/getLoadoutsFromUnits/functions/fnc_returnBaseItem.sqf new file mode 100644 index 0000000..336490f --- /dev/null +++ b/addons/getLoadoutsFromUnits/functions/fnc_returnBaseItem.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" + +params ["_array"]; + +private _return = ""; + +if (_array isNotEqualTo []) then { + private _maxCount = 2; + private _allreadyCounted = []; + + { + if !(_x in _allreadyCounted) then { + private _selectedItem = _x; + private _count = {_x == _selectedItem} count _array; + + if (_count > _maxCount) then { + _maxCount = _count; + _return = _selectedItem; + }; + + _allreadyCounted pushBack _selectedItem; + }; + }forEach _array; +}; + +_return \ No newline at end of file From d303366d816a9edaf73106195ed3fa4349c170bb Mon Sep 17 00:00:00 2001 From: Salbei Date: Thu, 16 Jun 2022 19:35:43 +0200 Subject: [PATCH 2/6] some more work --- .../functions/fnc_convertToString.sqf | 4 +- .../functions/fnc_createBaseClass.sqf | 80 +++++++++---------- .../functions/fnc_getClothes.sqf | 6 +- .../functions/fnc_getLoadoutAndFormat.sqf | 6 +- .../functions/fnc_getWeapon.sqf | 10 +-- 5 files changed, 52 insertions(+), 54 deletions(-) diff --git a/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf b/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf index 1dca5b1..289cbf7 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_convertToString.sqf @@ -2,8 +2,8 @@ params ["_tabs", "_item", "_type"]; -private _return = objNull; -if (_item isEqualType "") then { +private _return = nil; +if (!isNil "_item" && {_item isEqualType ""}) then { _return = _tabs + format ["%1 = ""%2"";", _type, _item]; }; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf index 92bc647..973e6f8 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf @@ -209,151 +209,151 @@ _baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; if (_primaryWeaponClass isNotEqualTo []) then { if ((_primaryWeaponClass select 0) isEqualTo _primaryWeapon) then { - _primaryWeaponClass set [0, objNull]; + _primaryWeaponClass set [0, nil]; }; if ((_primaryWeaponClass select 1) isEqualTo _primaryWeaponMuzzle) then { - _primaryWeaponClass set [0, objNull]; + _primaryWeaponClass set [1, nil]; }; if ((_primaryWeaponClass select 2) isEqualTo _primaryWeaponPointer) then { - _primaryWeaponClass set [0, objNull]; + _primaryWeaponClass set [2, nil]; }; if ((_primaryWeaponClass select 3) isEqualTo _primaryWeaponOptic) then { - _primaryWeaponClass set [0, objNull]; + _primaryWeaponClass set [3, nil]; }; private _mag = _primaryWeaponClass select 4; if ((_mag select 0) isEqualTo _primaryWeaponMagazine) then { - _mag set [0, objNull]; - _primaryWeaponClass set [0, _mag]; + _mag set [0, nil]; + _primaryWeaponClass set [4, _mag]; }; private _magU = _primaryWeaponClass select 5; if ((_magU select 0) isEqualTo _primaryWeaponUnderbarrelMagazine) then { - _magU set [0, objNull]; - _primaryWeaponClass set [0, _magU]; + _magU set [0, nil]; + _primaryWeaponClass set [5, _magU]; }; if ((_primaryWeaponClass select 6) isEqualTo _primaryWeaponUnderbarrel) then { - _primaryWeaponClass set [0, objNull]; + _primaryWeaponClass set [6, nil]; }; }; if (_secondaryWeaponClass isNotEqualTo []) then { if ((_secondaryWeaponClass select 0) isEqualTo _secondaryWeapon) then { - _secondaryWeaponClass set [0, objNull]; + _secondaryWeaponClass set [0, nil]; }; if ((_secondaryWeaponClass select 1) isEqualTo _secondaryWeaponMuzzle) then { - _secondaryWeaponClass set [0, objNull]; + _secondaryWeaponClass set [1, nil]; }; if ((_secondaryWeaponClass select 2) isEqualTo _secondaryWeaponPointer) then { - _secondaryWeaponClass set [0, objNull]; + _secondaryWeaponClass set [2, nil]; }; if ((_secondaryWeaponClass select 3) isEqualTo _secondaryWeaponOptic) then { - _secondaryWeaponClass set [0, objNull]; + _secondaryWeaponClass set [3, nil]; }; private _mag = _secondaryWeaponClass select 4; if ((_mag select 0) isEqualTo _secondaryWeaponMagazine) then { - _mag set [0, objNull]; - _secondaryWeaponClass set [0, _mag]; + _mag set [0, nil]; + _secondaryWeaponClass set [4, _mag]; }; private _magU = _secondaryWeaponClass select 5; if ((_magU select 0) isEqualTo _secondaryWeaponUnderbarrelMagazine) then { - _magU set [0, objNull]; - _secondaryWeaponClass set [0, _magU]; + _magU set [0, nil]; + _secondaryWeaponClass set [5, _magU]; }; if ((_secondaryWeaponClass select 6) isEqualTo _secondaryWeaponUnderbarrel) then { - _secondaryWeaponClass set [0, objNull]; + _secondaryWeaponClass set [6, nil]; }; }; if (_handgunWeaponClass isNotEqualTo []) then { if ((_handgunWeaponClass select 0) isEqualTo _handgunWeapon) then { - _handgunWeaponClass set [0, objNull]; + _handgunWeaponClass set [0, nil]; }; if ((_handgunWeaponClass select 1) isEqualTo _handgunWeaponMuzzle) then { - _handgunWeaponClass set [0, objNull]; + _handgunWeaponClass set [1, nil]; }; if ((_handgunWeaponClass select 2) isEqualTo _handgunWeaponPointer) then { - _handgunWeaponClass set [0, objNull]; + _handgunWeaponClass set [2, nil]; }; if ((_handgunWeaponClass select 3) isEqualTo _handgunWeaponOptic) then { - _handgunWeaponClass set [0, objNull]; + _handgunWeaponClass set [3, nil]; }; private _mag = _handgunWeaponClass select 4; if ((_mag select 0) isEqualTo _handgunWeaponMagazine) then { - _mag set [0, objNull]; - _handgunWeaponClass set [0, _mag]; + _mag set [0, nil]; + _handgunWeaponClass set [4, _mag]; }; private _magU = _handgunWeaponClass select 5; if ((_magU select 0) isEqualTo _handgunWeaponUnderbarrelMagazine) then { - _magU set [0, objNull]; - _handgunWeaponClass set [0, _magU]; + _magU set [0, nil]; + _handgunWeaponClass set [5, _magU]; }; if ((_handgunWeaponClass select 6) isEqualTo _handgunWeaponUnderbarrel) then { - _handgunWeaponClass set [0, objNull]; + _handgunWeaponClass set [6, nil]; }; }; if (_uniformClass isNotEqualTo []) then { if (_uniformClass select 0 isEqualTo _uniform) then { - _uniformClass set [0, objNull]; + _uniformClass set [0, nil]; }; }; if (_vestClass isNotEqualTo []) then { if (_vestClass select 0 isEqualTo _vest) then { - _vestClass set [0, objNull]; + _vestClass set [0, nil]; }; }; if (_backpackClass isNotEqualTo []) then { if (_backpackClass select 0 isEqualTo _backpack) then { - _backpackClass set [0, objNull]; + _backpackClass set [0, nil]; }; }; if (_headgearClass isNotEqualTo "") then { if (_headgearClass isEqualTo _headgear) then { - _headgearClass = objNull; + _headgearClass = nil; }; }; if (_gogglesClass isNotEqualTo "") then { if (_gogglesClass isEqualTo _goggles) then { - _gogglesClass = objNull; + _gogglesClass = nil; }; }; if (_binocularClass isNotEqualTo []) then { if (_binocularClass select 0 isEqualTo _binocular) then { - _binocularClass set [0, objNull]; + _binocularClass set [0, nil]; }; }; if (_itemsClass isNotEqualTo []) then { if ((_itemsClass select 0) isEqualTo _map) then { - _itemsClass set [0, objNull]; + _itemsClass set [0, nil]; }; if ((_itemsClass select 1) isEqualTo _gps) then { - _itemsClass set [1, objNull]; + _itemsClass set [1, nil]; }; if ((_itemsClass select 2) isEqualTo _radio) then { - _itemsClass set [2, objNull]; + _itemsClass set [2, nil]; }; if ((_itemsClass select 3) isEqualTo _compass) then { - _itemsClass set [3, objNull]; + _itemsClass set [3, nil]; }; if ((_itemsClass select 4) isEqualTo _watch) then { - _itemsClass set [4, objNull]; + _itemsClass set [4, nil]; }; if ((_itemsClass select 5) isEqualTo _nvgoggles) then { - _itemsClass set [5, objNull]; + _itemsClass set [5, nil]; }; }; @@ -362,6 +362,4 @@ _baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; }; }forEach _types; -diag_log str _baseLoadout; - _baseLoadout diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf index ac79128..b608b61 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf @@ -2,8 +2,10 @@ params ["_clothes"]; -private _return = objNull; -if (_clothes isNotEqualTo []) then { +diag_log str _clothes; + +private _return = nil; +if (!isNil "_clothes" && {_clothes isNotEqualTo []}) then { _return = _clothes select 0; }; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index 9fb4e96..ba9cdd1 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -36,7 +36,7 @@ private _binocular = if !(_loadout select 8 isEqualTo []) then { }; private _radio = _loadout select 9 select 2; -if (!isNull _radio && {isText (configFile >> "CfgWeapons" >> _radio >> "tf_parent")}) then { +if (!isNil _radio && {isText (configFile >> "CfgWeapons" >> _radio >> "tf_parent")}) then { _radio = getText (configFile >> "CfgWeapons" >> _radio >> "tf_parent"); }; @@ -85,8 +85,6 @@ if (!(_loadout select 5 isEqualTo []) && {!(_loadout select 5 select 1 isEqualTo _return pushBack (_tab + _tab + "};"); -diag_log str _return; -_return = _return - [objNull]; -diag_log str _return; +_return = _return - [nil]; _return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf index 8576923..d9d8c4c 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf @@ -6,26 +6,26 @@ private _return = []; if !(_weaponArray isEqualTo []) then { _weaponArray params [["_weapon", ""], ["_muzzle", ""], ["_pointer", ""], ["_optics", ""], ["_magazine", []], ["_underbarrelMagazin", []], ["_underbarrel", ""]]; - if (!isNull _weapon) then { + if (!isNil "_weapon") then { _return pushBack (_tripleTab + format ["%1Weapon = ""%2"";", _name, _weapon]); if ((_magazine isEqualType []) && {_magazine isNotEqualTo []}) then { _return pushBack( _tripleTab + format ["%1WeaponMagazine = ""%2"";", _name, _magazine select 0]); }; - if (!isNull _optics) then { + if (!isNil "_optics") then { _return pushBack (_tripleTab + format ["%1WeaponOptics = ""%2"";", _name, _optics]); }; - if (!isNull _pointer) then { + if (!isNil "_pointer") then { _return pushBack (_tripleTab + format ["%1WeaponPointer = ""%2"";", _name, _pointer]); }; - if (!isNull _muzzle) then { + if (!isNil "_muzzle") then { _return pushBack (_tripleTab + format ["%1WeaponMuzzle = ""%2"";", _name, _muzzle]); }; - if (!isNull _underbarrel) then { + if (!isNil "_underbarrel") then { _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrel]); }; From b2d245a59e513807d6a0e472a5a2067a638fa031 Mon Sep 17 00:00:00 2001 From: Salbei Date: Tue, 21 Jun 2022 22:06:07 +0200 Subject: [PATCH 3/6] fixed it --- addons/getLoadoutsFromUnits/XEH_PREP.hpp | 1 + .../functions/fnc_getClothes.sqf | 2 - .../functions/fnc_getLoadoutAndFormat.sqf | 5 ++- .../functions/fnc_getWeapon.sqf | 39 +++++++++---------- .../functions/fnc_onBtnOk.sqf | 2 +- .../functions/fnc_removeNilFromArray.sqf | 15 +++++++ 6 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf diff --git a/addons/getLoadoutsFromUnits/XEH_PREP.hpp b/addons/getLoadoutsFromUnits/XEH_PREP.hpp index 5296715..7fa0296 100644 --- a/addons/getLoadoutsFromUnits/XEH_PREP.hpp +++ b/addons/getLoadoutsFromUnits/XEH_PREP.hpp @@ -10,6 +10,7 @@ PREP(getLoadoutAndFormat); PREP(getWeapon); PREP(onBtnOk); PREP(onLoad); +PREP(removeNilFromArray); PREP(returnBaseItem); PREP(vanillaCivDefactionizer); PREP(vanillaMilitaryDefactionizer); \ No newline at end of file diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf index b608b61..b587b96 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getClothes.sqf @@ -2,8 +2,6 @@ params ["_clothes"]; -diag_log str _clothes; - private _return = nil; if (!isNil "_clothes" && {_clothes isNotEqualTo []}) then { _return = _clothes select 0; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index ba9cdd1..a0780c4 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -85,6 +85,9 @@ if (!(_loadout select 5 isEqualTo []) && {!(_loadout select 5 select 1 isEqualTo _return pushBack (_tab + _tab + "};"); -_return = _return - [nil]; + +//_return = _return - [nil]; - This sadly does not work :( +//So I have to do it the hard way +_return = [_return] call FUNC(removeNilFromArray); _return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf index d9d8c4c..5b0265d 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf @@ -4,34 +4,33 @@ params ["_weaponArray", "_name", "_tripleTab"]; private _return = []; if !(_weaponArray isEqualTo []) then { - _weaponArray params [["_weapon", ""], ["_muzzle", ""], ["_pointer", ""], ["_optics", ""], ["_magazine", []], ["_underbarrelMagazin", []], ["_underbarrel", ""]]; + _weaponArray params ["_weapon", "_muzzle", "_pointer", "_optics", "_magazine", "_underbarrelMagazin", "_underbarrel"]; if (!isNil "_weapon") then { _return pushBack (_tripleTab + format ["%1Weapon = ""%2"";", _name, _weapon]); + }; + if ((_magazine isEqualType []) && {_magazine isNotEqualTo []} && {!isNil {_magazine select 0}}) then { + _return pushBack( _tripleTab + format ["%1WeaponMagazine = ""%2"";", _name, _magazine select 0]); + }; - if ((_magazine isEqualType []) && {_magazine isNotEqualTo []}) then { - _return pushBack( _tripleTab + format ["%1WeaponMagazine = ""%2"";", _name, _magazine select 0]); - }; - - if (!isNil "_optics") then { - _return pushBack (_tripleTab + format ["%1WeaponOptics = ""%2"";", _name, _optics]); - }; + if (!isNil "_optics") then { + _return pushBack (_tripleTab + format ["%1WeaponOptics = ""%2"";", _name, _optics]); + }; - if (!isNil "_pointer") then { - _return pushBack (_tripleTab + format ["%1WeaponPointer = ""%2"";", _name, _pointer]); - }; + if (!isNil "_pointer") then { + _return pushBack (_tripleTab + format ["%1WeaponPointer = ""%2"";", _name, _pointer]); + }; - if (!isNil "_muzzle") then { - _return pushBack (_tripleTab + format ["%1WeaponMuzzle = ""%2"";", _name, _muzzle]); - }; + if (!isNil "_muzzle") then { + _return pushBack (_tripleTab + format ["%1WeaponMuzzle = ""%2"";", _name, _muzzle]); + }; - if (!isNil "_underbarrel") then { - _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrel]); - }; + if (!isNil "_underbarrel") then { + _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrel]); + }; - if ((_underbarrelMagazin isEqualType []) && {_underbarrelMagazin isNotEqualTo []})then { - _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrelMagazin]); - }; + if ((_underbarrelMagazin isEqualType []) && {_underbarrelMagazin isNotEqualTo []} && {!isNil {_underbarrelMagazin select 0}})then { + _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrelMagazin select 0]); }; } else { _return append [ diff --git a/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf b/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf index 528ce81..d111410 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_onBtnOk.sqf @@ -90,7 +90,7 @@ if (count _types > 2) then { "watch", "radio" ] apply {_doubleTab + _x + " = """";"}); - _structuredText pushBack (_tab + "};"); + _structuredText pushBack "};"; }; _structuredText pushBack (_tab + "class Type {"); diff --git a/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf b/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf new file mode 100644 index 0000000..a4c0590 --- /dev/null +++ b/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +params ["_oldArray"]; + +private _newArray = []; +{ + + private _var = _x; + + if (!isNil "_var") then { + _newArray pushBack _var; + }; +}forEach _oldArray; + +_newArray From 6396cc7270fd8ececf3cf8a105e0e2b6208b6c29 Mon Sep 17 00:00:00 2001 From: Salbei Date: Wed, 22 Jun 2022 14:33:01 +0200 Subject: [PATCH 4/6] fixed issues reportet by @Gelir95 --- .../getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf | 2 +- .../functions/fnc_getBaseLoadoutAndFormat.sqf | 2 +- .../functions/fnc_getLoadoutAndFormat.sqf | 5 +++-- addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf index 973e6f8..367655a 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf @@ -62,7 +62,7 @@ private _radios = []; ["_backpack", []], ["_headgear", ""], ["_googles", ""], - ["_binocluar", []], + ["_binocular", []], ["_items", []] ]; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getBaseLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getBaseLoadoutAndFormat.sqf index f075a58..32f99c6 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getBaseLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getBaseLoadoutAndFormat.sqf @@ -26,7 +26,7 @@ private _weaponArray = [_loadout select 2, "handgun", _doubleTab] call FUNC(getB _return = _return + _weaponArray; //Basic Items (Binocular, NVG, Maps, etc.) -private _binocular = if !(_loadout select 8 isEqualTo []) then { +private _binocular = if (_loadout select 8 isNotEqualTo []) then { format ["binoculars = ""%1"";", _loadout select 8 select 0] } else { "binoculars = """";" diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index a0780c4..e8f0bf4 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -31,8 +31,9 @@ private _weaponArray = [_loadout select 2, "handgun", _tripleTab] call FUNC(getW _return = _return + _weaponArray; //Basic Items (Binocular, NVG, Maps, etc.) -private _binocular = if !(_loadout select 8 isEqualTo []) then { - _return pushBack (_tripleTab + format ["binoculars = ""%1"";", _loadout select 8 select 0]) +private _binoLoadout = _loadout select 8; +private _binocular = if (_binoLoadout isEqualType [] && {_binoLoadout isNotEqualTo []} && {!isNil {_binoLoadout select 0}}) then { + _return pushBack (_tripleTab + format ["binoculars = ""%1"";", _binoLoadout select 0]) }; private _radio = _loadout select 9 select 2; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf index 5b0265d..39c4ed8 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getWeapon.sqf @@ -32,6 +32,7 @@ if !(_weaponArray isEqualTo []) then { if ((_underbarrelMagazin isEqualType []) && {_underbarrelMagazin isNotEqualTo []} && {!isNil {_underbarrelMagazin select 0}})then { _return pushBack (_tripleTab + format ["%1WeaponUnderbarrel = ""%2"";", _name, _underbarrelMagazin select 0]); }; + /* } else { _return append [ _tripleTab + format ["%1Weapon = """";", _name], @@ -42,6 +43,7 @@ if !(_weaponArray isEqualTo []) then { _tripleTab + format ["%1WeaponUnderbarrel = """";", _name], _tripleTab + format ["%1WeaponUnderbarrel = """";", _name] ]; + */ }; _return From ea52f60c2def049f450bbfb1a2c2fb2ee59c2b43 Mon Sep 17 00:00:00 2001 From: Salbei Date: Wed, 22 Jun 2022 17:29:26 +0200 Subject: [PATCH 5/6] added Fussels fix --- addons/getLoadoutsFromUnits/XEH_PREP.hpp | 1 - .../functions/fnc_getLoadoutAndFormat.sqf | 5 +---- .../functions/fnc_removeNilFromArray.sqf | 15 --------------- 3 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf diff --git a/addons/getLoadoutsFromUnits/XEH_PREP.hpp b/addons/getLoadoutsFromUnits/XEH_PREP.hpp index 7fa0296..5296715 100644 --- a/addons/getLoadoutsFromUnits/XEH_PREP.hpp +++ b/addons/getLoadoutsFromUnits/XEH_PREP.hpp @@ -10,7 +10,6 @@ PREP(getLoadoutAndFormat); PREP(getWeapon); PREP(onBtnOk); PREP(onLoad); -PREP(removeNilFromArray); PREP(returnBaseItem); PREP(vanillaCivDefactionizer); PREP(vanillaMilitaryDefactionizer); \ No newline at end of file diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index e8f0bf4..5db98b8 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -86,9 +86,6 @@ if (!(_loadout select 5 isEqualTo []) && {!(_loadout select 5 select 1 isEqualTo _return pushBack (_tab + _tab + "};"); - -//_return = _return - [nil]; - This sadly does not work :( -//So I have to do it the hard way -_return = [_return] call FUNC(removeNilFromArray); +_return = _return select {!isNil "_x" }; _return diff --git a/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf b/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf deleted file mode 100644 index a4c0590..0000000 --- a/addons/getLoadoutsFromUnits/functions/fnc_removeNilFromArray.sqf +++ /dev/null @@ -1,15 +0,0 @@ -#include "script_component.hpp" - -params ["_oldArray"]; - -private _newArray = []; -{ - - private _var = _x; - - if (!isNil "_var") then { - _newArray pushBack _var; - }; -}forEach _oldArray; - -_newArray From 39f96ef242fe0b39c625fdc5a36befdc07d56139 Mon Sep 17 00:00:00 2001 From: Salbei Date: Mon, 27 Jun 2022 15:27:50 +0200 Subject: [PATCH 6/6] Fixed 2 Issues, with Medicla macro & binos --- .../functions/fnc_createBaseClass.sqf | 11 ++++------- .../functions/fnc_getLoadoutAndFormat.sqf | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf index 367655a..b0fa0b9 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_createBaseClass.sqf @@ -203,7 +203,7 @@ _baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; ["_backpackClass", []], ["_headgearClass", ""], ["_googlesClass", ""], - ["_binocluarClass", []], + ["_binocularClass", []], ["_itemsClass", []] ]; @@ -330,10 +330,8 @@ _baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; }; }; - if (_binocularClass isNotEqualTo []) then { - if (_binocularClass select 0 isEqualTo _binocular) then { - _binocularClass set [0, nil]; - }; + if (_binocularClass isNotEqualTo [] && {(_binocularClass select 0) isEqualTo _binoculars}) then { + _binocularClass = []; }; if (_itemsClass isNotEqualTo []) then { @@ -357,8 +355,7 @@ _baseLoadout set [9, [_map, _gps, _radio, _compass, _watch, _nvgoggles]]; }; }; - - [_loadoutHash, _x, [_primaryWeaponClass, _secondaryWeaponClass, _handgunWeaponClass, _uniformClass, _vestClass, _backpackClass, _headgearClass, _googlesClass, _binocluarClass, _itemsClass]] call CBA_fnc_hashSet; + [_loadoutHash, _x, [_primaryWeaponClass, _secondaryWeaponClass, _handgunWeaponClass, _uniformClass, _vestClass, _backpackClass, _headgearClass, _googlesClass, _binocularClass, _itemsClass]] call CBA_fnc_hashSet; }; }forEach _types; diff --git a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf index 5db98b8..eea71f4 100644 --- a/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf +++ b/addons/getLoadoutsFromUnits/functions/fnc_getLoadoutAndFormat.sqf @@ -79,13 +79,25 @@ if (!(_loadout select 5 isEqualTo []) && {!(_loadout select 5 select 1 isEqualTo _x params ["_medicalTyp", "_index"]; if (_medicalTyp isEqualTo _type) exitWith { - _return pushBack ""; - _return pushBack (_tripleTab + (["GRAD_FACTIONS_MEDICITEMS_CFR", "GRAD_FACTIONS_MEDICITEMS_SQ", "GRAD_FACTIONS_MEDICITEMS_PT"] select _index)); + _return append [ + "", + _tripleTab + "class Rank {", + _tripleTab + _tab + "class PRIVATE {", + _tripleTab + _tab + _tab + (["GRAD_FACTIONS_MEDICITEMS_CFR", "GRAD_FACTIONS_MEDICITEMS_SQ", "GRAD_FACTIONS_MEDICITEMS_PT"] select _index), + _tripleTab + _tab + "};", + _tripleTab + _tab + "class CORPORAL: PRIVATE {}", + _tripleTab + _tab + "class SERGEANT: PRIVATE {}", + _tripleTab + _tab + "class LIEUTENANT: PRIVATE {}", + _tripleTab + _tab + "class CAPTAIN: PRIVATE {}", + _tripleTab + _tab + "class MAJOR: PRIVATE {}", + _tripleTab + _tab + "class COLONEL: PRIVATE {}", + _tripleTab + "}", + "" + ]; }; }forEach _typesMedical; _return pushBack (_tab + _tab + "};"); - _return = _return select {!isNil "_x" }; _return