mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Allow tools to exceed transportMaxWeapons when buying in bag
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
private ["_object","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3",
|
private ["_object","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3",
|
||||||
"_counter","_allowedMags","_allowedWeapons","_allowedBackpacks","_currentPrim","_currentSec","_currentTool",
|
"_counter","_allowedMags","_allowedWeapons","_allowedBackpacks","_currentPrim","_currentSec","_currentTool",
|
||||||
"_parentClasses","_alreadyInBackpack","_totalNewSpace","_primaryToBuy","_sidearmToBuy","_toolsToBuy",
|
"_parentClasses","_alreadyInBackpack","_totalNewSpace","_primaryToBuy","_sidearmToBuy","_toolsToBuy",
|
||||||
"_toBuyTotalMags","_totalSpace","_bags","_totalBagSlots"];
|
"_toBuyTotalMags","_totalSpace","_bags","_totalBagSlots","_type","_isBackpack","_notTools"];
|
||||||
|
|
||||||
_object = _this select 0;
|
_object = _this select 0;
|
||||||
_primaryToBuy = _this select 1; // Only needed if backpack
|
_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
|
_toolsToBuy = _this select 3; // Only needed if backpack
|
||||||
_toBuyTotalMags = _this select 4; // Only needed if backpack
|
_toBuyTotalMags = _this select 4; // Only needed if backpack
|
||||||
|
|
||||||
|
_type = typeOf _object;
|
||||||
|
_isBackpack = _type isKindOf "Bag_Base_EP1";
|
||||||
_allowedMags = 0;
|
_allowedMags = 0;
|
||||||
_allowedWeapons = 0;
|
_allowedWeapons = 0;
|
||||||
_allowedBackpacks = 0;
|
_allowedBackpacks = 0;
|
||||||
@@ -21,6 +23,7 @@ _bags = getBackpackCargo _object;
|
|||||||
_normalMags = [];
|
_normalMags = [];
|
||||||
_normalWeaps = [];
|
_normalWeaps = [];
|
||||||
_normalBags = [];
|
_normalBags = [];
|
||||||
|
_notTools = [];
|
||||||
|
|
||||||
_kinds = _mags select 0;
|
_kinds = _mags select 0;
|
||||||
_amounts = _mags select 1;
|
_amounts = _mags select 1;
|
||||||
@@ -38,6 +41,7 @@ _amounts2 = _weaps select 1;
|
|||||||
_counter = 0;
|
_counter = 0;
|
||||||
while {_counter < (_amounts2 select _forEachIndex)} do {
|
while {_counter < (_amounts2 select _forEachIndex)} do {
|
||||||
_normalWeaps set [count _normalWeaps, _x];
|
_normalWeaps set [count _normalWeaps, _x];
|
||||||
|
if !(getNumber (configFile >> "CfgWeapons" >> _x >> "type") in [4096,131072]) then {_notTools set [count _notTools,_x];};
|
||||||
_counter = _counter + 1;
|
_counter = _counter + 1;
|
||||||
};
|
};
|
||||||
} forEach _kinds2;
|
} forEach _kinds2;
|
||||||
@@ -52,11 +56,12 @@ _amounts3 = _bags select 1;
|
|||||||
};
|
};
|
||||||
} forEach _kinds3;
|
} forEach _kinds3;
|
||||||
|
|
||||||
_allowedMags = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxMagazines") - count(_normalMags);
|
_allowedBackpacks = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxBackpacks") - count(_normalBags);
|
||||||
_allowedWeapons = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxWeapons") - count(_normalWeaps);
|
_allowedMags = getNumber (configFile >> "CfgVehicles" >> _type >> "transportMaxMagazines") - count(_normalMags);
|
||||||
_allowedBackpacks = getNumber (configFile >> "CfgVehicles" >> (typeOf _object) >> "transportMaxBackpacks") - count(_normalBags);
|
_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
|
// Different weapon types take up different amounts of space in backpacks, but not vehicles
|
||||||
_currentPrim = 0;
|
_currentPrim = 0;
|
||||||
_currentSec = 0;
|
_currentSec = 0;
|
||||||
@@ -75,7 +80,7 @@ if (_object isKindOf "Bag_Base_EP1") then {
|
|||||||
} count _normalWeaps;
|
} count _normalWeaps;
|
||||||
|
|
||||||
//transportMaxMagazines is the same as total number of 1x slots in backpack
|
//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);
|
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
|
||||||
_totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyTotalMags;
|
_totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyTotalMags;
|
||||||
|
|||||||
Reference in New Issue
Block a user