mmmyum

player_spawnCheck.sqf with regular Dayz loot

Apr 29th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. private["_isAir","_inVehicle","_position","_nearby","_tooManyZs","_bPos","_bWithin","_zombiesNum"];
  2. //_type = _this select 0;
  3. _isAir = vehicle player iskindof "Air";
  4. _inVehicle = vehicle player isKindOf "player";
  5. _dateNow = (DateToNumber date);
  6. _maxZombies = dayz_maxLocalZombies;
  7. _maxWildZombies = 3;
  8. _age = -1;
  9.  
  10. _nearbyBuildings = [];
  11. _radius = 200;
  12. _position = getPosATL player;
  13. _nearby = 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"], 500];
  14. _tooManyZs = {alive _x} count (_position nearEntities ["zZombie_Base",500]) > dayz_maxLocalZombies;
  15.  
  16. {
  17. //
  18. _type = typeOf _x;
  19. _config = configFile >> "CfgBuildingLoot" >> _type;
  20. _canLoot = isClass (_config);
  21. _dis = _x distance player;
  22.  
  23. //Loot
  24. if ((_dis < 300) and (_dis > 15) and _canLoot) then {
  25. _looted = (_x getVariable ["looted",-0.1]);
  26. _cleared = (_x getVariable ["cleared",true]);
  27. _dateNow = (DateToNumber date);
  28. _age = (_dateNow - _looted) * 525948;
  29. //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
  30. if ((_age > 10) and (!_cleared)) then {
  31. _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)];
  32. {deleteVehicle _x} forEach _nearByObj;
  33. _x setVariable ["cleared",true,true];
  34. _x setVariable ["looted",_dateNow,true];
  35. };
  36. if ((_age > 10) and (_cleared)) then {
  37. //Register
  38. _x setVariable ["looted",_dateNow,true];
  39. //cleanup
  40. _handle = [_x] spawn building_spawnLoot;
  41. waitUntil{scriptDone _handle};
  42. };
  43. };
  44. //
  45. if (!_tooManyZs) then {
  46. _bPos = getPosATL _x;
  47. _bWithin = count _nearby;
  48. _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",500]);
  49. if ((_zombiesNum < 300) and (_zombiesNum < (20 * _bWithin))) then {
  50. [_x] call building_spawnZombies;
  51. };
  52. };
  53. } forEach _nearby
Advertisement
Add Comment
Please, Sign In to add comment