Merge pull request #1972 from oiad/patch-12

Fix javelin/stinger selling
This commit is contained in:
icomrade
2017-09-08 10:04:10 -04:00
committed by GitHub

View File

@@ -19,114 +19,113 @@ _vehTrade = false;
_baseVehicle = ""; _baseVehicle = "";
_myVehType = typeOf DZE_myVehicle; _myVehType = typeOf DZE_myVehicle;
if (false call Z_checkCloseVehicle) then {
_baseVehicle = getText (configFile >> "CfgVehicles" >> _myVehType >> "original");
_all = _weaps + _mags + _bags + [_myVehType];
_vehTrade = true;
} else {
_all = _weaps + _mags + _bags;
};
_arrayOfTraderCat = Z_traderData; _arrayOfTraderCat = Z_traderData;
_HasKeyCheck = { _HasKeyCheck = {
_obj = _this select 0; private ["_objectCharacterID","_keyFound","_tempKeys"];
_inventory = _this select 1;
_keyFound = false; _keyFound = false;
_objectCharacterId = _obj getVariable ["CharacterID","0"]; _objectCharacterId = DZE_myVehicle getVariable ["CharacterID","0"];
if (_objectCharacterId == "0") then { if (_objectCharacterId == "0") then {
_keyFound = true; _keyFound = true;
} else { } else {
_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]; _tempKeys = call epoch_tempKeys;
{ if (((_tempKeys select 0) find _objectCharacterID) >= 0) then {_keyFound = true;};
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then {
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
_keyFound = true;
};
};
} count _inventory;
}; };
_keyFound; _keyFound;
}; };
_totalPrice = 0; _totalPrice = 0;
{ _processGear = {
_y = _x; private ["_array","_type","_cat","_exists","_pic","_text","_sell","_buy","_buyCurrency","_sellCurrency","_worth"];
_swap = false;
_swap2 = false; _type = _this select 1;
if (_y == "ItemBloodbag" && dayz_classicBloodBagSystem) then {
_y = "bloodBagONEG";
_swap = true;
};
if (_y == _myVehType && {_baseVehicle != ""}) then {
_swap2 = true;
};
{ {
private ["_cat","_exists","_pic","_text","_type","_sell","_buy","_buyCurrency","_sellCurrency","_worth"]; _y = _x;
_cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)]; _swap = false;
if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then { _swap2 = false;
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")]; if (_y == "ItemBloodbag" && dayz_classicBloodBagSystem) then {
_y = "bloodBagONEG";
_swap = true;
}; };
if (_swap2 && {!isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y)} && {isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _baseVehicle)}) then { if (_y == _myVehType && {_baseVehicle != ""}) then {
//Use base vehicle prices for upgraded _DZE[1-4] variants only if they are not explicitly added in trader config _swap2 = true;
_y = _baseVehicle;
}; };
_exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y); {
if (_exists) exitWith { _cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)];
_pic = ""; if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then {
_text = ""; _cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
_type = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type");
// Make sure type matches for items that have the same weapon and magazine classname (i.e. PipeBomb, Mine, Javelin, etc.)
if ((_type == "trade_items" && !(_y in _mags) && !_swap) or (_type == "trade_weapons" && !(_y in _weaps))) exitWith {};
_sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
if (_swap) then {_y = "ItemBloodbag"};
switch (true) do {
case (_type == "trade_items") :
{
_pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture');
_text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName');
};
case (_type == "trade_weapons") :
{
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
};
case (_type in DZE_tradeObject) :
{
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
};
}; };
if (_swap2 && {!isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y)} && {isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _baseVehicle)}) then {
//Use base vehicle prices for upgraded _DZE[1-4] variants only if they are not explicitly added in trader config
_y = _baseVehicle;
};
_exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y);
if (_exists) exitWith {
_pic = "";
_text = "";
if (isNil '_text') then { _text = _y; }; _sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
_HasKey = true; _buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
if (_vehTrade && {_y == _myVehType}) then { if (_swap) then {_y = "ItemBloodbag"};
if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then { switch (true) do {
_HasKey = [DZE_myVehicle, _all] call _HasKeyCheck; case (_type == "trade_items") :
{
_pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture');
_text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName');
};
case (_type == "trade_weapons") :
{
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
};
case (_type in DZE_tradeObject) :
{
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
};
}; };
};
if (!_HasKey) exitWith {};
_worth = 0; if (isNil '_text') then { _text = _y; };
_currencyQty = _buy select 0; _HasKey = true;
if (!Z_SingleCurrency) then { if (_vehTrade && {_y == _myVehType}) then {
_buyCurrency = _buy select 1; if (!(_type in DZE_tradeVehicleKeyless) && DZE_SaleRequiresKey) then {
_sellCurrency = _sell select 1; _HasKey = call _HasKeyCheck;
_part = (configFile >> "CfgMagazines" >> _sellCurrency); };
_worth = getNumber(_part >> "worth"); };
if (_worth == 0) then { _worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency); }; if (!_HasKey || {_y == _myVehType && Z_SellingFrom != 2}) exitWith {};
} else {
_buyCurrency = CurrencyName; _worth = 0;
_sellCurrency = CurrencyName; _currencyQty = _buy select 0;
if (!Z_SingleCurrency) then {
_buyCurrency = _buy select 1;
_sellCurrency = _sell select 1;
_part = (configFile >> "CfgMagazines" >> _sellCurrency);
_worth = getNumber(_part >> "worth");
if (_worth == 0) then { _worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency); };
} else {
_buyCurrency = CurrencyName;
_sellCurrency = CurrencyName;
};
if (_currencyQty < 0) then {_buyCurrency = localize "STR_EPOCH_UNAVAILABLE";};
if ((_sell select 0) >= 0) then {
Z_SellableArray set [count(Z_SellableArray) , [_y, _type, _sell select 0, _text, _pic, _forEachIndex, _currencyQty, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]];
};
_totalPrice = _totalPrice + (_sell select 0);
}; };
if (_currencyQty < 0) then {_buyCurrency = localize "STR_EPOCH_UNAVAILABLE";}; } forEach _arrayOfTraderCat;
if ((_sell select 0) >= 0) then { } count (_this select 0);
Z_SellableArray set [count(Z_SellableArray) , [_y, _type, _sell select 0, _text, _pic, _forEachIndex, _currencyQty, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]]; };
};
_totalPrice = _totalPrice + (_sell select 0); if (false call Z_checkCloseVehicle) then {
}; _baseVehicle = getText (configFile >> "CfgVehicles" >> _myVehType >> "original");
} forEach _arrayOfTraderCat; _vehTrade = true;
} count _all; [[_myVehType],"trade_any_vehicle"] call _processGear;
};
[_weaps,"trade_weapons"] call _processGear;
[_mags,"trade_items"] call _processGear;
[_bags,"trade_backpacks"] call _processGear;
Z_OriginalSellableArray = [] + Z_SellableArray; Z_OriginalSellableArray = [] + Z_SellableArray;