diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index 181d81c7e..cc09237ec 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -30,6 +30,8 @@ [NEW] Added waves effect during stormy weather #974 @FramedYannick @ebaydayz [NEW] Optional variable to prevent stealing from backpacks by non-friendlies at traders. Set DZE_BackpackAntiTheft = true; in init.sqf @ebaydayz [NEW] Zupa's Advanced Trading is now included as part of the Epoch Code, enabled with DZE_advancedTrading = true; NOT COMPATIBLE WITH DATABASE TRADERS @icomrade @Windmolders +[NEW] Gems are now treated as variable value currency (Advanced Trading only). configure gem values using DZE_GemWorthArray =[]; see ConfigVariables.sqf for more info +[NEW] Gem rarity is now configurable for mining using DZE_GemOccurance =[]; see ConfigVariables.sqf for more info [CHANGED] Many duplicate functions and variables were renamed. See Documents\1.0.6 Variable Name Changes.txt @ebaydayz [CHANGED] Several weapon, item and tool classnames changed. Admins see SQL\1.0.6_Updates @ebaydayz 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 5ad066d7d..fd7b721a2 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcBuyableList.sqf @@ -41,6 +41,9 @@ _counter = 0; _sellCurrency = _sell select 1, _part = (configFile >> "CfgMagazines" >> _buyCurrency); _worth = getNumber(_part >> "worth"); + if (_worth == 0) then { + _worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency); + }; }else{ _buyCurrency = CurrencyName; _sellCurrency = CurrencyName; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf index 4af9aa788..351cea82a 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_calcDefaultCurrency.sqf @@ -1,9 +1,75 @@ -private["_worth","_string","_briefcase_100oz","_gold_10oz_a","_gold_10oz_b","_gold_10oz","_gold_1oz","_gold_1oz_b","_gold_1oz_a","_silver_10oz","_silver_10oz_a","_silver_10oz_b" -,"_silver_1oz","_silver_1oz_a","_silver_10oz_b","_pic","_string" -]; +private ["_ItemTopaz","_GemTotal","_ItemTopaz_ItemTopaz","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_pic","_string","_total","_briefcase_100oz","_gold_10oz_a","_gold_10oz_b","_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"]; + _total = _this; _string = ""; +_ItemTopaz = 0; +_ItemObsidian = 0; +_ItemSapphire = 0; +_ItemAmethyst = 0; +_ItemEmerald = 0; +_ItemCitrine = 0; +_ItemRuby = 0; +_GemTotal = 0; +_GemTotal2 = _total; + +{ + _gem = _x; + _value = DZE_GemWorthList select _forEachIndex; + switch(_gem) do { + case 'ItemTopaz': { + _ItemTopaz = floor(_GemTotal2 / _value); + if (_ItemTopaz >= 1) then { + _GemTotal = (_value * _ItemTopaz) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemObsidian': { + _ItemObsidian = floor(_GemTotal2 / _value); + if (_ItemObsidian >= 1) then { + _GemTotal = (_value * _ItemObsidian) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemSapphire': { + _ItemSapphire = floor(_GemTotal2 / _value); + if (_ItemSapphire >= 1) then { + _GemTotal = (_value * _ItemSapphire) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemAmethyst': { + _ItemAmethyst = floor(_GemTotal2 / _value); + if (_ItemAmethyst >= 1) then { + _GemTotal = (_value * _ItemAmethyst) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemEmerald': { + _ItemEmerald = floor(_GemTotal2 / _value); + if (_ItemEmerald >= 1) then { + _GemTotal = (_value * _ItemEmerald) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemCitrine': { + _ItemCitrine = floor(_GemTotal2 / _value); + if (_ItemCitrine >= 1) then { + _GemTotal = (_value * _ItemCitrine) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemRuby': { + _ItemRuby = floor(_GemTotal2 / _value); + if (_ItemRuby >= 1) then { + _GemTotal = (_value * _ItemRuby) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + }; +} forEach DZE_GemList; +_total = _GemTotal2; + _briefcase_100oz = floor(_total / 10000); _gold_10oz_a = floor(_total / 1000); @@ -22,10 +88,37 @@ _silver_1oz_a = floor(_total); _silver_1oz_b = _silver_10oz_a * 10; _silver_1oz = (_silver_1oz_a - _silver_1oz_b); - +if (_ItemTopaz > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemTopaz' >> 'picture'); + _string = format["%1x",_ItemTopaz,_pic, _string]; +}; +if (_ItemObsidian > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemObsidian' >> 'picture'); + _string = format["%1x",_ItemObsidian,_pic, _string]; +}; +if (_ItemSapphire > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemSapphire' >> 'picture'); + _string = format["%1x",_ItemSapphire,_pic, _string]; +}; +if (_ItemAmethyst > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemAmethyst' >> 'picture'); + _string = format["%1x",_ItemAmethyst,_pic, _string]; +}; +if (_ItemEmerald > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemEmerald' >> 'picture'); + _string = format["%1x",_ItemEmerald,_pic, _string]; +}; +if (_ItemCitrine > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemCitrine' >> 'picture'); + _string = format["%1x",_ItemCitrine,_pic, _string]; +}; +if (_ItemRuby > 0) then { + _pic = getText (configFile >> 'CfgMagazines' >> 'ItemRuby' >> 'picture'); + _string = format["%1x",_ItemRuby,_pic, _string]; +}; if (_briefcase_100oz > 0) then { _pic = getText (configFile >> 'CfgMagazines' >> 'ItemBriefcase100oz' >> 'picture'); - _string = format["%1x",_briefcase_100oz,_pic]; + _string = format["%1x",_briefcase_100oz,_pic, _string]; }; if (_gold_10oz > 0) then { _pic = getText (configFile >> 'CfgMagazines' >> 'ItemGoldBar10oz' >> 'picture'); diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf index 92daa3795..00897c6ee 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_canAfford.sqf @@ -12,60 +12,83 @@ _inventoryMoney = []; if isNumber (_worth) then { _total_currency = _total_currency + getNumber(_worth); _inventoryMoney set [count(_inventoryMoney),_x]; + } else { + _findGem = DZE_GemList find _x; + if (_findGem >= 0) then { + _worth = DZE_GemWorthList select _findGem; + _total_currency = _total_currency + _worth; + _inventoryMoney set [count(_inventoryMoney),_x]; + }; }; } count (magazines player); _return set [1, _inventoryMoney]; if( Z_AllowTakingMoneyFromBackpack ) then { - _backpackPlayer = unitBackpack player; - - if (!isNull _backpackPlayer) then { - _mags = getMagazineCargo _backpackPlayer; - _backpackMoney = []; - _kinds = _mags select 0; - _ammmounts = _mags select 1; - { - _part = (configFile >> "CfgMagazines" >> _x); - _worth = (_part >> "worth"); - - if isNumber (_worth) then { - _total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex)); - - _counter = 0 ; - while{ _counter < ( _ammmounts select _forEachIndex)}do{ - _backpackMoney set [count(_backpackMoney),_x]; - _counter = _counter + 1; - }; - }; - }forEach _kinds; - _return set [2, _backpackMoney]; - - }; + _backpackPlayer = unitBackpack player; + if (!isNull _backpackPlayer) then { + _mags = getMagazineCargo _backpackPlayer; + _backpackMoney = []; + _kinds = _mags select 0; + _ammmounts = _mags select 1; + { + _part = (configFile >> "CfgMagazines" >> _x); + _worth = (_part >> "worth"); + if isNumber (_worth) then { + _total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex)); + _counter = 0 ; + while{_counter < (_ammmounts select _forEachIndex)} do { + _backpackMoney set [count(_backpackMoney),_x]; + _counter = _counter + 1; + }; + } else { + _findGem = DZE_GemList find _x; + if (_findGem >= 0) then { + _worth = DZE_GemWorthList select _findGem; + _total_currency = _total_currency + (_worth * (_ammmounts select _forEachIndex)); + _counter = 0 ; + while{_counter < (_ammmounts select _forEachIndex)} do { + _backpackMoney set [count(_backpackMoney),_x]; + _counter = _counter + 1; + }; + }; + }; + } forEach _kinds; + _return set [2, _backpackMoney]; + }; }; if( Z_AllowTakingMoneyFromVehicle ) then { - if (!isNull Z_vehicle) then { - - _mags = getMagazineCargo Z_vehicle; - _vehicleMoney = []; - _kinds = _mags select 0; - _ammmounts = _mags select 1; - { - _part = (configFile >> "CfgMagazines" >> _x); - _worth = (_part >> "worth"); - - if isNumber (_worth) then { - _total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex)); - _counter = 0 ; - while{ _counter < ( _ammmounts select _forEachIndex)}do{ - _vehicleMoney set [count(_vehicleMoney),_x]; - _counter = _counter + 1; - }; - }; - }forEach _kinds; - _return set [3, _vehicleMoney]; - }; + if (!isNull Z_vehicle) then { + _mags = getMagazineCargo Z_vehicle; + _vehicleMoney = []; + _kinds = _mags select 0; + _ammmounts = _mags select 1; + { + _part = (configFile >> "CfgMagazines" >> _x); + _worth = (_part >> "worth"); + if isNumber (_worth) then { + _total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex)); + _counter = 0 ; + while{_counter < ( _ammmounts select _forEachIndex)}do{ + _vehicleMoney set [count(_vehicleMoney),_x]; + _counter = _counter + 1; + }; + } else { + _findGem = DZE_GemList find _x; + if (_findGem >= 0) then { + _worth = DZE_GemWorthList select _findGem; + _total_currency = _total_currency + (_worth * (_ammmounts select _forEachIndex)); + _counter = 0 ; + while{_counter < (_ammmounts select _forEachIndex)} do { + _backpackMoney set [count(_backpackMoney),_x]; + _counter = _counter + 1; + }; + }; + }; + } forEach _kinds; + _return set [3, _vehicleMoney]; + }; }; if ( _totalToPay <= _total_currency) then { 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 be2b94eb8..ba8617be4 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_checkArrayInConfig.sqf @@ -91,6 +91,9 @@ if(_total > 0)then{ _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; 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 85b02b764..58a5d3c30 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_returnChange.sqf @@ -1,5 +1,5 @@ // Made for DayZ Epoch by vbawol edited for AdvancedTrading by Zupa -private ["_trade_total","_part_inWorth","_part_in_configClass","_total_currency","_part","_worth","_return_change","_total","_briefcase_100oz","_gold_10oz_a","_gold_10oz_b","_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","_buyOrSell","_total_items"]; +private ["_return_change","_ItemTopaz","_GemTotal","_GemTotal2","_ItemObsidian","_ItemSapphire","_ItemAmethyst","_ItemEmerald","_ItemCitrine","_ItemRuby","_gem","_value","_total","_briefcase_100oz_a","_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"]; _successful = false; @@ -17,6 +17,72 @@ if (!Z_Selling) then { if (_return_change > 0) then { _total = _return_change; + _ItemTopaz = 0; + _ItemObsidian = 0; + _ItemSapphire = 0; + _ItemAmethyst = 0; + _ItemEmerald = 0; + _ItemCitrine = 0; + _ItemRuby = 0; + _GemTotal = 0; + _GemTotal2 = _total; + + { + _gem = _x; + _value = DZE_GemWorthList select _forEachIndex; + switch(_gem) do { + case 'ItemTopaz': { + _ItemTopaz = floor(_GemTotal2 / _value); + if (_ItemTopaz >= 1) then { + _GemTotal = (_value * _ItemTopaz) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemObsidian': { + _ItemObsidian = floor(_GemTotal2 / _value); + if (_ItemObsidian >= 1) then { + _GemTotal = (_value * _ItemObsidian) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemSapphire': { + _ItemSapphire = floor(_GemTotal2 / _value); + if (_ItemSapphire >= 1) then { + _GemTotal = (_value * _ItemSapphire) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemAmethyst': { + _ItemAmethyst = floor(_GemTotal2 / _value); + if (_ItemAmethyst >= 1) then { + _GemTotal = (_value * _ItemAmethyst) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemEmerald': { + _ItemEmerald = floor(_GemTotal2 / _value); + if (_ItemEmerald >= 1) then { + _GemTotal = (_value * _ItemEmerald) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemCitrine': { + _ItemCitrine = floor(_GemTotal2 / _value); + if (_ItemCitrine >= 1) then { + _GemTotal = (_value * _ItemCitrine) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + case 'ItemRuby': { + _ItemRuby = floor(_GemTotal2 / _value); + if (_ItemRuby >= 1) then { + _GemTotal = (_value * _ItemRuby) + _GemTotal; + _GemTotal2 = _total - _GemTotal; + }; + }; + }; + } forEach DZE_GemList; + _total = _GemTotal2; _briefcase_100oz = floor(_total / 10000); @@ -36,6 +102,41 @@ if (_return_change > 0) then { _silver_1oz_b = _silver_10oz_a * 10; _silver_1oz = (_silver_1oz_a - _silver_1oz_b); + if (_ItemTopaz > 0) then { + for "_x" from 1 to _ItemTopaz do { + player addMagazine "ItemTopaz"; + }; + }; + if (_ItemObsidian > 0) then { + for "_x" from 1 to _ItemObsidian do { + player addMagazine "ItemObsidian"; + }; + }; + if (_ItemSapphire > 0) then { + for "_x" from 1 to _ItemSapphire do { + player addMagazine "ItemSapphire"; + }; + }; + if (_ItemAmethyst > 0) then { + for "_x" from 1 to _ItemAmethyst do { + player addMagazine "ItemAmethyst"; + }; + }; + if (_ItemEmerald > 0) then { + for "_x" from 1 to _ItemEmerald do { + player addMagazine "ItemEmerald"; + }; + }; + if (_ItemCitrine > 0) then { + for "_x" from 1 to _ItemCitrine do { + player addMagazine "ItemCitrine"; + }; + }; + if (_ItemRuby > 0) then { + for "_x" from 1 to _ItemRuby do { + player addMagazine "ItemRuby"; + }; + }; if (_briefcase_100oz > 0) then { for "_x" from 1 to _briefcase_100oz do { diff --git a/SQF/dayz_code/actions/AdvancedTrading/init.sqf b/SQF/dayz_code/actions/AdvancedTrading/init.sqf index ae0f4fa68..1775bdbd0 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/init.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/init.sqf @@ -14,6 +14,27 @@ if(isNil "Z_AdvancedTradingInit")then{ #include "\z\addons\dayz_code\actions\AdvancedTrading\functions\defines.sqf"; /* Configs that needs to be defined but not changed in config file */ + + _tempGemList = []; + _tempWorthList = []; + DZE_GemList = []; + DZE_GemWorthList = []; + { + _tempGemList set [(count _tempGemList), (_x select 0)]; + _tempWorthList set [(count _tempWorthList), (_x select 1)]; + } count DZE_GemWorthArray; + + //sort the array + for "_i" from 0 to ((count _tempGemList) - 1) do { + _largest = _tempWorthList call BIS_fnc_greatestNum; + _LargestGem = _tempGemList select (_tempWorthList find _largest); + _tempWorthList = _tempWorthList - [_largest]; + _tempGemList = _tempGemList - [_LargestGem]; + DZE_GemList set [(count DZE_GemList), _LargestGem]; + DZE_GemWorthList set [(count DZE_GemWorthList), _largest]; + }; + + Z_Selling = true; Z_SellingFrom = 2; Z_vehicle = objNull; diff --git a/SQF/dayz_code/actions/remove.sqf b/SQF/dayz_code/actions/remove.sqf index 721595878..17b120de2 100644 --- a/SQF/dayz_code/actions/remove.sqf +++ b/SQF/dayz_code/actions/remove.sqf @@ -206,9 +206,16 @@ if (_proceed) then { if (_isMine) then { if((random 10) <= 4) then { - _gems = ["ItemTopaz","ItemObsidian","ItemSapphire","ItemAmethyst","ItemEmerald","ItemCitrine","ItemRuby"]; - _gem = _gems select (floor(random (count _gems))); - _selectedRemoveOutput set [(count _selectedRemoveOutput),[_gem,1]]; + _gems = []; + _weights = []; + { + _gems set [(count _gems), (_x select 0)]; + _weights set [(count _weights), (_x select 1)]; + } count DZE_GemOccurance; + diag_log [_gems, _weights]; + _gemSelected = [_gems, _weights] call BIS_fnc_selectRandomWeighted; + diag_log _gemSelected; + _selectedRemoveOutput set [(count _selectedRemoveOutput),[_gemSelected,1]]; }; }; diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index f052941f6..75763cdb1 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -43,8 +43,10 @@ MaxAmmoBoxes = 3; // Max number of random Supply_Crate_DZE to spawn around the m MaxMineVeins = 50; // Max number of random mine veins to spawn around the map timezoneswitch = 0; // Changes murderMenu times with this offset in hours. DZE_SafeZonePosArray = []; //Prevent players in safeZones from being killed if their vehicle is destroyed. Format is [[[3D POS] RADIUS],[[3D POS] RADIUS]]; Ex. DZE_SafeZonePosArray = [[[6325.6772,7807.7412,0],150],[[4063.4226,11664.19,0],150]]; +DZE_GemOccurance = [["ItemTopaz",10], ["ItemObsidian",8], ["ItemSapphire",6], ["ItemAmethyst",4], ["ItemEmerald",3], ["ItemCitrine",2], ["ItemRuby",1]];; //Sets how rare each gem in the order shown when mining (whole numbers only) /****** Advanced Trading Variables ***********/ +DZE_GemWorthArray = [["ItemTopaz",10000], ["ItemObsidian",20000], ["ItemSapphire",30000], ["ItemAmethyst",40000], ["ItemEmerald",50000], ["ItemCitrine",60000], ["ItemRuby",70000]]; //array of gem prices, MULTIPLES OF 10000 ONLY!!! Works only in advanced trading DZE_advancedTrading = true; //Use advanced trading system. WARNING: set to false if you use database traders, you should use config-traders anyway! Z_AT_FolderLocation = '\z\addons\dayz_code\actions\AdvancedTrading'; Z_VehicleDistance = 40; // Distance that a vehicle needs to be to see it's content or to sell it.