Fix private arrays

Fix issue with wild zeds not spawning loot (idk if they it didnt work
before, but _loottypecfg was nil so it probably didnt)
This commit is contained in:
icomrade
2014-03-16 17:21:46 -04:00
parent 3c28809247
commit f5dff8d0b7
3 changed files with 28 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
private ["_position","_doLoiter","_unitTypes","_loot","_array","_agent","_type","_radius","_method","_myDest","_newDest","_lootType","_player","_isAlive","_rnd","_id"];
private ["_unitTypes","_lootType","_lootTypeCfg","_loot_count","_index","_weights","_loot","_array","_player","_doLoiter","_agent","_type","_radius","_method","_position","_isAlive","_myDest","_newDest","_rnd","_id"];
_player = _this select 0;
_unitTypes = [];
@@ -51,36 +51,34 @@ _agent setVariable ["newDest",_newDest];
_rnd = random 1;
if (_rnd > 0.3) then {
if (DZE_MissionLootTable) then {
_lootType = missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot";
_lootType = getText (missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot");
} else {
_lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
_lootType = getText (configFile >> "CfgVehicles" >> _type >> "zombieLoot");
};
if (isText _lootType) then {
if (DZE_MissionLootTable) then {
_lootTypeCfg = getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType));
} else {
_lootTypeCfg = getArray (configFile >> "cfgLoot" >> getText(_lootType));
};
_array = [];
{
_array set [count _array, _x select 0]
} foreach _lootTypeCfg;
if (count _array > 0) then {
_index = dayz_CLBase find getText(_lootType);
_weights = dayz_CLChances select _index;
_loot = _array select (_weights select (floor(random (count _weights))));
if(!isNil "_array") then {
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;
};
if (DZE_MissionLootTable) then {
_lootTypeCfg = getArray (missionConfigFile >> "CfgLoot" >> _lootType);
} else {
_lootTypeCfg = getArray (configFile >> "CfgLoot" >> _lootType);
};
_array = [];
{
_array set [count _array, _x select 0]
} foreach _lootTypeCfg;
if (count _array > 0) then {
_index = dayz_CLBase find _lootType;
_weights = dayz_CLChances select _index;
_loot = _array select (_weights select (floor(random (count _weights))));
if(!isNil "_array") then {
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;
};
};
};