mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Fix incorrect backpack space calculation
Fixes not being able to purchase into a half full backpack and free slot counts text incorrect when buying into backpack.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
private["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBackpacks","_allowedTools","_allowedPrimary","_allowedSidearm","_formattedText","_pic"
|
||||
,"_backpack","_vehicleWeapons","_vehicleMagazines","_vehicleBackpacks","_tempWeaponsArray","_tempBackpackArray","_tempMagazinesArray","_actualMags"];
|
||||
,"_backpack","_vehicleWeapons","_vehicleMagazines","_vehicleBackpacks","_tempWeaponsArray","_tempBackpackArray","_tempMagazinesArray","_actualMags"
|
||||
,"_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2","_counter"];
|
||||
#include "defines.sqf";
|
||||
|
||||
_selection = _this select 0;
|
||||
@@ -69,13 +70,11 @@ if(_selection == 1) then{ //vehicle
|
||||
_returnArray = [_allowedMags - _vehicleMagazines, _allowedWeapons - _vehicleWeapons, _allowedBackpacks - _vehicleBackpacks];
|
||||
};
|
||||
if(_selection == 0) then{ //backpack
|
||||
_allowedWeapons = 0;
|
||||
_allowedMags = 0;
|
||||
_allowedBackpacks = 0;
|
||||
_vehicleMagazines = 0;
|
||||
_vehicleWeapons = 0;
|
||||
_totalBagSlots = 0;
|
||||
_alreadyInBackpack = 0;
|
||||
_backpack = unitBackpack player;
|
||||
if (!isNil "_backpack") then {
|
||||
if (!isNull _backpack) then {
|
||||
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'picture');
|
||||
|
||||
_formattedText = format [
|
||||
@@ -84,23 +83,51 @@ if(_selection == 0) then{ //backpack
|
||||
];
|
||||
|
||||
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
|
||||
_tempMagazinesArray = getMagazineCargo Z_vehicle;
|
||||
|
||||
_tempMagazinesArray = getMagazineCargo _backpack;
|
||||
_tempWeaponsArray = getWeaponCargo _backpack;
|
||||
_normalMags = [];
|
||||
_normalWeaps = [];
|
||||
|
||||
_kinds = _tempMagazinesArray select 0;
|
||||
_amounts = _tempMagazinesArray select 1;
|
||||
{
|
||||
_vehicleMagazines = _vehicleMagazines + _x;
|
||||
}count ( _tempMagazinesArray select 1);
|
||||
|
||||
|
||||
_tempWeaponsArray = getWeaponCargo Z_vehicle;
|
||||
_counter = 0;
|
||||
while {_counter < (_amounts select _forEachIndex)} do {
|
||||
_normalMags set [count(_normalMags), _x];
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
} forEach _kinds;
|
||||
|
||||
_kinds2 = _tempWeaponsArray select 0;
|
||||
_amounts2 = _tempWeaponsArray select 1;
|
||||
{
|
||||
_vehicleWeapons = _vehicleWeapons + _x;
|
||||
}count ( _tempWeaponsArray select 1);
|
||||
_counter = 0;
|
||||
while {_counter < (_amounts2 select _forEachIndex)} do {
|
||||
_normalWeaps set [count(_normalWeaps), _x];
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
} forEach _kinds2;
|
||||
|
||||
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxWeapons');
|
||||
_allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines');
|
||||
_allowedBackpacks = 0;
|
||||
_totalBagSlots = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines');
|
||||
_currentPrim = 0;
|
||||
_currentSec = 0;
|
||||
_currentTool = 0;
|
||||
{
|
||||
_parentClasses = [(configFile >> "CfgWeapons" >> _x ),true] call BIS_fnc_returnParents;
|
||||
if ('ItemCore' in _parentClasses or 'Binocular' in _parentClasses) then {
|
||||
_currentTool = _currentTool + 1;
|
||||
} else {
|
||||
if ('PistolCore' in _parentClasses) then {
|
||||
_currentSec = _currentSec + 1;
|
||||
} else {
|
||||
_currentPrim = _currentPrim + 1;
|
||||
};
|
||||
};
|
||||
} count _normalWeaps;
|
||||
|
||||
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
|
||||
};
|
||||
_returnArray = [_allowedMags - _vehicleMagazines ,_allowedWeapons - _vehicleWeapons, _allowedBackpacks];
|
||||
_returnArray = [_totalBagSlots - _alreadyInBackpack, floor((_totalBagSlots - _alreadyInBackpack) / 10), _allowedBackpacks];
|
||||
};
|
||||
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetText format["%1/%2/%3",_returnArray select 1,_returnArray select 0,_returnArray select 2];
|
||||
|
||||
Reference in New Issue
Block a user