The Herschel Space Observatory enables observations in the far-infrared at high spectral and spatial resolution. A particular class of molecules will be directly observable: light diatomic hydrides and their ions (CH, OH, SH, NH, CH + , OH + , SH + , NH + ). These simple constituents are important both for the chemical evolution of the region and as tracers of high-energy radiation. If outflows of a forming star erode cavities in the envelope, protostellar far-UV (FUV; 6 < E γ < 13.6 eV) radiation may escape through such low-density regions. Depending on the shape of the cavity, the FUV radiation then irradiates the quiescent envelope in the walls along the outflow. The chemical composition in these outflow walls is altered by photoreactions and heating via FUV photons in a manner similar to photo-dominated regions. In this work, we study the effect of cavity shapes, outflow density, and of a disk with the two-dimensional chemical model of a high-mass young stellar object introduced in the second paper in this series. The model has been extended with a self-consistent calculation of the dust temperature and a multi-zone escape probability method for the calculation of the molecular excitation and the prediction of line fluxes. We find that the shape of the cavity is particularly important in the innermost part of the envelope, where the dust temperatures are high enough ( 100 K) for water ice to evaporate. If the cavity shape allows FUV radiation to penetrate this hot-core region, the abundance of FUV-destroyed species (e.g., water) is decreased. On larger scales, the shape of the cavity is less important for the chemistry in the outflow wall. In particular, diatomic hydrides and their ions CH + , OH + , and NH + are enhanced by many orders of magnitude in the outflow walls due to the combination of high gas temperatures and rapid photodissociation of more saturated species. The enhancement of these diatomic hydrides is sufficient for a detection using the HIFI and PACS instruments on board Herschel. The effect of X-ray ionization on the chemistry is found to be small, due to the much larger luminosity in FUV bands compared to X-rays.