Guest User

Untitled

a guest
Feb 7th, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. private ["_bias","_vectorup","_elevation", "_countpos","_lootChance","_index","_weights","_cntWeights","_itemType","_qty","_rnd","_iPos","_obj","_type","_config","_pos","_itemTypes","_positions","_bias", "_pos", "_pos_index", "_i", "_x", "_index", "_existing_loopiles_count", "_deleted_loopiles", "_local"];
  2. _obj = _this;
  3. //_obj = _this select 0;
  4. //_rndlooted = _this select 1;
  5.  
  6. /// don't populate if the object tilts too much
  7. //if (isNil "_obj" or{(isnull _obj)}) exitWith { diag_log [ "Error", __FILE__, "null obj, wtf?!"]; 0};
  8. _vectorup = vectorUp _obj;
  9. if (abs(([0,0,_vectorup select 2] distance _vectorup) atan2 (_vectorup select 2)) > 20) exitWith {0};
  10.  
  11. _type = typeOf _obj;
  12. _config = missionConfigFile >> "CfgBuildingLoot" >> _type;
  13. _itemTypes = [] + getArray (_config >> "lootType");
  14. _bias = 1;
  15. _lootChance = _bias *(getNumber (_config >> "lootChance"));
  16. _qty = 0; // effective quantity of spawned weaponholder
  17. _pos = [] + getArray (_config >> "lootPos");
  18. _countpos = count _pos;
  19. _posidx = [];
  20. for "_i" from _countpos-1 to 0 step -1 do {
  21. _posidx set [_i, _i];
  22. };
  23. //_lootChance = _lootChance * 1.3 * (1 - _rndlooted); // 1.3
  24. _rnd = 0.5;
  25. _existing_loopiles_count = 0;
  26. _deleted_loopiles = 0;
  27. _local = _obj getVariable [ "", false ];
  28. _iPos=[];
  29. for "_i" from _countpos to 1 step -1 do {
  30. _x = _posidx select floor random _i;
  31. _posidx = _posidx - [_x];
  32. _x = _pos select _x;
  33. if ((count _x == 3) AND {(dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders)}) then {
  34. _iPos = _obj modelToWorld _x;
  35. _delLootPiles = [];
  36. // local building (from towngenerator) -> don't delete previous, don't add another lootpile if previous exists
  37. _existing_loopiles_count = {
  38. if (!_local) then {
  39. _delLootPiles set [ count _delLootPiles, _x];
  40. _deleted_loopiles=_deleted_loopiles+1;
  41. false
  42. }
  43. else { true }
  44. } count (_iPos nearObjects ["reammoBox", 2]);
  45. _rnd = random (1 - (_rnd - 0.5) / 10);
  46. if (((!_local) OR {(_local AND {(_existing_loopiles_count == 0)})}) AND {(_lootChance > _rnd)}) then {
  47. _index = dayz_CBLBase find _type;
  48. //if (_index < 0) then { diag_log str [ _type, _this, dayz_CBLBase ]; };
  49. _weights = dayz_CBLChances select _index;
  50. _cntWeights = count _weights;
  51. _index = floor(random _cntWeights);
  52. _index = _weights select _index;
  53. _itemType = _itemTypes select _index;
  54. _elevation = 0 max (_iPos select 2); // prevent buried weaponholder if the building is buried at this loot position
  55. //if (_x select 2 == 0) then { _elevation = 0; }; // prevent levitating weaponholder if the weaponholder should be on the ground;
  56. _iPos set [2, _elevation];
  57. [_itemType select 0, _itemType select 1, _iPos, 0.0] call spawn_loot;
  58. //dayz_sg_newloot set [ count dayz_sg_newloot, [_itemType select 0, _itemType select 1, _iPos, 0.0] ];
  59. dayz_currentWeaponHolders = dayz_currentWeaponHolders + 1;
  60. _qty = _qty + 1;
  61. };
  62. { deleteVehicle _x; } count _delLootPiles;
  63. };
  64. };
  65. /*
  66. diag_log format [ "%1: add loot %2%8 at [%6]. chance:%3(unbiased:%4) del:%7 old:%9 new:%5", __FILE__,
  67. _obj, _lootChance, (getNumber (_config >> "lootChance")),
  68. _qty, _iPos, _deleted_loopiles,
  69. if (_local) then { "(local)" } else { "" },_existing_loopiles_count
  70. ];
  71. */
  72. _qty
Advertisement
Add Comment
Please, Sign In to add comment