Saethkept

player_spawnCheck.sqf

Apr 26th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. _isAir = vehicle player iskindof "Air";
  2. _inVehicle = vehicle player isKindOf "player";
  3. _fastRun = _this select 0;
  4. _dateNow = (DateToNumber date);
  5. _age = -1;
  6. if (!_inVehicle) then {
  7. _position = getPosATL player;
  8. //waitUntil{_position nearObjectsReady 200};
  9. _nearby = _position nearObjects ["building",200]; //nearestObjects [player, ["building"], 200];
  10. _tooManyZs = {alive _x} count (_position nearEntities ["zZombie_Base",400]) > dayz_maxLocalZombies;
  11. {
  12. _type = typeOf _x;
  13. _config = configFile >> "CfgBuildingLoot" >> _type;
  14. _canLoot = isClass (_config);
  15. if (_canLoot) then {
  16. _dis = _x distance player;
  17. if ((_dis < 120) and (_dis > 30)) then {
  18. _looted = (_x getVariable ["looted",-0.1]);
  19. _cleared = (_x getVariable ["cleared",true]);
  20. /*
  21. if(isServer) then {
  22. _dateNow = (DateToNumber date);
  23. _age = (_dateNow - _looted) * 525948;
  24. } else {
  25. _dateNow = serverTime;
  26. _age = (_dateNow * 60) - _looted;
  27. };
  28. */
  29. _dateNow = (DateToNumber date);
  30. _age = (_dateNow - _looted) * 525948;
  31. //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
  32. if ((_age > 10) and (!_cleared) and !_inVehicle) then {
  33. _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)];
  34. {deleteVehicle _x} forEach _nearByObj;
  35. _x setVariable ["cleared",true,true];
  36. _x setVariable ["looted",_dateNow,true];
  37. };
  38. if ((_age > 10) and (_cleared) and !_inVehicle) then {
  39. //Register
  40. _x setVariable ["looted",_dateNow,true];
  41. //cleanup
  42. _handle = [_x,_fastRun] spawn building_spawnLoot;
  43. waitUntil{scriptDone _handle};
  44. };
  45. };
  46. if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
  47. if (dayz_spawnZombies < dayz_maxLocalZombies) then {
  48. if (!_tooManyZs) then {
  49. private["_zombied"];
  50. _zombied = (_x getVariable ["zombieSpawn",-0.1]);
  51. _dateNow = (DateToNumber date);
  52. _age = (_dateNow - _zombied) * 525948;
  53. if (_age > 5) then {
  54. _bPos = getPosATL _x;
  55. _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
  56. if (_zombiesNum == 0) then {
  57. //Randomize Zombies
  58. _x setVariable ["zombieSpawn",_dateNow,true];
  59. _handle = [_x,_fastRun] spawn building_spawnZombies;
  60. waitUntil{scriptDone _handle};
  61. //} else {
  62. //_x setVariable ["zombieSpawn",_dateNow,true];
  63. };
  64. };
  65. };
  66. } else {
  67. dayz_spawnWait = time;
  68. dayz_spawnZombies = 0;
  69. };
  70. };
  71. };
  72. if (!_fastRun) then {
  73. sleep 0.1;
  74. };
  75. } forEach _nearby;
  76. };
Advertisement
Add Comment
Please, Sign In to add comment