From my conjecture, I think it's a mix between valence electron and the principal energy state, but I'm not sure.
For example, C, N, O and F can only make a maximum of four bonds, as they can only have up to sp3 hybrid orbitals.
For Si, P, S and Cl, they can make a maximum of nine bonds, as they can have sp3d5 hybrid orbitals.
That's what I think, but I'm probably incorrect in some aspect.