Advertisement
Guest User

Untitled

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