Advertisement
Guest User

loot_init.sqf

a guest
Dec 31st, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. private["_cfgCount","_config","_configCustomMod","_i","_itemChances","_itemCount","_weighted","_j","_weight","_l","_k","_g","_type","_canZombie","_canLoot"];
  2. dayz_CBLChances = [];
  3. dayz_CBLBase = [];
  4.  
  5. _configCustomMod = configFile >> dayzNam_buildingLoot;
  6. _config = missionConfigFile >> "CfgBuildingLootNamalsk";
  7.  
  8. for "_i" from 0 to ((count _config) - 1) do {
  9. _classname = configName (_config select _i);
  10. _itemChances = getArray (_config >> _classname >> "lootType");
  11. _itemCount = count _itemChances;
  12.  
  13. //diag_log format["Classname: %1, Array: %2, Amount: %3", _classname, _itemChances, _itemCount];
  14.  
  15. _found = false;
  16. if (dayzNam_buildingLoot != "CfgBuildingLootNamalsk") then {
  17. for "_g" from 0 to ((count _configCustomMod) - 1) do {
  18. _classnameMod = configName (_configCustomMod select _g);
  19. if (_classnameMod == _classname) then {
  20. _found = true;
  21. _classname = configName (_configCustomMod select _g);
  22. _itemChances = [] + getArray (_configCustomMod >> _classname >> "lootType");
  23. _itemCount = count _itemChances;
  24. };
  25. };
  26. };
  27.  
  28. if (_itemCount > 0) then {
  29. if (dayz_CBLBase find _classname < 0) then {
  30. _weighted = [];
  31. _j = 0;
  32. for "_l" from 0 to ((count _itemChances) - 1) do {
  33. _weight = round (((_itemChances select _l) select 2) * 100);
  34. for "_k" from 0 to (_weight - 1) do {
  35. _weighted set [_j + _k, _l];
  36. };
  37. _j = _j + _weight;
  38. };
  39.  
  40. dayz_CBLChances set [count dayz_CBLChances, _weighted];
  41. dayz_CBLBase set [count dayz_CBLBase, _classname];
  42. };
  43. } else {
  44. dayz_CBLChances set [count dayz_CBLChances, [0]];
  45. dayz_CBLBase set [count dayz_CBLBase, _classname];
  46. };
  47. };
  48.  
  49. dayz_CLChances = [];
  50. dayz_CLBase = [];
  51. _config = configFile >> "cfgLoot";
  52. for "_i" from 0 to ((count (_config)) - 1) do {
  53. _classname = configName (_config select _i);
  54. _itemChances = getArray (_config select _i);
  55. //diag_log format["CFGLoot: %1, Array: %2", _classname, _itemChances];
  56. _weighted = [];
  57. _j = 0;
  58. for "_l" from 0 to ((count _itemChances) - 1) do {
  59. _weight = round (((_itemChances select _l) select 1) * 100);
  60. for "_k" from 0 to (_weight - 1) do {
  61. _weighted set [_j + _k, _l];
  62. };
  63. _j = _j + _weight;
  64. };
  65. dayz_CLBase set [count dayz_CLBase, _classname];
  66. dayz_CLChances set [count dayz_CLChances, _weighted];
  67. };
  68. //diag_log ("BaseLoot: " +str(dayz_CLBase));
  69.  
  70. private["_i","_type","_config","_canZombie","_canLoot"];
  71. dayz_ZombieBuildings = [];
  72. dayz_LootBuildings = [];
  73. for "_i" from 0 to (count (configFile >> "CfgBuildingLootNamalsk") - 1) do {
  74. _type = (configFile >> "CfgBuildingLootNamalsk") select _i;
  75. _canZombie = getNumber (_type >> "zombieChance") > 0;
  76. _canLoot = getNumber (_type >> "lootChance") > 0;
  77. if(_canZombie) then {
  78. if(!((configName _type) in dayz_ZombieBuildings)) then {
  79. dayz_ZombieBuildings set [count dayz_ZombieBuildings, configName _type];
  80. };
  81. };
  82. if(_canLoot) then {
  83. if(!((configName _type) in dayz_LootBuildings)) then {
  84. dayz_LootBuildings set [count dayz_LootBuildings, configName _type];
  85. };
  86. };
  87. };
  88. //diag_log format["ZombieBuildings: %1", dayz_ZombieBuildings];
  89. //diag_log format["LootBuildings: %1", dayz_LootBuildings];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement