Tankbuster 1747 Posted November 7, 2015 I've done something similar, I think. This function takes a position and a boolean (true to ignore military/windmills/powerlines/pier/dockside etc) and returns a radius that describes the perimeter of the town. fnc_getcitylimits = // finds citylimits for the position given // if 2nd param is true, script will concentrate more on actual houses // returns the radius of the city limits and the house count within that { private ["_locpos","_countonlyhouses","_oldringshousecount","_rads","_houses","_dummyhouses","_ringhousecount","_allhousecount", "_finalhousecount", "_myradius", "_rings", "_foundhouses", "_myhouse", "_excludedbuildings", "_exitit", "_previousringhousecount", "_excludedcount", "_previousringhousecount", "_excludedcount"]; params ["_locpos", "_countonlyhouses"]; _locpos set [2,0]; _ringhousecount = 0;_oldringshousecount = 0;_previousringhousecount = 0;_rads = 300;_finalhousecount = 0; _excludedcount = 0; _excludedbuildings = ["Land_TTowerSmall_1_F", "Land_Dome_Big_F", "Cargo_Patrol_base_F", "Cargo_House_base_F", "Cargo_Tower_base_F", "Cargo_HQ_base_F","Piers_base_F", "PowerLines_base_F", "PowerLines_Wires_base_F", "PowerLines_Small_base_F", "Land_PowerPoleWooden_L_F", /*"Lamps_base_F",*/ "Land_Research_HQ_F", "Land_Research_house_V1_F", "Land_MilOffices_V1_F", "Land_TBox_F", "Land_Chapel_V1_F","Land_Chapel_Small_V2_F", "Land_Chapel_Small_V1_F", "Land_BellTower_01_V1_F", "Land_BellTower_02_V1_F", "Land_fs_roof_F","Land_fs_feed_F", "Land_Windmill01_ruins_F", "Land_d_Windmill01_F", "Land_i_Windmill01_F","Land_i_Barracks_V2_F", "Land_spp_Transformer_F", "Land_dp_smallFactory_F", "Land_Shed_Big_F", "Land_Metal_Shed_F","Land_i_Shed_Ind_F","Land_Communication_anchor_F", "Land_TTowerSmall_2_F", "Land_Communication_F","Land_cmp_Shed_F", "Land_cmp_Tower_F", "Land_u_Shed_Ind_F", "Land_TBox_F"]; for "_myradius" from 75 to 450 step 75 do { _houses = []; _excludedcount = 0; _dummyhouses = (_locpos nearObjects ["House_F", _myradius]); { if (_countonlyhouses) then { _myhouse = _x;_exitit = false; { if (_myhouse isKindOf _x) exitWith {_exitit = true}; } foreach _excludedbuildings; if (_exitit) then {/*diag_log format ["%1 excluded because is %2", typeof _myhouse, _x];*/ _excludedcount = _excludedcount +1;} else {_houses pushBack _myhouse;}; } else {_houses = _dummyhouses}; } foreach _dummyhouses; _allhousecount = (count _houses); _ringhousecount = _allhousecount - _oldringshousecount; //diag_log format ["houses count = %1 at ring %2 meters", _ringhousecount, _myradius]; if ((_ringhousecount < _previousringhousecount) and (_myradius > 99)) exitWith {_rads = _myradius; _finalhousecount = _ringhousecount; }; _oldringshousecount = _oldringshousecount + _ringhousecount; _previousringhousecount = _ringhousecount; }; [_rads, _finalhousecount] }; Here's demonstration mission that shows the function in action, plus a further script to attempt to relocate the town centre to a better position. http://steamcommunity.com/profiles/76561198023888634/myworkshopfiles/?appid=107410 Share this post Link to post Share on other sites