From 3a3413caf5ab4696adb9dc4fcf48019004532ca9 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Mon, 31 Oct 2016 13:54:40 -0400 Subject: [PATCH] Allow tools to exceed transportMaxWeapons when buying in bag --- .../functions/z_at_calcFreeSpace.sqf | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcFreeSpace.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcFreeSpace.sqf index 51b4fc775..c72b6c1f0 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcFreeSpace.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcFreeSpace.sqf @@ -1,7 +1,7 @@ private ["_object","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3", "_counter","_allowedMags","_allowedWeapons","_allowedBackpacks","_currentPrim","_currentSec","_currentTool", "_parentClasses","_alreadyInBackpack","_totalNewSpace","_primaryToBuy","_sidearmToBuy","_toolsToBuy", -"_toBuyTotalMags","_totalSpace","_bags","_totalBagSlots"]; +"_toBuyTotalMags","_totalSpace","_bags","_totalBagSlots","_type","_isBackpack","_notTools"]; _object = _this select 0; _primaryToBuy = _this select 1; // Only needed if backpack @@ -9,6 +9,8 @@ _sidearmToBuy = _this select 2; // Only needed if backpack _toolsToBuy = _this select 3; // Only needed if backpack _toBuyTotalMags = _this select 4; // Only needed if backpack +_type = typeOf _object; +_isBackpack = _type isKindOf "Bag_Base_EP1"; _allowedMags = 0; _allowedWeapons = 0; _allowedBackpacks = 0; @@ -21,6 +23,7 @@ _bags = getBackpackCargo _object; _normalMags = []; _normalWeaps = []; _normalBags = []; +_notTools = []; _kinds = _mags select 0; _amounts = _mags select 1; @@ -38,6 +41,7 @@ _amounts2 = _weaps select 1; _counter = 0; while {_counter < (_amounts2 select _forEachIndex)} do { _normalWeaps set [count _normalWeaps, _x]; + if !(getNumber (configFile >> "CfgWeapons" >> _x >> "type") in [4096,131072]) then {_notTools set [count _notTools,_x];}; _counter = _counter + 1; }; } forEach _kinds2; @@ -52,11 +56,12 @@ _amounts3 = _bags select 1; }; } forEach _kinds3; -_allowedMags = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxMagazines") - count(_normalMags); -_allowedWeapons = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxWeapons") - count(_normalWeaps); -_allowedBackpacks = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxBackpacks") - count(_normalBags); +_allowedBackpacks = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxBackpacks") - count(_normalBags); +_allowedMags = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxMagazines") - count(_normalMags); +_allowedWeapons = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxWeapons"); +_allowedWeapons = if (_isBackpack) then {_allowedWeapons - count(_notTools)} else {_allowedWeapons - count(_normalWeaps)}; //tools and binocs can exceed transportMaxWeapons in backpacks but not vehicles -if (_object isKindOf "Bag_Base_EP1") then { +if (_isBackpack) then { // Different weapon types take up different amounts of space in backpacks, but not vehicles _currentPrim = 0; _currentSec = 0; @@ -75,7 +80,7 @@ if (_object isKindOf "Bag_Base_EP1") then { } count _normalWeaps; //transportMaxMagazines is the same as total number of 1x slots in backpack - _totalBagSlots = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxMagazines"); + _totalBagSlots = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxMagazines"); _alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags); _totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyTotalMags;