function Utils::AreOtherStationsNearby(tile, stationId) { //check if there are other stations squareSize squares nearby local square = AITileList(); local squareSize = 0; if(!AIController.GetSetting("is_friendly")) { //dont care about enemy stations when is_friendly is off squareSize = (stationId == null) ? 5 : 2; //6 tiles distance between new stations, 3 tiles distance between adjacent stations square.AddRectangle(Utils.getOffsetTile(tile, (-1) * squareSize, (-1) * squareSize), Utils.getOffsetTile(tile, squareSize, squareSize)); //if another station is nearby return true for(local tile = square.Begin(); square.HasNext(); tile = square.Next()) { if(AITile.IsStationTile(tile) && (AITile.GetOwner(tile) == AICompany.ResolveCompanyID(AICompany.COMPANY_SELF)) ) { //negate second expression to merge your statitions return true; } } } else { squareSize = 3; square.AddRectangle(Utils.getOffsetTile(tile, (-1) * squareSize, (-1) * squareSize), Utils.getOffsetTile(tile, squareSize, squareSize)); //if another station is nearby return true for(local tile = square.Begin(); square.HasNext(); tile = square.Next()) { if(AITile.IsStationTile(tile)) { return true; } } } if(! ((AITile.IsBuildable(tile) || AIRoad.IsRoadTile(tile)) && AITile.GetSlope(tile) == AITile.SLOPE_FLAT)) { return true; } return false; };