If, in the effort to suppress or disperse any unlawful or riotous assembly, or to arrest or detain any of the persons engaged therein, any such rioters or other persons then present as spectators or otherwise are killed or wounded, the officers, and persons acting in their aid, are guiltless thereof. If any such officers or persons acting in their aid are killed or wounded, all persons engaged in such assembly are guilty thereof.