From cb58f1da21b2113c123801c05ea9e41fcf79f4d5 Mon Sep 17 00:00:00 2001 From: Skaronator Date: Thu, 6 Mar 2014 23:01:46 +0100 Subject: [PATCH] Fix #1149 / New Loottable System --- SQF/dayz_code/compile/wild_spawnZombies.sqf | 33 ++++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/SQF/dayz_code/compile/wild_spawnZombies.sqf b/SQF/dayz_code/compile/wild_spawnZombies.sqf index 8d395bd6a..97d2aaa35 100644 --- a/SQF/dayz_code/compile/wild_spawnZombies.sqf +++ b/SQF/dayz_code/compile/wild_spawnZombies.sqf @@ -50,20 +50,37 @@ _agent setVariable ["newDest",_newDest]; //Add some loot _rnd = random 1; if (_rnd > 0.3) then { - _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; - if (isText _lootType) then { + if (DZE_MissionLootTable) then { + _lootType = missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot"; + } else { + _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; + }; - _array = []; + if (isText _lootType) then { if (DZE_MissionLootTable) then { - _array = getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType)); + _lootTypeCfg = getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType)); } else { - _array = getArray (configFile >> "cfgLoot" >> getText(_lootType)); + _lootTypeCfg = getArray (configFile >> "cfgLoot" >> getText(_lootType)); }; - + _array = []; + { + _array set [count _array, _x select 0] + } foreach _lootTypeCfg; if (count _array > 0) then { - _loot = _array call BIS_fnc_selectRandomWeighted; + _index = dayz_CLBase find getText(_lootType); + _weights = dayz_CLChances select _index; + _loot = _array select (_weights select (floor(random (count _weights)))); if(!isNil "_array") then { - _agent addMagazine _loot; + if (DZE_MissionLootTable) then { + _loot_count = getNumber(missionConfigFile >> "CfgMagazines" >> _loot >> "count"); + } else { + _loot_count = getNumber(configFile >> "CfgMagazines" >> _loot >> "count"); + }; + if(_loot_count>1) then { + _agent addMagazine [_loot, ceil(random _loot_count)]; + } else { + _agent addMagazine _loot; + }; }; }; };