Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. private ["_wreck","_maxlocalspawned","_maxControlledZombies","_iPos","_nearByZed","_nearByPlayer","_rnd","_positions","_zombieChance","_unitTypes","_min","_max","_num","_clean","_obj","_type","_config","_canLoot","_originalPos","_fastRun","_enabled","_i","_Pos"];
  2. _obj = _this select 0;
  3. _wreck = false;
  4. if (count _this > 1) then {
  5. _wreck = _this select 1;
  6. };
  7.  
  8. _type = typeOf _obj;
  9. _config = missionConfigFile >> "CfgLoot" >> "Buildings" >> _type;
  10. _canLoot = isClass (_config);
  11. _originalPos = getPosATL _obj;
  12.  
  13. _maxlocalspawned = round(dayz_spawnZombies);
  14. //Lets check if we need to divide the amount of zeds
  15. if (r_player_divideinvehicle > 0) then {
  16. _maxlocalspawned = round(dayz_spawnZombies / r_player_divideinvehicle);
  17. };
  18.  
  19. _maxControlledZombies = round(dayz_maxLocalZombies);
  20. _enabled = false;
  21.  
  22. if (_canLoot && !([_originalPos] call DZE_SafeZonePosCheck)) then {
  23. //Get zombie class
  24. _unitTypes = getArray (_config >> "zombieClass");
  25. _min = getNumber (_config >> "minRoaming");
  26. _max = getNumber (_config >> "maxRoaming");
  27. _zombieChance = getNumber (_config >> "zombieChance");
  28.  
  29. //Walking Zombies
  30. _num = (round(random _max)) max _min; // + round(_max / 3);
  31. //diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
  32.  
  33. for "_i" from 0 to _num do
  34. {
  35. //_iPos = _obj modelToWorld _originalPos;
  36. if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
  37. [_originalPos,true,_unitTypes,_wreck] call zombie_generate;
  38. };
  39. };
  40.  
  41. //Add Internal Zombies
  42. if ((random 1) < _zombieChance) then {
  43. _clean = {alive _x} count ((getPosATL _obj) nearEntities ["zZombie_Base",(sizeOf _type)]) == 0;
  44. if (_clean) then {
  45. _positions = getArray (_config >> "zedPos");
  46. //diag_log format["Building: %1 / Positions: %2 / Chance: %3",_type,_positions,_zombieChance];
  47. {
  48. _Pos = [_x select 0, _x select 1, 0];
  49. _rnd = random 1;
  50. if (_rnd < _zombieChance) then {
  51. _iPos = _obj modelToWorld _Pos;
  52. _nearByZed = {alive _x} count (_iPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]) > 0;
  53. _nearByPlayer = ({isPlayer _x} count (_iPos nearEntities ["CAManBase",30])) > 0;
  54. //diag_log ("BUILDING: " + _type + " / " + str(_nearByZed) + " / " + str(_nearByPlayer));
  55. if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
  56. if (!_nearByPlayer and !_nearByZed) then {
  57. [_iPos,false,_unitTypes,false] call zombie_generate;
  58. };
  59. };
  60. };
  61. } forEach _positions;
  62. };
  63. };
  64. };
  65.  
  66. //diag_log ("2 end");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement