The opacity mechanism in B-type stars – II. Excitation of high-order g-modes in main-sequence stars