OK, first I am not a lawyer and all the regular blah blah disclaimers.
Tricky to answer. Statutory and case law in your state will be your best guide and even then its not a simple as “If they are doing A, I get to do B cuz the law says so”.
For example, even in my often times backwards state of California, the law on justifiable homicide allows for homicide…"[w]hen 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." (Cal Penal Code 197(2) )
However, even with the law written as such, doesn’t mean its as simple as you get to let loose with both barrels as it were.
Further in California, the jury instructions addressing “Justifiable Homicide: Defending Against Harm to Person Within Home or on Property” instructs the jury the conditions where lethal force can be excused in the defense of the home. But again, that means you are ALREADY being prosecuted and the judge has to read these instructions to the jury and you hope they will see the evidence and case your way as a self-defense case.
Keep in mind that self-defense is a “defense” or argument made to excuse otherwise illegal as legal. For example, simply stated its illegal to commit battery against another person, except in cases of self-defense. Its illegal to use a deadly weapon likely to cause serious bodily harm or death, except in cases of self-defense. Doesn’t mean you that police will not arrest you, or that your local prosecutor will not attempt charge you with a crime. When they do, your attorney will have to make an argument of self-defense.
This is why we have USCCA. To learn, train, and have the ability to mount a proper legal defense in the event you are faced with having to use your firearm to defend yourself or your loved ones against an imminent danger of being killed or suffering serious bodily injury.