The interplay of self-trapping and self-quenching for resonant transitions in solids; role of a cavity