US laws: shooting an undercover cop
<p>So this is in the interest of storytelling and writing.</p>

<p>So we have cop A who is undercover and acting as mobster B's right hand man.</p>

<p>Then we have bar owner C who closed down the bar, and is alone in it doing inventory 2 hours after closing, all alone.</p>

<p>B and A come in the bar (forcibly, since it was closed, but quietly) and surprise C. B want to threaten C into paying protection money, but C refuses, so B and A (who is undercover) are trashing the place and threatening C with death.</p>

<p>C then quickly pulls out a gun and shoots both of them dead.</p>

<p>Would C be in any trouble? Seeing as how it was self defense and he didn't know that A was an undercover cop.</p>

<p>Laws that add special penalties to killing a police officer require that the accused knows that the victim is a police officer, for example <a href="https://code.dccouncil.us/dc/council/code/sections/22-2106.html" rel="noreferrer">DC 22-2106</a> (emphasis mine)</p>

<blockquote>
  <p>(a) Whoever, with deliberate and premeditated malice, and <strong>with knowledge or reason to know that the victim is a law enforcement officer or public safety employee</strong>, kills any law enforcement officer...</p>
</blockquote>

<p>A prosecution would need to show beyond a reasonable doubt that the accused knew the victim was an undercover police officer to convict them under this statute.  In the case presented, it seems unlikely that the bartender could be convicted under such a statute, even without consideration of a possible self-defense argument.  </p>

criminal-law police self-defense undercover