§197. Homicide is also justifiable when committed by any person in any of the following cases:
1. When resisting any attempt to murder any person, or to commit a felony, or to do some great bodily injury upon any person; or,
2. When committed in defense of habitation, property, or person, against one who manifestly intends or endeavors, by violence or surprise, to commit a felony, or against one who manifestly intends and endeavors, in a violent, riotous or tumultuous manner, to enter the habitation of another for the purpose of offering violence to any person therein; or,
3. When committed in the lawful defense of such person, or of a wife or husband, parent, child, master, mistress, or servant of such person, when there is reasonable ground to apprehend a design to commit a felony or to do some great bodily injury, and imminent danger of such design being accomplished; but such person, or the person in whose behalf the defense was made, if he was the assailant or engaged in mutual combat, must really and in good faith have endeavored to decline any further struggle before the homicide was committed; or,
4. When necessarily committed in attempting, by lawful ways and means, to apprehend any person for any felony committed, or in lawfully suppressing any riot, or in lawfully keeping and preserving the peace.