I am not interested in whether or not this is the correct action but only what the legalities are. You are in a state with the Castle Doctrine law including the Alter Ego principle and the following happens:
You are in your typical convience store and notice a BG comes in to rob the clerk. You have a clear view of the action and pull your gun out.
1. The BG has a knife to the throat to of the clerk and you fire. The BG moves just as you fire and the bullet hits the BG but goes through him and hits the clerk killing her.
2. Same as #1 except you completely miss the BG and the clerk is killed.
3. & 4. Same as #1 & 2 except the BG has a gun.
5. The clerk pulls a gun but misses and kills you.
What does the DA do in each case? How much are you actually protected by the Castle Doctrine?