Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. private ["_type","_inVehicle","_dateNow","_maxWildZombies","_age","_radius","_position","_markerstr","_markerstr1","_markerstr2","_markerstr3","_nearByObj","_handle","_looted","_cleared","_zombied","_config","_canLoot","_dis","_players","_nearby","_nearbyCount","_onTheMove","_soundLimit"];
  2. //_t1 = diag_tickTime;
  3.  
  4. _type = _this select 0;
  5. _inVehicle = (vehicle player != player);
  6. _onTheMove = (speed (vehicle player) > 10);
  7. _dateNow = (DateToNumber date);
  8. _maxWildZombies = 3;
  9. _age = -1;
  10. _radius = 200;
  11. _position = getPosATL player;
  12.  
  13. dayz_spawnZombies = 0;
  14. dayz_CurrentZombies = 0;
  15.  
  16. // experiment with adding fly sounds locally for both zombies && players.
  17. _soundLimit = 2;
  18. {
  19. if (!alive _x) then {
  20. if (!(_x isKindOf "zZombie_Base")) then {
  21. [player,"flysound",1,true] call dayz_zombieSpeak;
  22. _soundLimit = _soundLimit - 1;
  23. };
  24. };
  25. if (_soundLimit == 0) exitWith {};
  26. } count (nearestObjects [player, ["CAManBase"], 8]);
  27.  
  28. _players = _position nearEntities ["CAManBase",_radius+200];
  29. dayz_maxGlobalZombies = dayz_maxGlobalZombiesInit;
  30. {
  31. if(isPlayer _x) then {
  32. dayz_maxGlobalZombies = dayz_maxGlobalZombies + dayz_maxGlobalZombiesIncrease;
  33. } else {
  34. if (_x isKindOf "zZombie_Base") then {
  35. if (local _x) then {
  36. dayz_spawnZombies = dayz_spawnZombies + 1;
  37. };
  38. dayz_CurrentZombies = dayz_CurrentZombies + 1;
  39. };
  40. };
  41. } count _players;
  42.  
  43. if ("ItemMap_Debug" in items player) then {
  44. deleteMarkerLocal "MaxZeds";
  45. deleteMarkerLocal "Counter";
  46. deleteMarkerLocal "Loot30";
  47. deleteMarkerLocal "Loot120";
  48. deleteMarkerLocal "Agro80";
  49.  
  50. _markerstr = createMarkerLocal ["MaxZeds", _position];
  51. _markerstr setMarkerColorLocal "ColorYellow";
  52. _markerstr setMarkerShapeLocal "ELLIPSE";
  53. _markerstr setMarkerBrushLocal "Border";
  54. _markerstr setMarkerSizeLocal [_radius, _radius];
  55.  
  56. _markerstr1 = createMarkerLocal ["Counter", _position];
  57. _markerstr1 setMarkerColorLocal "ColorRed";
  58. _markerstr1 setMarkerShapeLocal "ELLIPSE";
  59. _markerstr1 setMarkerBrushLocal "Border";
  60. _markerstr1 setMarkerSizeLocal [_radius+100, _radius+100];
  61.  
  62. _markerstr2 = createMarkerLocal ["Agro80", _position];
  63. _markerstr2 setMarkerColorLocal "ColorRed";
  64. _markerstr2 setMarkerShapeLocal "ELLIPSE";
  65. _markerstr2 setMarkerBrushLocal "Border";
  66. _markerstr2 setMarkerSizeLocal [80, 80];
  67.  
  68. _markerstr2 = createMarkerLocal ["Loot30", _position];
  69. _markerstr2 setMarkerColorLocal "ColorRed";
  70. _markerstr2 setMarkerShapeLocal "ELLIPSE";
  71. _markerstr2 setMarkerBrushLocal "Border";
  72. _markerstr2 setMarkerSizeLocal [30, 30];
  73.  
  74. _markerstr3 = createMarkerLocal ["Loot120", _position];
  75. _markerstr3 setMarkerColorLocal "ColorBlue";
  76. _markerstr3 setMarkerShapeLocal "ELLIPSE";
  77. _markerstr3 setMarkerBrushLocal "Border";
  78. _markerstr3 setMarkerSizeLocal [120, 120];
  79.  
  80. diag_log ("SpawnWait: " +str(time - dayz_spawnWait));
  81. diag_log ("LocalZombies: " +str(dayz_spawnZombies) + "/" +str(dayz_maxLocalZombies));
  82. diag_log ("GlobalZombies: " +str(dayz_CurrentZombies) + "/" +str(dayz_maxGlobalZombies));
  83. diag_log ("dayz_maxCurrentZeds: " +str(dayz_maxCurrentZeds) + "/" +str(dayz_maxZeds));
  84.  
  85. };
  86.  
  87.  
  88. _nearby = _position nearObjects ["building",_radius];
  89. _nearbyCount = count _nearby;
  90. if (_nearbyCount < 1) exitwith
  91. {
  92. if ((dayz_spawnZombies < _maxWildZombies) && !_inVehicle) then {
  93. [_position] call wild_spawnZombies;
  94. };
  95. };
  96.  
  97.  
  98. {
  99. _type = typeOf _x;
  100. _config = configFile >> "CfgBuildingLoot" >> _type;
  101. if (DZE_MissionLootTable) then {
  102. _config = missionConfigFile >> "CfgBuildingLoot" >> _type;
  103. };
  104. _canLoot = isClass (_config);
  105.  
  106. if(_canLoot) then {
  107. _nearbyPole = (getPos _x) nearestObject "Plastic_Pole_EP1_DZ";
  108. if (isNull _nearbyPole) then {
  109. _dis = _x distance player;
  110.  
  111. //Loot
  112. if ((_dis < 120) && (_dis > 30) && !_inVehicle) then {
  113. _looted = (_x getVariable ["looted",-0.1]);
  114. _cleared = (_x getVariable ["cleared",true]);
  115. _dateNow = (DateToNumber date);
  116. _age = (_dateNow - _looted) * 525948;
  117. //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
  118. if ((_age > DZE_LootSpawnTimer) && (!_cleared)) then {
  119. _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)];
  120. {deleteVehicle _x} count _nearByObj;
  121. _x setVariable ["cleared",true,true];
  122. _x setVariable ["looted",_dateNow,true];
  123. };
  124. if ((_age > DZE_LootSpawnTimer) && (_cleared)) then {
  125. //Register
  126. _x setVariable ["looted",_dateNow,true];
  127. //cleanup
  128. _x call building_spawnLoot;
  129. };
  130. };
  131.  
  132. // do not spawn zeds if player is moving faster then 10kmh
  133. if (!_onTheMove) then {
  134. //Zeds
  135. if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
  136. if (dayz_maxCurrentZeds < dayz_maxZeds) then {
  137. if (dayz_CurrentZombies < dayz_maxGlobalZombies) then {
  138. if (dayz_spawnZombies < dayz_maxLocalZombies) then {
  139. _zombied = (_x getVariable ["zombieSpawn",-0.1]);
  140. _dateNow = (DateToNumber date);
  141. _age = (_dateNow - _zombied) * 525948;
  142. if (_age > 3) then {
  143. _x setVariable ["zombieSpawn",_dateNow,true];
  144. [_x] call building_spawnZombies;
  145. };
  146. } else {
  147. dayz_spawnWait = time;
  148. };
  149. };
  150. };
  151. };
  152. };
  153. };
  154. };
  155. } forEach _nearby;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement