diff --git a/Sources/epoch_code/compile/traders/EPOCH_NPCTraderMenuFilter.sqf b/Sources/epoch_code/compile/traders/EPOCH_NPCTraderMenuFilter.sqf index 0b21ac5a..eb54023e 100644 --- a/Sources/epoch_code/compile/traders/EPOCH_NPCTraderMenuFilter.sqf +++ b/Sources/epoch_code/compile/traders/EPOCH_NPCTraderMenuFilter.sqf @@ -51,9 +51,15 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { { _item = _x; _rounds = 1; + _onHand = false; if (_item isequaltype []) then { _item = _x select 0; - _rounds = _x select 1; + if ((_x select 1) isequalto "Hand") then { + _onHand = true; + } + else { + _rounds = _x select 1; + }; }; if !(_item isequalto "") then { _maxrnd = 1; @@ -66,7 +72,7 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { _tooltip = format ["%1 rounds left in Magazine",_rounds]; }; if (_index == 0 || (tolower _item) in _FilterArray) then { - _id = lbAdd [_PlayerItemsBox, _item call EPOCH_itemDisplayName]; + _id = lbAdd [_PlayerItemsBox, (_item call EPOCH_itemDisplayName) + (if (_onHand) then {" (in Hand)"} else {""})]; lbSetData [_PlayerItemsBox, _id, _item]; lbSetValue [_PlayerItemsBox, _id, _rounds]; lbSetPicture [_PlayerItemsBox, _id, _item call EPOCH_itemPicture]; @@ -74,6 +80,9 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { lbSetTooltip [_PlayerItemsBox, _id, _tooltip]; lbSetColor [_PlayerItemsBox,_id,[1,(_rounds/_maxrnd),0,1]]; }; + if (_onHand) then { + lbSetColor [_PlayerItemsBox,_id,[1,1,1,0.5]]; + }; }; }; } forEach EPOCH_NpcTradePlayerItems; diff --git a/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf b/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf index a16ec9ae..26242be3 100644 --- a/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf +++ b/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf @@ -13,8 +13,8 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf */ -private [ "_PlayerFilerDropDown","_PlayerItemsBox","_PlayerItemsOutBox","_TraderItemsOutBox","_CryptoInCtrl","_CryptoOutCtrl","_allowAdd","_uiItem","_rounds","_itemIcon","_itemColor","_errormsg","_stockLimit","_config", - "_itemClasses","_itemQtys","_qtyIndex","_sizeOut","_item","_vehicle","_itemName","_index","_maxrnd","_ItemIndex","_cryptoCount","_worth","_itemTax","_tax" +private [ "_PlayerFilerDropDown","_PlayerItemsBox","_PlayerItemsOutBox","_TraderItemsOutBox","_CryptoInCtrl","_CryptoOutCtrl","_allowAdd","_uiItem","_rounds","_itemIcon","_itemColor","_errormsg","_config", + "_sizeOut","_item","_vehicle","_itemName","_index","_maxrnd","_ItemIndex","_cryptoCount","_worth","_itemTax","_tax" ]; params ["_control","_selected"]; _selected params ["_CurControl","_id"]; @@ -33,31 +33,10 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { _itemIcon = _CurControl lbPicture _id; _itemColor = _CurControl lbColor _id; _errormsg = ""; - _stockLimit = false; _config = 'CfgPricing' call EPOCH_returnConfig; if (isClass (_config >> _uiItem)) then { if (_control == _PlayerItemsOutBox) then { - _itemClasses = EPOCH_NpcTradeTraderItems select 0; - _itemQtys = EPOCH_NpcTradeTraderItems select 1; - _qtyIndex = _itemClasses find _uiItem; - if (_qtyIndex != -1) then { - _itemQty = _itemQtys select _qtyIndex; - _maxrnd = 1; - if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then { - _maxrnd = getnumber (configfile >> "cfgMagazines" >> _uiItem >> "count"); - }; - _itemQty = _itemQty / _maxrnd; - _sizeIn = lbSize _PlayerItemsOutBox; - if (_sizeIn > 0) then { - for "_i" from 0 to (_sizeIn - 1) do { - _InItem = lbData [_PlayerItemsOutBox, _i]; - if ((lbData [_PlayerItemsOutBox, _i]) == _uiItem) then { - _itemQty = _itemQty + ((lbValue [_PlayerItemsOutBox, _i])/_maxrnd); - }; - }; - }; - }; if (_uiItem isKindOf "Air" || _uiItem isKindOf "Ship" || _uiItem isKindOf "LandVehicle" || _uiItem isKindOf "Tank") then { _sizeOut = lbSize _PlayerItemsOutBox; if (_sizeOut > 0) then { @@ -109,7 +88,12 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { lbSetPicture [_control, _index, _itemIcon]; lbSetColor [_control,_index,_itemColor]; if (_control == _PlayerItemsBox && !(_uiItem iskindof "Landvehicle" || _uiItem iskindof "SHIP" || _uiItem iskindof "AIR" || _uiItem iskindof "TANK")) then { - EPOCH_NpcTradePlayerItems pushback [_uiItem,_rounds]; + if ((_itemName find " (in Hand)") > -1) then { + EPOCH_NpcTradePlayerItems pushback [_uiItem,"Hand"]; + } + else { + EPOCH_NpcTradePlayerItems pushback [_uiItem,_rounds]; + }; } else { if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then { @@ -119,9 +103,15 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { lbSetTooltip [_control,_index,_tooltip]; }; }; - _ItemIndex = EPOCH_NpcTradePlayerItems find [_uiItem,_rounds]; + _ItemIndex = -1; + if ((_itemName find " (in Hand)") > -1) then { + _ItemIndex = EPOCH_NpcTradePlayerItems find [_uiItem,"Hand"]; + }; if (_ItemIndex < 0) then { _ItemIndex = EPOCH_NpcTradePlayerItems find _uiItem; + if (_ItemIndex < 0) then { + _ItemIndex = EPOCH_NpcTradePlayerItems find [_uiItem,_rounds]; + }; }; if (_ItemIndex > -1) then { EPOCH_NpcTradePlayerItems deleteat _ItemIndex; @@ -168,12 +158,7 @@ if !(isNull EPOCH_lastNPCtradeTarget) then { }; } else { - if (_stockLimit) then{ - ["Trader has the maximum amount of this item", 5] call Epoch_message; - } - else { - [_errormsg, 5] call Epoch_message; - }; + [_errormsg, 5] call Epoch_message; }; }; } diff --git a/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf b/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf index 008eec03..6fa3bdfe 100644 --- a/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf +++ b/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf @@ -23,10 +23,13 @@ if (alive _target) then { EPOCH_lastNPCtradeTarget = _target; EPOCH_NpcTradePlayerItems = (items player)+(magazinesammo player); if (primaryWeapon player != "") then { - EPOCH_NpcTradePlayerItems pushback primaryWeapon player; + EPOCH_NpcTradePlayerItems pushback [primaryWeapon player,"Hand"]; }; if (secondaryWeapon player != "") then { - EPOCH_NpcTradePlayerItems pushback secondaryWeapon player; + EPOCH_NpcTradePlayerItems pushback [secondaryWeapon player,"Hand"]; + }; + if (handgunWeapon player != "") then { + EPOCH_NpcTradePlayerItems pushback [handgunWeapon player,"Hand"]; }; if (count backpackItems player == 0 && count backpackmagazines player == 0 && backpack player != "") then { EPOCH_NpcTradePlayerItems pushback backpack player; diff --git a/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf b/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf index c1ecd269..5bb68ac8 100644 --- a/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf +++ b/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf @@ -28,6 +28,11 @@ if (alive _this) then { _arrayIn = []; if (_sizeIn > 0) then { for "_i" from 0 to (_sizeIn - 1) do { + _onHand = false; + _itemName = lbText [_PlayerItemsOutBox, _i]; + if ((_itemName find " (in hand)") > -1) then { + _onHand = true; + }; _item = lbData [_PlayerItemsOutBox, _i]; _rounds = lbValue [_PlayerItemsOutBox, _i]; if (isClass (_config >> _item)) then{ @@ -39,14 +44,14 @@ if (alive _this) then { _itemWorth = round (_itemWorth*(_rounds/_maxrnd)); _added = false; if ([_item, "CfgWeapons"] call EPOCH_fnc_isAny) then { - if (_item in items player) then { + if (_item in items player && !_onHand) then { player removeItem _item; _arrayIn pushBack [_item,_rounds]; _added = true; } else { - if (_item in [primaryweapon player,secondaryweapon player]) then { - _index = if (_item == primaryweapon player) then {0} else {1}; + if (_item in [primaryweapon player,secondaryweapon player, handgunweapon player]) then { + _index = if (_item == primaryweapon player) then {0} else {if (_item == secondaryweapon player) then {1} else {2}}; { if (_foreachindex > 0) then { _weaponaddon = _x;