Advertisement
HWS_Wolf

sqf666

Nov 13th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.03 KB | None | 0 0
  1. /**
  2.  * Exile Mod
  3.  * www.exilemod.com
  4.  * © 2015 Exile Mod Team
  5.  *
  6.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  7.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  8.  */
  9.  
  10. private["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile"];
  11. _unit             = _this select 0;
  12. _selectionName    = _this select 1;
  13. _amountOfDamage   = _this select 2;
  14. _sourceOfDamage   = _this select 3;
  15. _typeOfProjectile = _this select 4;
  16.  
  17. fnc_otherUnif = {
  18.   params ["_type","_return"];
  19.   if (_type == 0) exitWith {
  20.     MGI_button = _return select 1; false
  21.   };
  22.   if (_type == 1 and !isnil "MGI_button" && {MGI_button == 1}) then {
  23.     disableSerialization;
  24.     _control = _return select 0;
  25.     _index = _return select 1;
  26.     private _idc = ctrlIDC _control;
  27.     private _text = lbText [_idc, _index];
  28.     private _picture = lbPicture [_idc,_index];
  29.     private _uniforms = ("getText (_x >> 'displayName') == _text && getNumber (_x >> 'ItemInfo' >> 'type') == 801" configClasses (configFile >> "CfgWeapons"));
  30.     if (count _uniforms > 0) then {
  31.       [_idc,_text,_picture,_index,_uniforms] spawn {
  32.         params ["_idc","_text","_picture","_index","_uniforms","_selectedUnif","_unifContClasses",["_uniformObject",objNull],["_selectedInvent",[]],"_items","_otherItems","_g0"];
  33.         _currentUnif = uniform player;
  34.         _currentInvent = uniformItems player;
  35.         _selectedUnif = ((_uniforms select {toLower (gettext (_x >> "picture")) splitString "\"joinString "\" == _picture}) apply {configName _x}) select 0;
  36.  
  37.        if !(pl_container isKindOf "CAManBase") then {
  38.          _unifContClasses = (everyContainer pl_container select { (_x select 0) select [0,2] == "U_" or ["_U_",(_x select 0)] call bis_fnc_instring or ["uniform",(_x select 0)] call bis_fnc_instring});
  39.          _cnt = 0;
  40.          for "_i" from 0 to _index do {
  41.            if (lbText [_idc,_i] == _text) then {
  42.              _cnt = _cnt +1;
  43.              _uniformObject = _unifContClasses select {_selectedUnif == (_x select 0)} select (_cnt -1) select 1
  44.            };
  45.          };
  46.        } else {
  47.          _uniformObject = uniformContainer pl_container
  48.        };
  49.        _selectedInvent = [];
  50.        {_selectedInvent pushback _x} foreach (itemCargo _uniformObject);
  51.        if (magazineCargo _uniformObject isEqualType []) then {
  52.          {_selectedInvent pushback _x} foreach (magazineCargo _uniformObject);
  53.        };
  54.        if !(pl_container isKindOf "CAmanbase") then {
  55.          _items = +itemCargo pl_container;
  56.          _unifItems = _unifContClasses apply {_x select 0};
  57.          _vestContClasses = (everyContainer pl_container select { (_x select 0) select [0,2] == "V_"});
  58.          _vestItems = _vestContClasses apply {_x select 0};
  59.          _otherItems = +_items - _unifItems - _vestItems;
  60.          pl_container setVariable ["allconts",_unifContClasses+_vestContClasses];
  61.          for "_i" from 0 to count (_unifContClasses+_vestContClasses) -1 do {
  62.            if (((pl_container getVariable "allconts") select _i) select 1 == _uniformObject) exitWith {
  63.              (pl_container getVariable "allconts") deleteAt _i
  64.            };
  65.          };
  66.          pl_container setVariable ["allconts", +(pl_container getVariable "allconts") apply {[_x select 0, itemCargo (_x select 1), magazineCargo (_x select 1)]}];
  67.          _g0 = pl_container;
  68.          clearItemCargoGlobal _g0;
  69.        } else {
  70.          _g0 = createVehicle ["WeaponHolderSimulated_Scripted", (player modelToWorld [0,1,1]), [], 0, "CAN_COLLIDE"]
  71.        };
  72.        player forceAddUniform _selectedUnif;
  73.        {player addItemToUniform _x} forEach _selectedInvent;
  74.        call {
  75.          if (pl_container isKindOf "CAManBase") exitWith {
  76.            removeUniform pl_container
  77.          };
  78.          {
  79.            _x params ["_cont",["_it",[]],["_mag",[]]];
  80.            pl_container addItemCargoGlobal [_cont,1];
  81.            _createdCont = pl_container call MGI_lastCont;
  82.            {_createdCont addItemCargoGlobal [_x,1];true} count _it;
  83.            {_createdCont addMagazineCargoGlobal [_x,1];true} count _mag;
  84.          } forEach (pl_container getVariable ["allconts",[]]);
  85.          {_g0 addItemCargoGlobal [_x,1]} forEach _otherItems;
  86.        };
  87.        _g0 addItemCargoGlobal [_currentUnif,1];
  88.        _lastCont = _g0 call MGI_lastCont;
  89.        {_lastCont addItemCargoGlobal [_x,1]} forEach _currentInvent;
  90.        if (_g0 isKindOf "WeaponHolderSimulated" && {(count itemCargo _g0 + count magazineCargo _g0 + count weaponCargo _g0 + count backpackCargo _g0) == 0}) then {
  91.          deleteVehicle _g0
  92.        };
  93.      };
  94.    };
  95.  };
  96.  MGI_button = 0; false
  97. };
  98.  
  99. MGI_lastCont = compileFinal "
  100.   params [['_cont',objNull]];
  101.   private '_lastCont';
  102.    _invent = (everyContainer _cont - (everyBackpack _cont apply {[typeOf _x,_x]}));
  103.    if !(_invent isEqualTo []) then {
  104.     _lastCont = _invent select (count _invent -1) select 1;
  105.    } else {
  106.     _lastCont = _cont;
  107.    };
  108.    _lastCont
  109. ";
  110.  
  111. player addEventHandler ["InventoryOpened", {
  112.  params ["_unit", "_container"];
  113.  pl_container = _container;
  114.  [] spawn {
  115.    waitUntil {!(isNull findDisplay 602)};
  116.    disableSerialization;
  117.    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["MouseButtonClick", "[0,_this] call fnc_otherUnif"]} forEach [632,640];
  118.    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["LBSelChanged", "[1,_this] spawn fnc_otherUnif"]} forEach [632,640];
  119.  };
  120. }]
  121.  
  122.     if (isPlayer _sourceOfDamage && !(_sourceOfDamage isEqualTo player)) exitWith
  123.     {
  124.         _amountOfDamage = damage _unit;
  125.         _amountOfDamage
  126.     };
  127.     pl_container = _container;
  128.  [] spawn {
  129.    waitUntil {!(isNull findDisplay 602)};
  130.    disableSerialization;
  131.    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["MouseButtonClick", "[0,_this] call fnc_otherUnif"]} forEach [632,640];
  132.    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["LBSelChanged", "[1,_this] spawn fnc_otherUnif"]} forEach [632,640];
  133.  };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement