From e5af93b50b7dd7ca379de67848060d595a98cd12 Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Sat, 12 Sep 2020 03:10:31 +0200 Subject: [PATCH] Add weight to items at traders If the weight system is active all weights of the items will be displayed on the trader infos. Also update the trading files and replace switch with call and exitwith which is faster. --- .../functions/z_at_allowBuying.sqf | 40 ++++++++++--------- .../functions/z_at_calcBuyableList.sqf | 4 +- .../functions/z_at_calcCurrency.sqf | 18 ++++----- .../functions/z_at_checkArrayInConfig.sqf | 14 +++---- .../functions/z_at_displayBackpackInfo.sqf | 10 +++++ .../functions/z_at_displayFreeSpace.sqf | 21 +++++----- .../functions/z_at_displayItemInfo.sqf | 14 ++++++- .../functions/z_at_displayVehicleInfo.sqf | 6 +-- .../functions/z_at_displayWeaponInfo.sqf | 12 +++++- .../functions/z_at_getContainer.sqf | 16 ++++---- .../functions/z_at_getItemConfig.sqf | 14 +++---- .../functions/z_at_getItemInfo.sqf | 12 +++--- .../functions/z_at_logTrade.sqf | 14 +++---- .../functions/z_at_returnChange.sqf | 32 +++++++-------- .../functions/z_at_sellItems.sqf | 25 +++++------- ...upa_fnc_removeWeaponsAndMagazinesCargo.sqf | 4 +- 16 files changed, 141 insertions(+), 115 deletions(-) diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf index 0401a1c92..3f77ac3f9 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf @@ -3,6 +3,7 @@ private ["_selection","_return","_toBuyWeaps","_toBuyTotalMags","_toBuyBags","_t ,"_allowedPrimary","_allowedTools","_allowedSidearm","_allowedBackpacks","_toolClasses" ,"_duplicate","_quantity","_tool","_totalBagSlots","_pistolMags","_regularMags","_toBuyPistolMags" ,"_toBuyRegularMags","_type","_freeSpace","_backpack","_totalSpace","_toolAmounts","_allowedBinocular","_message" +,"_vehiclesToBuy","_allowedWeapons","_allowedPistolMags","_allowedRegularMags","_typeW" ]; _selection = Z_SellingFrom; _return = false; @@ -28,20 +29,20 @@ if (_vehiclesToBuy > 0) then { if (_selection == 2) then { //gear _pistolMags = 0; - _regularMags = 0; + _regularMags = 0; { _type = getNumber (configFile >> "CfgMagazines" >> _x >> "type"); if (_type == 16) then {_pistolMags = _pistolMags + 1;}; // WeaponSlotHandGunItem (pistol ammo slot) if (_type == 256) then {_regularMags = _regularMags + 1;}; // WeaponSlotItem (normal magazine) } count (magazines player); - + _allowedPistolMags = 8 - _pistolMags; _allowedRegularMags = 12 - _regularMags; _p = primaryWeapon player; _allowedPrimary = if (_p != "") then {0} else {1}; if (DZE_TwoPrimaries == 2 && dayz_onBack == "") then { _allowedPrimary = _allowedPrimary + 1; }; - + _b = unitBackpack player; _allowedBackpacks = if (isNull _b) then {1} else {0}; @@ -50,15 +51,16 @@ if (_selection == 2) then { //gear _allowedBinocular = 2; _duplicate = false; { - switch getNumber (configFile >> "CfgWeapons" >> _x >> "type") do { - case 2: {_allowedSidearm = 0;}; //Pistol - case 4: {_allowedBackpacks = 0;}; //Launcher - case 4096: {_allowedBinocular = _allowedBinocular - 1;}; //Binocular slot - case 131072: {_allowedTools = _allowedTools - 1;}; //Toolbelt slot + _typeW = getNumber (configFile >> "CfgWeapons" >> _x >> "type"); + call { + if (_typeW == 2) exitwith {_allowedSidearm = 0;}; //Pistol + if (_typeW == 4) exitwith {_allowedBackpacks = 0;}; //Launcher + if (_typeW == 4096) exitwith {_allowedBinocular = _allowedBinocular - 1;}; //Binocular slot + if (_typeW == 131072) exitwith {_allowedTools = _allowedTools - 1;}; //Toolbelt slot }; if (_x in _toolClasses) exitWith {_duplicate = true;}; // Forbid purchasing duplicate tools into gear } count (weapons player); - + { _tool = _x; _quantity = {(_tool == _x)} count _toolClasses; // Buying same tool multiple times with 1x quantity @@ -68,7 +70,7 @@ if (_selection == 2) then { //gear _toolsToBuy = _toolsToBuy - 1; //Not counting binoculars in tool total (12) when buying in gear }; } forEach _toolClasses; - + { if (_x > 1) exitWith {_duplicate = true;}; // Buying >1x quantity of a tool } count _toolAmounts; @@ -80,11 +82,11 @@ if (_selection == 2) then { //gear if (_allowedPrimary >= _primaryToBuy && _allowedSidearm >= _sidearmToBuy && _allowedTools >= _toolsToBuy && !_duplicate && _allowedBinocular > -1) then { _check1 = true; } else { - _message = switch (true) do { - case (_duplicate): {localize "STR_EPOCH_TRADE_DUPLICATE_TOOL"}; - case (_allowedBinocular < 0): {localize "STR_EPOCH_TRADE_BINOCULARS_FULL"}; - case (_allowedTools < _toolsToBuy): {localize "STR_EPOCH_PLAYER_107"}; - default {format[localize "STR_EPOCH_TRADE_GEAR_FULL",_allowedPrimary,_allowedSidearm,_allowedTools]}; + _message = call { + if (_duplicate) exitWith {localize "STR_EPOCH_TRADE_DUPLICATE_TOOL"}; + if (_allowedBinocular < 0) exitWith {localize "STR_EPOCH_TRADE_BINOCULARS_FULL"}; + if (_allowedTools < _toolsToBuy) exitWith {localize "STR_EPOCH_PLAYER_107"}; + format[localize "STR_EPOCH_TRADE_GEAR_FULL",_allowedPrimary,_allowedSidearm,_allowedTools]; }; systemChat _message; }; @@ -96,13 +98,13 @@ if (_selection == 2) then { //gear if (_allowedBackpacks >= _toBuyBags) then { _check3 = true; } else { - if (_allowedBackpacks == 0) then { + if (_allowedBackpacks == 0) then { systemChat localize "STR_EPOCH_TRADE_HAVE_BACKPACK"; } else { systemChat localize "STR_EPOCH_TRADE_ONE_BACKPACK"; }; }; - + if (_check1 && _check2 && _check3) then { _return = true; }; }; @@ -180,7 +182,7 @@ if (_selection == 0) then { //backpack systemChat localize "STR_EPOCH_TRADE_BACKPACK_FULL"; }; }; - + if (_allowedMags >= _toBuyTotalMags) then { _check2 = true; } else { @@ -206,4 +208,4 @@ if (_selection == 0) then { //backpack if (_check0 && _check1 && _check2 && _check3 && _check4) then { _return = true; }; }; -_return \ No newline at end of file +_return diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf index 3776d1030..ce1061796 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf @@ -1,9 +1,9 @@ -private ["_arrayOfTraderCat","_counter","_cat","_cfgtraders","_y","_type","_buy","_sell","_pic","_text","_worth","_buyCurrency","_sellCurrency","_ignore","_categoryNumber","_BcurrencyQty","_ScurrencyQty"]; +private ["_arrayOfTraderCat","_part","_cat","_cfgtraders","_y","_type","_buy","_sell","_pic","_text","_worth","_buyCurrency","_sellCurrency","_ignore","_categoryNumber","_BcurrencyQty","_ScurrencyQty"]; call Z_clearBuyList; Z_BuyableArray = []; _arrayOfTraderCat = Z_traderData; -_counter = 0; + { _categoryNumber = _x select 1; if (_categoryNumber == _this) exitWith { diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf index 7fbec6c1e..9fabc2372 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcCurrency.sqf @@ -20,50 +20,50 @@ _GemTotal2 = _total; { _gem = _x; _value = DZE_GemWorthList select _forEachIndex; - switch(_gem) do { - case 'ItemTopaz': { + call { + if (_gem == 'ItemTopaz') exitwith { _ItemTopaz = floor(_GemTotal2 / _value); if (_ItemTopaz >= 1) then { _GemTotal = (_value * _ItemTopaz) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemObsidian': { + if (_gem == 'ItemObsidian') exitwith { _ItemObsidian = floor(_GemTotal2 / _value); if (_ItemObsidian >= 1) then { _GemTotal = (_value * _ItemObsidian) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemSapphire': { + if (_gem == 'ItemSapphire') exitwith { _ItemSapphire = floor(_GemTotal2 / _value); if (_ItemSapphire >= 1) then { _GemTotal = (_value * _ItemSapphire) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemAmethyst': { + if (_gem == 'ItemAmethyst') exitwith { _ItemAmethyst = floor(_GemTotal2 / _value); if (_ItemAmethyst >= 1) then { _GemTotal = (_value * _ItemAmethyst) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemEmerald': { + if (_gem == 'ItemEmerald') exitwith { _ItemEmerald = floor(_GemTotal2 / _value); if (_ItemEmerald >= 1) then { _GemTotal = (_value * _ItemEmerald) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemCitrine': { + if (_gem == 'ItemCitrine') exitwith { _ItemCitrine = floor(_GemTotal2 / _value); if (_ItemCitrine >= 1) then { _GemTotal = (_value * _ItemCitrine) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemRuby': { + if (_gem == 'ItemRuby') exitwith { _ItemRuby = floor(_GemTotal2 / _value); if (_ItemRuby >= 1) then { _GemTotal = (_value * _ItemRuby) + _GemTotal; @@ -166,4 +166,4 @@ if (_noIMG) then { } forEach _array; }; -_string \ No newline at end of file +_string diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf index 74b531e89..b6fa074e2 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -8,7 +8,7 @@ * * Fills up the sellable list if the item has a valid config. **/ -private ["_weaps","_mags","_extraText","_arrayOfTraderCat","_totalPrice","_backUpText","_bags","_baseVehicle","_currencyQty","_swap","_swap2","_myVehType"]; +private ["_weaps","_mags","_extraText","_arrayOfTraderCat","_totalPrice","_backUpText","_bags","_baseVehicle","_currencyQty","_swap","_swap2","_myVehType","_processGear","_HasKeyCheck","_vehTrade"]; #include "defines.hpp" _weaps = _this select 0; @@ -37,7 +37,7 @@ _HasKeyCheck = { _totalPrice = 0; _processGear = { - private ["_configType","_passedType","_cat","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth"]; + private ["_configType","_passedType","_cat","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth","_y","_HasKey","_part"]; _passedType = _this select 1; //Check for items that have the same magazine and weapon classname (PipeBomb, Stinger, Igla, etc.) { @@ -65,22 +65,22 @@ _processGear = { _text = ""; _configType = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type"); if (_passedType == "find") then {_passedType = _configType;}; - + _sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell"); _buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy"); if (_swap) then {_y = "ItemBloodbag"}; - switch (true) do { - case (_passedType == "trade_items") : + call { + if (_passedType == "trade_items") exitwith { _pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture'); _text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName'); }; - case (_passedType == "trade_weapons") : + if (_passedType == "trade_weapons") exitwith { _pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture'); _text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName'); }; - case (_passedType in DZE_tradeObject) : + if (_passedType in DZE_tradeObject) exitwith { _pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture'); _text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName'); diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayBackpackInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayBackpackInfo.sqf index e5c1ba5fc..2125db50d 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayBackpackInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayBackpackInfo.sqf @@ -88,4 +88,14 @@ if (Z_SingleCurrency) then { ]; }; +if (DZE_R3F_WEIGHT) then { + private "_weight"; + + _weight = getNumber(configFile >> "CfgWeight" >> "Backpacks" >> _class >> "weight"); + _formattedText = _formattedText + format [ + "%1: %2 %3" + ,localize "STR_EPOCH_WEIGHT",_weight,localize "STR_R3F_WEIGHT_English" + ]; +}; + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf index 2d86dc792..6e4410b12 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayFreeSpace.sqf @@ -1,4 +1,4 @@ -private ["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_pic","_backpack","_actualMags","_freeSpace","_allowedPrimary","_allowedSidearm","_p"]; +private ["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_pic","_backpack","_actualMags","_freeSpace","_allowedPrimary","_allowedSidearm","_p","_nr","_totalBagSlots", "_totalSpace"]; #include "defines.hpp" _selection = _this select 0; @@ -10,21 +10,22 @@ if (_selection == 2) then { //gear // Don't show pistol mag slots as item slots in gear. Player is informed of pistol mag slots count in systemChat. _actualMags = {(getNumber (configFile >> "CfgMagazines" >> _x >> "type") == 256)} count (magazines player); // 256 = WeaponSlotItem (normal magazine) _allowedMags = 12 - _actualMags; - + _p = primaryWeapon player; _allowedPrimary = if (_p != "") then {0} else {1}; if (DZE_TwoPrimaries == 2 && dayz_onBack == "") then { _allowedPrimary = _allowedPrimary + 1; }; - + _backpack = unitBackpack player; _allowedBackpacks = if (isNull _backpack) then {1} else {0}; _allowedSidearm = 1; { - switch getNumber (configFile >> "CfgWeapons" >> _x >> "type") do { - case 2: {_allowedSidearm = 0;}; //Pistol - case 4: {_allowedBackpacks = 0;}; //Launcher + _nr = getNumber (configFile >> "CfgWeapons" >> _x >> "type"); + call { + if (_nr == 2) exitwith {_allowedSidearm = 0;}; //Pistol + if (_nr == 4) exitwith {_allowedBackpacks = 0;}; //Launcher }; } count (weapons player); - + // 12 toolbelt + 1 Binoculars + 1 NVG + 1 Pistol + 1 Primary = 16 (onBack isn't counted in weapons player) //_allowedWeapons = 16 - count(weapons player); // Don't show tool slots as weapon slots in gear. Player is informed of tool slots count in systemChat. @@ -50,7 +51,7 @@ if (_selection == 1) then { //vehicle _allowedMags = _freeSpace select 1; _allowedWeapons = _freeSpace select 2; _allowedBackpacks = _freeSpace select 3; - + _pic = getText (configFile >> "CfgVehicles" >> (typeOf DZE_myVehicle) >> "picture"); (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [ @@ -69,7 +70,7 @@ if (_selection == 0) then { //backpack _freeSpace = [_backpack,0,0,0,0] call Z_calcFreeSpace; _totalSpace = _freeSpace select 0; _totalBagSlots = _freeSpace select 4; - + _pic = getText (configFile >> "CfgVehicles" >> (typeOf _backpack) >> "picture"); (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText format [ @@ -87,4 +88,4 @@ if (_selection == 0) then { //backpack "\z\addons\dayz_code\gui\gear\gear_ui_slots_weapons_white.paa",_returnArray select 1, "\z\addons\dayz_code\gui\gear\gear_ui_slots_items_white.paa",_returnArray select 0, "\z\addons\dayz_code\gui\gear\gear_ui_slots_backpacks_white.paa",_returnArray select 2 -]; \ No newline at end of file +]; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf index 984e63739..1aac58bbc 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf @@ -1,4 +1,4 @@ -private ["_item","_picture","_class","_display","_buyPrice","_sellPrice","_formattedText","_buyCurrency","_sellCurrency","_compatible","_weapon","_attach","_config","_compatibleText","_type","_text","_displayText"]; +private ["_picBuy","_picSell","_item","_picture","_class","_display","_buyPrice","_sellPrice","_formattedText","_buyCurrency","_sellCurrency","_compatible","_weapon","_attach","_config","_compatibleText","_type","_text","_displayText"]; #include "defines.hpp" _item = _this select 0; @@ -114,9 +114,19 @@ if (count _compatible > 0) then { if (_displayText != "") then { _formattedText = _formattedText + format [ - "%1: %2" + "%1: %2
" ,localize "STR_EPOCH_DESCRIPTION",_displayText ]; }; +if (DZE_R3F_WEIGHT) then { + private "_weight"; + + _weight = [getNumber(configFile >> "CfgWeight" >> "Magazines" >> _class >> "weight"),1] select ((configName(inheritsFrom(configFile >> "cfgMagazines" >> _class))) == "SkinBase"); + _formattedText = _formattedText + format [ + "%1: %2 %3" + ,localize "STR_EPOCH_WEIGHT",_weight,localize "STR_R3F_WEIGHT_English" + ]; +}; + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf index de082d0af..faed7eabd 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf @@ -1,6 +1,6 @@ -private ['_item', '_type','_picture',"_class","_display","_transportMaxWeapons","_transportMaxMagazines","_transportmaxBackpacks" +private ['_item','_picture',"_class","_display","_transportMaxWeapons","_transportMaxMagazines","_transportmaxBackpacks" ,"_buyPrice","_sellPrice","_buyCurrency","_sellCurrency","_formattedText","_fuelCapacity","_maxSpeed","_armor","_seats","_weapons", -"_weapons2","_config","_wepText","_turret","_text"]; +"_weapons2","_config","_wepText","_turret","_text","_index","_picSell","_picBuy"]; #include "defines.hpp" @@ -208,5 +208,5 @@ if (count _weapons2 > 0) then { localize "STR_EPOCH_WEAPONS",_wepText ]; }; - + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf index 5a22edf12..497ae2a91 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf @@ -1,4 +1,4 @@ -private ["_item","_picture","_class","_display","_buyPrice","_sellPrice","_magazines","_magText","_formattedText","_buyCurrency","_sellCurrency","_attachments","_attachText","_config","_text","_attach","_type"]; +private ["_parentClasses","_picBuy","_picSell","_item","_picture","_class","_display","_buyPrice","_sellPrice","_magazines","_magText","_formattedText","_buyCurrency","_sellCurrency","_attachments","_attachText","_config","_text","_attach","_type"]; #include "defines.hpp" _item = _this select 0; @@ -124,4 +124,14 @@ if !("ItemCore" in _parentClasses or "Binocular" in _parentClasses) then { ]; }; +if (DZE_R3F_WEIGHT) then { + private "_weight"; + + _weight = getNumber(configFile >> "CfgWeight" >> "Weapons" >> _class >> "weight"); + _formattedText = _formattedText + format [ + "%1: %2 %3" + ,localize "STR_EPOCH_WEIGHT",_weight,localize "STR_R3F_WEIGHT_English" + ]; +}; + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getContainer.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getContainer.sqf index 261f639ed..e6b5d1203 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getContainer.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getContainer.sqf @@ -22,8 +22,8 @@ _backpack = unitBackpack player; call Z_calcPrice; if (Z_Selling) then { - switch (_lbIndex) do { - case 0: { //backpack + call { + if (_lbIndex == 0) exitwith { //backpack if (!isNull _backpack) then { [localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_fillTradeTitle; Z_SellingFrom = 0; @@ -33,7 +33,7 @@ if (Z_Selling) then { (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " "; }; }; - case 1: { //vehicle + if (_lbIndex == 1) exitwith { //vehicle _canBuyInVehicle = true call Z_checkCloseVehicle; if (_canBuyInVehicle) then { [localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_fillTradeTitle; @@ -44,7 +44,7 @@ if (Z_Selling) then { (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " "; }; }; - case 2: { //gear + if (_lbIndex == 2) exitwith { //gear [localize "STR_EPOCH_TRADE_SELLING_GEAR"] call Z_fillTradeTitle; Z_SellingFrom = 2; call Z_getGearItems; @@ -53,8 +53,8 @@ if (Z_Selling) then { } else { ctrlSetText [Z_AT_TRADERLINE2, " "]; ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_SELLING_ALL"]; - switch (_lbIndex) do { - case 0: { //backpack + call { + if (_lbIndex == 0) exitwith { //backpack if (!isNull _backpack) then { Z_SellingFrom = 0; [localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_fillTradeTitle; @@ -64,7 +64,7 @@ if (Z_Selling) then { (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " "; }; }; - case 1: { //vehicle + if (_lbIndex == 1) exitwith { //vehicle _canBuyInVehicle = true call Z_checkCloseVehicle; if (_canBuyInVehicle) then { Z_SellingFrom = 1; @@ -75,7 +75,7 @@ if (Z_Selling) then { (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetStructuredText parseText " "; }; }; - case 2: { //gear + if (_lbIndex == 2) exitwith { //gear Z_SellingFrom = 2; [localize "STR_EPOCH_TRADE_BUYING_GEAR"] call Z_fillTradeTitle; [2] call Z_displayFreeSpace; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf index 11713204c..38f0925d0 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemConfig.sqf @@ -4,24 +4,22 @@ private ['_item', '_type']; _item = _this select 0; _type = _item select 1; -switch (true) do { - case (_type == "trade_items") : +call { + if (_type == "trade_items") exitwith { [_item] call Z_displayItemInfo; }; - case (_type == "trade_weapons") : + if (_type == "trade_weapons") exitwith { [_item] call Z_displayWeaponInfo; }; - case (_type == "trade_backpacks") : + if (_type == "trade_backpacks") exitwith { [_item] call Z_displayBackpackInfo; }; - case (_type in DZE_tradeVehicle) : + if (_type in DZE_tradeVehicle) exitwith { [_item] call Z_displayVehicleInfo; }; - default { - (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText (parseText format["%1",localize "STR_EPOCH_TRADE_NO_INFO"]); - } + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText (parseText format["%1",localize "STR_EPOCH_TRADE_NO_INFO"]); }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemInfo.sqf index 83e5836d4..9dcce1dfc 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getItemInfo.sqf @@ -8,20 +8,20 @@ private ['_item','_selectedList','_selectedIndex']; _selectedList = _this select 0; _selectedIndex = _this select 1; -_item = []; +_item = []; if (_selectedIndex >= 0) then { - switch (_selectedList) do { - case 'sellable': { + call { + if (_selectedList == 'sellable') exitwith { _item = Z_SellableArray select _selectedIndex; }; - case 'selling': { + if (_selectedList == 'selling') exitwith { _item = Z_SellArray select _selectedIndex; }; - case 'buyable': { + if (_selectedList == 'buyable') exitwith { _item = Z_BuyableArray select _selectedIndex; }; - case 'buying': { + if (_selectedList == 'buying') exitwith { _item = Z_BuyingArray select _selectedIndex; }; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf index 296eaf80d..4c0a9baa7 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_logTrade.sqf @@ -7,10 +7,10 @@ _Z_logTrade = { _quantity = _this select 1; _buyOrSell = _this select 2; _price = _this select 3; - _container = switch (Z_SellingFrom) do { - case 0 : {"backpack"}; - case 1 : {"vehicle"}; - case 2 : {"gear"}; + _container = call { + if (Z_SellingFrom == 0) exitwith {"backpack"}; + if (Z_SellingFrom == 1) exitwith {"vehicle"}; + if (Z_SellingFrom == 2) exitwith {"gear"}; }; _price = if (Z_singleCurrency) then {format ["%1 %2",[_price] call BIS_fnc_numberText,CurrencyName]} else {[_price,true,1,1] call Z_calcCurrency}; @@ -20,7 +20,7 @@ _Z_logTrade = { } else { diag_log format["%1: Sold %2x %3 from %4 at %5 for %6",localize "STR_EPOCH_PLAYER_289",_quantity,_className,_container,inTraderCity,_price]; }; - + // Log to server RPT if (DZE_serverLogTrades) then { PVDZE_obj_Trade = [player,0,if (_buyOrSell == "buy") then {0} else {1},_className,inTraderCity,false,_price,_quantity,_container,false]; @@ -48,7 +48,7 @@ for "_i" from 0 to (count _prices)-1 do { _amount = _amounts select _i; _price = _prices select _i; _quantity = {(_className == _x)} count _classNames; - + if (_quantity > 1) then { if !(_className in _queueNames) then {_queueNames set [count _queueNames,_className];}; _index = _queueNames find _className; @@ -63,4 +63,4 @@ if (count _queueNames > 0) then { for "_i" from 0 to (count _queueNames)-1 do { [_queueNames select _i, _queueAmounts select _i, _buyOrSell, _queuePrices select _i] call _Z_logTrade; }; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf index c50414c72..0e4d59296 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf @@ -1,6 +1,6 @@ // Made for DayZ Epoch by vbawol edited for AdvancedTrading by Zupa private ["_return_change","_ItemTopaz","_GemTotal","_GemTotal2","_ItemObsidian","_ItemSapphire", -"_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_total","_briefcase_100oz_a", +"_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_total", "_gold_10oz_a","_gold_10oz_b","_briefcase_100oz","_gold_10oz","_gold_1oz_a","_gold_1oz_b","_gold_1oz", "_silver_10oz_a","_silver_10oz_b","_silver_10oz","_silver_1oz_a","_silver_1oz_b","_silver_1oz", "_successful","_trade_total","_total_currency","_addRegularMag","_justChecking","_moneyAdded", @@ -51,7 +51,7 @@ if (!Z_Selling) then { _addRegularMag = { private ["_backpack","_freeBagSpace","_freeSpace","_regularMags","_justChecking","_moneyAdded","_item","_enoughRoom","_regularMagsToBuy","_moneyInGear","_moneyInBackpack","_freeGearSlots"]; - + _moneyAdded = _this select 0; // Return change _justChecking = _this select 1; _item = _this select 2; @@ -64,10 +64,10 @@ _addRegularMag = { _moneyInGear = 0; // All money was removed in Z_payDefault _moneyInBackpack = 0; // All money was removed in Z_payDefault }; - + _regularMags = {(getNumber (configFile >> "CfgMagazines" >> _x >> "type") == 256)} count (magazines player); // 256 = WeaponSlotItem (normal magazine) _freeGearSlots = 12 - ((_regularMags + _regularMagsToBuy + _moneyAdded) - _moneyInGear); - + if (_justChecking or _freeGearSlots < 0) then { _freeBagSpace = 0; _backpack = unitBackpack player; @@ -78,9 +78,9 @@ _addRegularMag = { _enoughRoom = (_freeGearSlots + _freeBagSpace + _moneyInBackpack) >= 0; // Return change into vehicle or on ground is not advised due to potential for theft }; - + if (_justChecking) exitWith {_enoughRoom}; - + if (_freeGearSlots >= 0) then { player addMagazine _item; } else { @@ -113,50 +113,50 @@ if (_return_change > 0) then { { _gem = _x; _value = DZE_GemWorthList select _forEachIndex; - switch(_gem) do { - case 'ItemTopaz': { + call { + if (_gem == 'ItemTopaz') exitwith { _ItemTopaz = floor(_GemTotal2 / _value); if (_ItemTopaz >= 1) then { _GemTotal = (_value * _ItemTopaz) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemObsidian': { + if (_gem == 'ItemObsidian') exitwith { _ItemObsidian = floor(_GemTotal2 / _value); if (_ItemObsidian >= 1) then { _GemTotal = (_value * _ItemObsidian) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemSapphire': { + if (_gem == 'ItemSapphire') exitwith { _ItemSapphire = floor(_GemTotal2 / _value); if (_ItemSapphire >= 1) then { _GemTotal = (_value * _ItemSapphire) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemAmethyst': { + if (_gem == 'ItemAmethyst') exitwith { _ItemAmethyst = floor(_GemTotal2 / _value); if (_ItemAmethyst >= 1) then { _GemTotal = (_value * _ItemAmethyst) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemEmerald': { + if (_gem == 'ItemEmerald') exitwith { _ItemEmerald = floor(_GemTotal2 / _value); if (_ItemEmerald >= 1) then { _GemTotal = (_value * _ItemEmerald) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemCitrine': { + if (_gem == 'ItemCitrine') exitwith { _ItemCitrine = floor(_GemTotal2 / _value); if (_ItemCitrine >= 1) then { _GemTotal = (_value * _ItemCitrine) + _GemTotal; _GemTotal2 = _total - _GemTotal; }; }; - case 'ItemRuby': { + if (_gem == 'ItemRuby') exitwith { _ItemRuby = floor(_GemTotal2 / _value); if (_ItemRuby >= 1) then { _GemTotal = (_value * _ItemRuby) + _GemTotal; @@ -254,13 +254,13 @@ if (_return_change > 0) then { if (_justChecking) then { _moneyAdded = _moneyAdded + 1; } else { [1,false,format["ItemSilverBar%1oz",_silver_1oz]] call _addRegularMag; }; }; }; - + if (_justChecking) then { _successful = [_moneyAdded,true,"",_regularMagsToBuy,_moneyInGear,_moneyInBackpack] call _addRegularMag; } else { _successful = true; }; - + if (_combine) then {call player_forceSave;}; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf index cff1fa0b4..76c77aed0 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -1,9 +1,8 @@ -private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold","_wealth"]; +private ["_sellVehicle","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_bag","_itemsToLog","_tCost","_tSold","_wealth"]; if (count Z_SellArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_SELL_NO_ITEMS"; }; if (Z_SellingFrom == 1 && (isNull DZE_myVehicle or !local DZE_myVehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; }; -_tempArray = Z_SellArray; closeDialog 2; _outcome = []; _weaponsArray = []; @@ -17,7 +16,7 @@ _itemsCheckArray = []; _itemsToLog = [[],[],[],"sell"]; _sellVehicle = { - private ["_damage","_tireDmg","_tires","_okToSell","_returnInfo","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_vehicle"]; + private ["_damage","_tireDmg","_tires","_okToSell","_returnInfo","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_vehicle","_sellType"]; _vehicle = _this select 0; _sellType = _this select 1; _returnInfo = []; @@ -66,24 +65,20 @@ _sellVehicle = { _type = _x select 1; _name = _x select 0; - switch (true) do { - case (_type == "trade_items") : - { + call { + if (_type == "trade_items") exitwith { _itemsArray set [count(_itemsArray),_name]; _itemsCheckArray set [count(_itemsCheckArray),[_x select 2, _x select 11]]; }; - case (_type == "trade_weapons") : - { + if (_type == "trade_weapons") exitwith { _weaponsArray set [count(_weaponsArray),_name]; _weaponsCheckArray set [count(_weaponsCheckArray),[_x select 2, _x select 11]]; }; - case (_type == "trade_backpacks") : - { + if (_type == "trade_backpacks") exitwith { _bpArray set [count(_bpArray),_name]; _bpCheckArray set [count(_bpCheckArray),[_x select 2, _x select 11]]; }; - case (_type in DZE_tradeVehicle) : - { + if (_type in DZE_tradeVehicle) exitwith { if (local DZE_myVehicle) then { _VehKey = [DZE_myVehicle, _type] call _sellVehicle; if (count _VehKey > 0) then { @@ -112,7 +107,7 @@ _itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf DZE_myVehic //gear if (Z_SellingFrom == 2) then { - private ["_localResult", "_vehTraded"]; + private ["_localResult", "_vehTraded","_bagTraded","_name","_type"]; _wA = []; _mA = []; _vehTraded = false; @@ -185,7 +180,7 @@ if (Z_SingleCurrency) then { _money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x); _itemsToLog set [2, (_itemsToLog select 2) + [((((_bpCheckArray select _forEachIndex) select 0)) * _x)]]; } forEach (_outcome select 2); - + if (count _outcome > 3) then { _money = _money + ((_vehCheckArray select 0) select 0); _itemsToLog set [2, (_itemsToLog select 2) + [((_vehCheckArray select 0) select 0)]]; @@ -219,7 +214,7 @@ if (typeName _money == "SCALAR") then { player setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth + _money),true]; systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE",[_money] call BIS_fnc_numberText,CurrencyName]; } else { - _success = [_money,0,false,0,[],[],false] call Z_returnChange; + [_money,0,false,0,[],[],false] call Z_returnChange; _tCost = ""; _tCost = [_money,true] call z_calcCurrency; if (_tCost != "") then { systemChat format[localize "STR_EPOCH_TRADE_SELL_SUCCESS",_tCost]; }; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf index 1c63edc39..6d0fac18b 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf @@ -6,7 +6,7 @@ Author: Zupa 2014-09-30 ---------------------------------------------------------------------------- */ -private ["_vehInfo","_inCargo","_object","_mags","_weaps","_normalMags","_normalWeaps","_returnVar","_returnMag","_returnWeap","_freeSpace"]; +private ["_vehInfo","_inCargo","_object","_mags","_weaps","_normalMags","_normalWeaps","_returnVar","_returnMag","_returnWeap","_freeSpace","_sell"]; _object = _this select 0; _mags = _this select 1; @@ -65,4 +65,4 @@ _returnVar set [0,_returnMag]; _returnVar set [1,_returnWeap]; _returnVar set [2,[]]; -_returnVar \ No newline at end of file +_returnVar