Advertisement
Guest User

Untitled

a guest
Feb 7th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. private ["_maxControlledZombies","_looted","_zombied","_doNothing","_spawnZedRadius", "_serverTime"];
  2. _age = -1;
  3. //_nearbyBuildings = [];
  4. _position = getPosATL player;
  5. _spawnableObjects = ["building", "SpawnableWreck", "IC_Fireplace1", "IC_DomeTent", "IC_Tent"];
  6. //_force = false;
  7. _speed = speed (vehicle player);
  8. _radius = 150*0.707;
  9. _spawnZedRadius = 20;
  10.  
  11. /*
  12. //Tick Time
  13. PVDZ_getTickTime = player;
  14. publicVariableServer "PVDZ_getTickTime";
  15. */
  16.  
  17.  
  18. //Total Counts
  19. _maxlocalspawned = round(dayz_spawnZombies);
  20. _maxControlledZombies = round(dayz_maxLocalZombies);
  21. _maxWeaponHolders = round(dayz_maxMaxWeaponHolders);
  22. _currentWeaponHolders = round(dayz_currentWeaponHolders);
  23. _maxtoCreate = 3;
  24.  
  25.  
  26. //Limits (Land,Sea,Air)
  27. _inVehicle = (vehicle player != player);
  28. _isAir = vehicle player iskindof "Air";
  29. _isLand = vehicle player iskindof "Land";
  30. _isSea = vehicle player iskindof "Sea";
  31. if (_isLand) then { } else { };
  32. if (_isAir) then { } else { };
  33. if (_isSea) then { } else { };
  34.  
  35. _doNothing = false;
  36. if (_inVehicle) then {
  37. _Controlledzeddivided = 0;
  38. //exit if too fast
  39. if (_speed > 25) exitwith {_doNothing = true;};
  40.  
  41. //Crew can spawn zeds.
  42. _totalcrew = count (crew (vehicle player));
  43. if (_totalcrew > 1) then {
  44. _Controlledzeddivided = 2;
  45.  
  46. //Dont allow driver to spawn if we have other crew members.
  47. if (player == driver (vehicle player)) exitwith {_doNothing = true;};
  48. } else {
  49. _Controlledzeddivided = 4;
  50. };
  51.  
  52. if (_Controlledzeddivided > 0) then {
  53. _maxControlledZombies = round(_maxControlledZombies / _Controlledzeddivided);
  54. r_player_divideinvehicle = _Controlledzeddivided;
  55. };
  56. };
  57.  
  58. if (_doNothing) exitwith {};
  59.  
  60. _nearby = nearestObjects [_position, _spawnableObjects,_radius];
  61. _maxlocalspawned = _maxlocalspawned max floor(_maxControlledZombies*.8);
  62. if (_maxlocalspawned > 0) then { _spawnZedRadius = _spawnZedRadius * 3; };
  63.  
  64. //Logging
  65. diag_log (format["%1 Local.Agents: %2/%3, NearBy.Agents: %8/%9, Global.Agents: %6/%7, W.holders: %10/%11, (radius:%4m %5fps).","SpawnCheck",
  66. _maxlocalspawned, _maxControlledZombies, _radius, round diag_fpsmin,dayz_currentGlobalZombies,
  67. dayz_maxGlobalZeds, dayz_CurrentNearByZombies, dayz_maxNearByZombies, _currentWeaponHolders,_maxWeaponHolders]);
  68.  
  69. //Spawn zeds in buildings
  70. {
  71. _type = typeOf _x;
  72. _config = missionConfigFile >> "CfgBuildingLoot" >> _type;
  73. _canSpawn = isClass (_config);
  74. _dis = _x distance player;
  75. _checkLoot = ((count (getArray (_config >> "lootPos"))) > 0);
  76. _islocal = _x getVariable ["", false]; // object created locally via TownGenerator. See stream_locationFill.sqf
  77.  
  78. //Make sure wrecks always spawn Zeds
  79. //_isWreck = _x isKindOf "SpawnableWreck";
  80. //if (_isWreck) then { _force = true; };
  81.  
  82. //Loot
  83. if (_canSpawn) then {
  84. if (!dayz_serversideloot) then {
  85. if (_currentWeaponHolders < _maxWeaponHolders) then {
  86. //Baisc loot check
  87. if ((_dis < 125) and (_dis > 30) and !_inVehicle and _checkLoot) then {
  88. _serverTime = serverTime;
  89. _looted = (_x getVariable ["looted",_serverTime]);
  90. _age = _serverTime - _looted;
  91. if ((_age == 0) or (_age > 900)) then {
  92. _x setVariable ["looted",_serverTime,!_islocal];
  93. _x call building_spawnLoot;
  94. if (!(_x in dayz_buildingBubbleMonitor)) then {
  95. dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
  96. };
  97. //diag_log [ diag_tickTime, "new loot at",_x,"age:", _age, "serverTime:", _serverTime];
  98. }/*
  99. else {
  100. diag_log [ diag_tickTime, "won't spawn loot at",_x,"age:", _age, "serverTime:", _serverTime];
  101. }*/;
  102. };
  103. };
  104. };
  105.  
  106. //Zeds
  107. if (_dis > _spawnZedRadius) then {
  108. if ((dayz_spawnZombies < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
  109. _serverTime = serverTime;
  110. _zombied = (_x getVariable ["zombieSpawn",_serverTime]);
  111. _age = _serverTime - _zombied;
  112. if ((_age == 0) or (_age > 300)) then {
  113. _bPos = getPosATL _x;
  114. _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
  115.  
  116. if (_zombiesNum == 0) then {
  117. _x setVariable ["zombieSpawn",_serverTime,!_islocal];
  118.  
  119. if (!(_x in dayz_buildingBubbleMonitor)) then {
  120. //add active zed to var
  121. dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
  122. };
  123.  
  124. //start spawn
  125. [_x] call building_spawnZombies;
  126. };
  127. };
  128.  
  129. //diag_log (format["%1 building. %2", __FILE__, _x]);
  130. };
  131. };
  132. };
  133. } forEach _nearby;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement