Guest User

Untitled

a guest
Feb 7th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. private ["_item","_itemTypes","_qty","_tQty","_uniq"];
  2.  
  3. _iItem = _this select 0;
  4. _iClass = _this select 1;
  5. _iPos = _this select 2;
  6. _radius = _this select 3;
  7. _uniq = [];
  8.  
  9. switch (_iClass) do {
  10. case "weapon": {
  11. //Item is a weapon, add it and a random quantity of magazines
  12. _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
  13. _item addWeaponCargoGlobal [_iItem,1];
  14. _mags = [] + getArray (missionConfigFile >> "cfgWeapons" >> _iItem >> "magazines");
  15. if ((count _mags) > 0) then {
  16. // if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
  17. if (!(_iItem in MeleeWeapons)) then {
  18. _magQty = round(random 10);
  19. if (_magQty > 3) then {
  20. _item addMagazineCargoGlobal [(_mags select 0), (round(random 1) + 1)];
  21. };
  22. };
  23. };
  24. };
  25. case "magazine": {
  26. //Item is one magazine
  27. _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
  28. _item addMagazineCargoGlobal [_iItem,1];
  29. };
  30. case "object": {
  31. //Item is one object as a special weaponholder
  32. _item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
  33. };
  34. default {
  35. //Item is food, add random quantity of cans along with an item (if exists)
  36. _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
  37.  
  38. _itemTypes = [];
  39. {
  40. _itemTypes set [count _itemTypes, _x select 0]
  41. } foreach getArray (missionConfigFile >> "cfgLoot" >> _iClass);
  42.  
  43. //_qty = 0;
  44. //_max = ceil(random 2) + 1;
  45.  
  46. //while {_qty < _max} do {
  47. _index = dayz_CLBase find _iClass;
  48. _weights = dayz_CLChances select _index;
  49. _cntWeights = count _weights;
  50. _index = floor(random _cntWeights);
  51. _index = _weights select _index;
  52. _canType = _itemTypes select _index;
  53.  
  54. //_itemarray = dayz_CLItemNames select _index;
  55. //_canType = _itemarray call BIS_fnc_selectRandom;
  56.  
  57. //diag_log ("CanType: "+str(_canType));
  58. _tQty = round(random 1) + 1;
  59. if (_canType in _uniq) then {
  60. if (({_x in _uniq} count magazines _item) == 0) then { _tQty = 1; } else { _tQty = 0;};
  61. if (_tQty == 0) then {diag_log(format["%1 Prevent any duplicate member %2 from family %3",__FILE__, _canType, _uniq]);};
  62. //diag_log(format["%1 %2 DUP? type:%3 mag:%4 _this:%5",__FILE__, __LINE__, _canType, magazines _item, _this]);
  63. };
  64. if (_tQty > 0) then {
  65. if (!(_canType in _uniq)) then {
  66. _item addMagazineCargoGlobal [_canType,1];
  67. _uniq set [count _uniq, _canType];
  68. //diag_log ("uniq: "+str(_uniq));
  69. //_qty = _qty + 1;
  70. };
  71. };
  72. //};
  73.  
  74. if (_iItem != "") then {
  75. _item addWeaponCargoGlobal [_iItem,1];
  76. //diag_log ("Unknown");
  77. };
  78. };
  79. };
  80. _item setPosATL _iPos; // createVehicle does a "setPos", i.e stacks the weaponholder above existing item on the object.
  81. sleep 0.01;
  82.  
  83. //if (_permaLoot == true) then { _item setVariable ["permaLoot",true]; };
  84.  
  85. _item // used in server_spawnCrashSite
Advertisement
Add Comment
Please, Sign In to add comment