Your scenarios seem to presume that if he is acting illegally, he is not acting is his official duties. But the combination of Pin official duties" and "illegal" is possible, although adjudicated in hindsight. The question becomes whether or not a homeowner can raise the affirmative defense provided by the statutory castle doctrine if the police, in their duties, acted illegally. The Indiana Supreme Court says "No."
The state of the law in Indiana, courtesy of the Indiana Supreme Court, is that if a police officer is acting illegally, in his official duty, a homeowner may not offer resistance.
This is a judicially created carve-out to the statutory castle doctrine in Indiana.
b) A person:
(1) is justified in using reasonable force, including deadly force, against another person; and
(2) does not have a duty to retreat; if the person reasonably believes that the force is necessary to prevent or terminate the other person's unlawful entry of or attack on the person's dwelling, curtilage, or occupied motor vehicle.
I think the term "acting illegally" is overbroad. The question is whether or not he is acting in his official duty. If the officer is, in fact, violating some criminal statute for which he could be charged and imprisoned or jailed, that he is no longer acting in his official duty and the Castle doctrine would be applicable.
I think a lot of people just are having a knee jerk reaction to this holding. The holding is not a carte blanche permit for cops to make illegal entry. They have to be acting in their official capacity as safety officers and law enforcement officers. If they are off the reservation, then the Castle doctrine is still in effect.
This is not an unreasonable decision.