mmmyum

player_spawnCheck modified v0.1a

Apr 27th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. private["_type","_isAir","_inVehicle","_dateNow","_age","_position","_within100","_beyond300","_beyond200","_within450","_tooManyZs","_mydistance","_legit450","_nearby","_legit300","_bPos","_bWithin","_zombiesNum"];
  2. _type = _this select 0;
  3. _Keepspawning = _this select 1;
  4. _isAir = vehicle player iskindof "Air";
  5. _inVehicle = vehicle player isKindOf "player";
  6. _position = getPosATL player;
  7. _dateNow = (DateToNumber date);
  8. _age = -1;
  9. _within100 = [];
  10. _beyond300 = [];
  11. _beyond200 = [];
  12. _within450 = nearestObjects [_position, ["Office","Church","Land_HouseV_1I4","Land_kulna","Land_Ind_Workshop01_01","Land_Ind_Garage01","Land_Ind_Workshop01_02","Land_Ind_Workshop01_04","Land_Ind_Workshop01_L","Land_Hangar_2","Land_hut06","Land_stodola_old_open","Land_A_FuelStation_Build","Land_A_GeneralStore_01a","Land_A_GeneralStore_01","Land_Farm_Cowshed_a","Land_stodola_open","Land_Barn_W_01","Land_Hlidac_budka","Land_HouseV2_02_Interier","Land_a_stationhouse","Land_Mil_ControlTower","Land_SS_hangar","Land_A_Pub_01","Land_HouseB_Tenement","Land_A_Hospital","Land_Panelak","Land_Panelak2","Land_Shed_Ind02","Land_Shed_wooden","Land_Misc_PowerStation","Land_HouseBlock_A1_1","Land_Shed_W01","Land_HouseV_1I1","Land_Tovarna2","Land_rail_station_big","Land_Ind_Vysypka","Land_A_MunicipalOffice","Land_A_Office01","Land_A_Office02","Land_A_BuildingWIP","Land_Church_01","Land_Church_03","Land_Church_02","Land_Church_02a","Land_Church_05R","Land_Mil_Barracks_i","Land_A_TVTower_Base","Land_Mil_House","Land_Misc_Cargo1Ao","Land_Misc_Cargo1Bo","Land_Nav_Boathouse","Land_ruin_01","Land_wagon_box","Land_HouseV2_04_interier","Land_HouseV2_01A","Land_psi_bouda","Land_KBud","Land_A_Castle_Bergfrit","Land_A_Castle_Stairs_A","Land_A_Castle_Gate","Land_Mil_Barracks","Land_Mil_Barracks_L","Land_Barn_W_02","Land_sara_domek_zluty","Land_HouseV_3I4","Land_Shed_W4","Land_HouseV_3I1","Land_HouseV_1L2","Land_HouseV_1T","Land_telek1","Land_Rail_House_01","Land_HouseV_2I","Land_Misc_deerstand","Camp","CampEast","CampEast_EP1","MASH","MASH_EP1","UH1Wreck_DZ","USMC_WarfareBFieldhHospital","Land_Ind_Shed_02_main","Land_Shed_W03","Land_HouseV_1I3","Land_HouseV_1L1","Land_HouseV_1I2","Land_HouseV_2L","Land_HouseV_2T1","Land_houseV_2T2","Land_HouseV_3I2","Land_HouseV_3I3","Land_HouseBlock_A1","Land_HouseBlock_A1_2","Land_HouseBlock_A2","Land_HouseBlock_A2_1","Land_HouseBlock_A3","Land_HouseBlock_B1","Land_HouseBlock_B2","Land_HouseBlock_B3","Land_HouseBlock_B4","Land_HouseBlock_B5","Land_HouseBlock_B6","Land_HouseBlock_C1","Land_HouseBlock_C2","Land_HouseBlock_C3","Land_HouseBlock_C4","Land_HouseBlock_C5","Land_HouseV2_01B","Land_Misc_Cargo1D","Land_HouseV2_03","Land_Ind_Shed_01_end","Land_A_statue01","Land_Shed_W02"], 450];
  13. _tooManyZs = {alive _x} count (_position nearEntities ["zZombie_Base",450]) > dayz_maxLocalZombies;
  14. {
  15. _mydistance = player distance _x;
  16. if (_mydistance <= 100) then {
  17. _within100 set [_x];
  18. };
  19. } foreach _within450;
  20. _legit450 = _within450 - _within100;
  21. if ((count _legit450 > 0) and (count _legit450 < 11)) then {
  22. _nearby = _legit450;
  23. } else {
  24. {
  25. if (_mydistance > 300) then {
  26. _beyond300 set [_x];
  27. };
  28. } foreach _legit450;
  29. _legit300 = _legit450 - _beyond300;
  30. if ((count _legit300 > 0) and (count _legit300 < 11)) then {
  31. _nearby = _legit300;
  32. } else {
  33. {
  34. if (_mydistance > 200) then {
  35. _beyond200 set [_x];
  36. };
  37. } foreach _legit300;
  38. _nearby = _legit300 - _beyond200;
  39. };
  40. };
  41. {
  42. _type = typeOf _x;
  43. _config = configFile >> "CfgBuildingLoot" >> _type;
  44. _canLoot = isClass (_config);
  45. _dis = _x distance player;
  46.  
  47. //Loot
  48. if ((_dis < 300) and (_dis > 30) and _canLoot) then {
  49. _looted = (_x getVariable ["looted",-0.1]);
  50. _cleared = (_x getVariable ["cleared",true]);
  51. _dateNow = (DateToNumber date);
  52. _age = (_dateNow - _looted) * 525948;
  53. //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
  54. if ((_age > 10) and (!_cleared)) then {
  55. _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)];
  56. {deleteVehicle _x} forEach _nearByObj;
  57. _x setVariable ["cleared",true,true];
  58. _x setVariable ["looted",_dateNow,true];
  59. };
  60. if ((_age > 10) and (_cleared)) then {
  61. //Register
  62. _x setVariable ["looted",_dateNow,true];
  63. //cleanup
  64. _handle = [_x] spawn building_spawnLoot;
  65. waitUntil{scriptDone _handle};
  66. };
  67. };
  68. //Zeds
  69. if (!_tooManyZs) then {
  70. _bPos = getPosATL _x;
  71. _bWithin = count _nearby;
  72. _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",450]);
  73. if ((_zombiesNum < 150) and (_zombiesNum < (7.5 * _bWithin))) then {
  74. [_x] call building_spawnZombies;
  75. };
  76. };
  77. } forEach _nearby
Advertisement
Add Comment
Please, Sign In to add comment