Guest User

ass

a guest
Dec 29th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 3.61 KB | None | 0 0
  1. private ["_config","_itemChances","_itemCount","_weighted","_j","_weight","_type","_canZombie","_canLoot","_classname","_itemChancesSmall","_itemCountSmall"];
  2. dayz_CBLChances = [];
  3. dayz_CBLBase = [];
  4.  
  5. dayzE_CBLSChances = [];
  6. dayzE_CBLSBase = [];
  7.  
  8. _config = missionConfigFile >> "CfgBuildingLoot";
  9. FOR "_i" FROM 0 TO ((COUNT _config) - 1) do {
  10.     _classname = toLower(configName (_config SELECT _i));
  11.     _itemChances = [] + getArray (_config >> _classname >> "ItemChance");
  12.     _itemCount = COUNT _itemChances;
  13.     IF (_itemCount > 0) THEN {
  14.         IF (dayz_CBLBase find _classname < 0) THEN {
  15.             _weighted = [];
  16.             _j = 0;
  17.             FOR "_l" FROM 0 TO ((COUNT _itemChances) - 1) do {
  18.                 _weight = round ((_itemChances SELECT _l) * 100);
  19.                 FOR "_k" FROM 0 TO _weight - 1 do {
  20.                     _weighted SET [_j + _k, _l];
  21.                 };
  22.                 _j = _j + _weight;
  23.             };
  24.             dayz_CBLChances SET [COUNT dayz_CBLChances, _weighted];    
  25.             dayz_CBLBase SET [COUNT dayz_CBLBase, _classname];
  26.         };
  27.     } ELSE {
  28.         dayz_CBLChances SET [COUNT dayz_CBLChances, [0]];
  29.         dayz_CBLBase SET [COUNT dayz_CBLBase, _classname];
  30.     };
  31.    
  32.     _itemChancesSmall = [] + getArray (_config >> _classname >> "ItemChanceSmall");
  33.     _itemCountSmall = COUNT _itemChancesSmall;
  34.     IF (_itemCountSmall > 0) THEN {
  35.         IF (dayzE_CBLSBase find _classname < 0) THEN {
  36.             _weighted = [];
  37.             _j = 0;
  38.             FOR "_l" FROM 0 TO ((COUNT _itemChancesSmall) - 1) do {
  39.                 _weight = round ((_itemChancesSmall SELECT _l) * 100);
  40.                 FOR "_k" FROM 0 TO _weight - 1 do {
  41.                     _weighted SET [_j + _k, _l];
  42.                 };
  43.                 _j = _j + _weight;
  44.             };
  45.             dayzE_CBLSChances SET [COUNT dayzE_CBLSChances, _weighted];    
  46.             dayzE_CBLSBase SET [COUNT dayzE_CBLSBase, _classname];
  47.         };
  48.     } ELSE {
  49.         dayzE_CBLSChances SET [COUNT dayzE_CBLSChances, [0]];
  50.         dayzE_CBLSBase SET [COUNT dayzE_CBLSBase, _classname];
  51.     };
  52. };
  53.  
  54. dayz_CLChances = [];
  55. dayz_CLBase = [];
  56. _config = missionConfigFile >> "cfgLoot";
  57. FOR "_i" FROM 0 TO ((COUNT (_config)) - 1) do {
  58.     _itemChances = (getArray (_config SELECT _i)) SELECT 1;
  59.     _weighted = [];
  60.     _j = 0;
  61.     FOR "_l" FROM 0 TO ((COUNT _itemChances) - 1) do {
  62.         _weight = round ((_itemChances SELECT _l) * 100);
  63.         FOR "_k" FROM 0 TO _weight - 1 do {
  64.             _weighted SET [_j + _k, _l];
  65.         };
  66.         _j = _j + _weight;
  67.     };
  68.     dayz_CLBase SET [COUNT dayz_CLBase, configName (_config SELECT _i)];
  69.     dayz_CLChances SET [COUNT dayz_CLChances, _weighted];      
  70. };
  71.  
  72. dayzE_CLSChances = [];
  73. dayzE_CLSBase = [];
  74. _config = missionConfigFile >> "cfgLootSmall";
  75. FOR "_i" FROM 0 TO ((COUNT (_config)) - 1) do {
  76.     _itemChances = (getArray (_config SELECT _i)) SELECT 1;
  77.     _weighted = [];
  78.     _j = 0;
  79.     FOR "_l" FROM 0 TO ((COUNT _itemChances) - 1) do {
  80.         _weight = round ((_itemChances SELECT _l) * 100);
  81.         FOR "_k" FROM 0 TO _weight - 1 do {
  82.             _weighted SET [_j + _k, _l];
  83.         };
  84.         _j = _j + _weight;
  85.     };
  86.     dayzE_CLSBase SET [COUNT dayzE_CLSBase, configName (_config SELECT _i)];
  87.     dayzE_CLSChances SET [COUNT dayzE_CLSChances, _weighted];      
  88. };
  89.  
  90. private["_i","_type","_config","_canZombie","_canLoot"];
  91. dayz_ZombieBuildings = [];
  92. dayz_LootBuildings = [];
  93. FOR "_i" FROM 0 TO (COUNT (missionConfigFile >> "CfgBuildingLoot") - 1) do {
  94.     _type = (missionConfigFile >> "CfgBuildingLoot") SELECT _i;
  95.     _canZombie =    getNumber (_type >> "zombieChance") > 0;
  96.     _canLoot =      getNumber (_type >> "lootChance") > 0;
  97.     IF(_canZombie) THEN {
  98.         IF(!((configName _type) IN dayz_ZombieBuildings)) THEN {
  99.             dayz_ZombieBuildings SET [COUNT dayz_ZombieBuildings, configName _type];
  100.         };
  101.     };
  102.     IF(_canLoot) THEN {
  103.         IF(!((configName _type) IN dayz_LootBuildings)) THEN {
  104.             dayz_LootBuildings SET [COUNT dayz_LootBuildings, configName _type];
  105.         };
  106.     };
  107. };
Advertisement
Add Comment
Please, Sign In to add comment