Self-Offense

A character sees or hears that someone is coming. Thinking that it's a bad guy, he prepares a mallet, a baseball bat, a net, etc. When the person appears, he strikes... and then notices that it was his friend rather than a bad guy.

Usually, while the character is distracted tending to his injured friend, the real bad guy will come up behind him.

Compare Friend or Foe. Sister trope of Cat Scare where approaching danger turns out to be a harmless critter. See also Don't Sneak Up On Me Like That.

Film
"Henry Jones Sr.: I thought you were one of them! Indiana Jones: They come through the door! Henry Jones Sr.: Good point!"
 * Done in Abbott and Costello Join The Foreign Legion.
 * Non-humorous example: In The Departed,
 * Played hilariously straight in A Fish Called Wanda by Kevin Kline's character to John Cleese's.
 * Used in the eighth Friday the 13th movie, Jason Takes Manhattan. In retrospect, maybe it was a bad idea to give the gun to the guy who needs glasses to see properly before splitting up. Actually, wait...
 * In the Get Smart movie, Max sees a silhouette of what he thinks is a KAOS agent, so he takes a fire extinguisher and hits the silhouette in the head. He then finds that he knocked out the Chief of CONTROL.
 * In Indiana Jones and the Last Crusade, Henry Jones Sr. beans his son with a vase when Indiana jumps in through the window of the castle the Nazis are holding him in.


 * In the first Scary Movie, a young woman beats a group of trick-or-treaters senseless in this context.
 * Used to gruesome effect in the horror movie The Strangers: the two main characters, terrorized in their home by masked invaders, are hiding behind a makeshift barricade in a back room with a shotgun, waiting in terror for their pursuer to appear in the doorway...and when someone finally does, the male protagonist shoots immediately, blowing the head off of—his best friend Mike who has come to pick them up.
 * Another Non-humorous example pretty much sets up the entire plot of Blade 3.
 * Although in that case it was a bad guy, deliberately tricking Blade into making the mistake.
 * Every possible variation of this trope was more or less invented by The Three Stooges.
 * In a likely homage, Sam Raimi used this gag in both Evil Dead 2 and the prototype short film Within the Woods.
 * Als used with Laurel and Hardy when they tried to Shanghai sailors. Oops.
 * Nonviolent example in The Name of the Rose, Adso gets separated from William while in the catacombs, and they try to find one another by voice. Adso suddenly sees a figure with a lamp across the hall, and calls out that he sees someone. It's William, and he identifies himself by flickering his lamp three times.
 * Columbus does this to  in Zombieland. He had it coming, though.
 * In Johnny English, the titular bumbling secret agent performs this, then pins it all on a mysterious "aggressor".
 * He then goes on to stage a fight between himself and himsel...the "aggressor" in the next room.
 * Also done in The Great Race.

Live Action TV
"Hogan: Watch it! I'm an American--and a veteran. Prisoner: I thought you were one of the guards! Hogan: Germans come through the door; Americans come through the floor."
 * Non-humorous example: When Faith in Buffy the Vampire Slayer staked the mayor's aide, believing him to be a vampire.
 * In Heroes, Maya, somehow managing to keep hold of a baseball bat and an Idiot Ball at the same time, does this to Mohinder once. Because the superpowered Serial Killer a) would totally jangle the lock on the front door in broad daylight, and b) would be far more damaged by a baseball bat than by Maya's own superpowers.
 * In an episode of Hogan's Heroes, after a lady prisoner nearly brains Hogan with her high heel:

"Fozzie: Oh Gonzo, I'm sorry. I thought you were a pig. Gonzo: Terrific, terrific. First he clobbers me then he insults me!"
 * The Twilight Zone episode "The Monsters are Due on Maple Street".
 * Semi-common spot in Professional Wrestling, between friends, allies, and tag teams; a series of these can herald a breakup, either because the attacker does it so often it's really not an accident..or the attacker really is just that incompetent and means well but the victim snaps.
 * In the Blakes Seven episode "Redemption", Vila opens the lock on Avon's cell, steps through and is punched in the stomach. On the plus side, Avon actually apologised to him.
 * When pigs launch Hostile Show Takeover of The Muppet Show, Kermit and Fozzie are locked into the boiler. Fozzie decides to club the pig guard to escape, but when the door opens its actually Gonzo, the latest hostage who gets conked!

Real Life

 * Example, with guns: The death of Thomas "Stonewall" Jackson.
 * Jackson and his group were probing Federal lines very late at night some days into the Battle of Chancellorsville. As they returned, a Confederate picket line encountered them and opened fire. They tried to call out that they were firing on their own men, but the picket officers claimed it was a Yankee lie.
 * Mickey Marcus. The guy whom Kirk Douglas portrayed in "Cast a Giant Shadow". The exact circumstances of his death were slightly different (and just a bit more understandable) than those in the movie.

Theater

 * Non-humorous example: The death of Polonius in Hamlet.
 * Hamlet thought it was pretty funny.
 * And many who had Polonius's advice quoted at them as wisdom for years would agree.

Video Games

 * Happens in Assassin's Creed II when Ezio returns home after his father and brothers are hauled off by the Florentine guard. The maid assumes he's another guard coming for his mother and sister and takes a swing at him with a candlestick holder as he comes through the door. A Quick Time Event determines if he gets clocked or not, and the scene continues regardless.
 * This can happen to Batman in Arkham City while in the Joker's warehouse. One of the medics is hiding from thugs and when she hears Batman approach she jumps out from behind some boxes and takes a swing at his head with a 2x4. Of course, being The Goddamn Batman, you can stand there and take it with no ill effects whatsoever.

Western Animation

 * Parodied in Family Guy. When the house is broken into, Peter arms himself with a baseball bat and goes to investigate. He comes across Meg in the hall and stares at her while she tries to ask what is going on. He then whacks her and says, unconvincingly "Sorry Meg, you startled me." She was not amused.
 * In one episode of Scooby Doo, Daphne mistakenly clobbered Shaggy with a vase in this context.
 * Used in Teen Titans once. Fortunately, they recognize each other before they attack.
 * In an episode of Thundercats, Mumm-Ra tricks Lion-O into attacking Tygra with the Sword of Omens this way. Because the Sword can only be used for good, it breaks, forcing Lion-O to risk his neck finding someone who can repair it.