How to Stop the Deus Ex Machina

Fridge Logic is a cruel mistress and deadly force. It can destroy Willing Suspension of Disbelief in seconds, as a viewer realizes the heroes (or villains) could easily and quickly succeed if they took a certain action within their power.

So why don't they? Why did the author feel the need to have them do things the hard way? Often it's done to preserve the drama and sense of urgency in the plot, because there would be no story, or story worth telling, if they solved their problem easily.

If the author knows what they're doing, they'll take pains to point out why the heroes (or villains) cannot or will not take that step. Stopping the Deus Ex Machina can be simple or complex, and may deal with physical limitations or mental, emotional, or moral ones (even technically laudable ones, such as "refuses to take a life"—though in practice that's not such a good thing all the time).

The most basic way of implementing these restrictions are Internal and External means. Internal restrictions are ones inherent to a character (personality, morality, skills, talent) and those that are self-imposed, like vows to help others, not kill, that sort of thing. External restrictions are ones that the environment imposes on the characters, be it in material restrictions or injuries. They might have their means of travel restricted, communications cut off, equipment damaged or disabled. Or they may be wheelchair bound, have a broken arm, a Power Limiter or reality itself somehow disallows an action, among other possibilities.

As you can see, though this guide has Deus Ex Machina in the name, it covers situations that completely normal people could solve. For your reading convenience, they have been divided into topic sections covering how to stop characters from doing specific things, as well as specific types of impediments.

Mind Over Manners is a subtrope.

Don't do that!

 * How To Keep Your Hero From Just Walking Away
 * Internal: Give them a sense of obligation or indebtedness, or some other emotional reason to stay. If they're helped by a Good Samaritan, fall for a soiled dove, a Determined Widow, or any other Love Interest, or the antagonist makes it personal are all good reasons (note that if they are staying to help, you need to give the person being helped a reason to stay, too, so we don't ask why the hero didn't just bring them along while he left).
 * Example: In Silent Hill 1, the protagonist Harry wouldn't leave even if he could since his daughter Cheryl is lost in the monster filled town.
 * External: Make it impossible for them to leave by putting them in a Closed Circle, or making it worth their while to stay. Like having someone offer them money, or putting them in house arrest so that leaving is undesirable.
 * Example: In both versions of House on Haunted Hill, the mansion has deadbolts, iron reinforced windows, and all are on a time lock. No one gets out before the party is over.
 * How To Maintain Lack Of Communication
 * Internal: Mistrusting other characters (with reasons to not trust them!); Being Watched or some other surveillance.
 * Example: In Ranma ½, both Ranma and Akane are too stubborn to honestly admit their romantic feelings for each other, and prone to (almost willfully) misreading situations to think the worst of each other.
 * External: Aside from mundane and personal reasons, there are magical ones. A Curse that makes it so they Cannot Spit It Out, or makes them entirely unable to speak. Faulty telephones, a loud environment, and having one or both gagged or deafened can also work for a time.
 * Example: In the fable of the Six Swans or The Swan Brothers, the only way their sister can cure them of their transformation into swans is to weave them sweaters while being completely silent. This leads the prince who loves her into being susceptible to her wicked stepmother convincing him she doesn't love him.
 * How To Keep Someone From Using His Awesome Powers
 * Internal: Self imposed limits to avoid collateral damage are also workable. Of course, the Godzilla Threshold will still have to be crossed at one point. Authors should not cheat viewers of a gun demonstration after showing them ~Chekhov's Gun~.
 * Example: In Dark City, John Murdock can't use his powerful abilities because the experiments that caused them gave him almost complete amnesia.
 * External: This includes advice for justifying the Mentor's refusal to do the job himself, since he obviously has greater power than the rest of the cast. Having the environment be an Anti-Magic, or an enemy so powerful they can ignore the hero's powers. Or hire a person who specializes in it and let him do whatever he wants. For a climactic battle, consider setting up an environment that requires the full use of said powers just to function normally (and show what happens to normal people).
 * Example: Several episodes of Buffy the Vampire Slayer create a lot of anxiety by removing her powers, such as being hypnotized into thinking she's a Victorian lady, drugged into losing her super strength, or pinned under a chandelier.
 * How to rein in errant Phlebotinum.
 * Internal: The character doesn't trust the phlebotinum, either because he's a luddite, or because of some deep seated hate stemming from a Dark and Troubled Past. Using plot solving phlebotinum thus requires they use great willpower or reach a difficult epiphany.
 * Example: Perseus in the 2010 Clash of the Titans won't use either his powers or a divinely gifted sword because he hates the gods for having killed his adoptive family. Only when his lover Io is mortally wounded does he accept his divine heritage and use it.
 * External: It Only Works Once, it's dangerous Psycho Serum or Toxic Phlebotinum, there were No Plans, No Prototype, No Backup, it was a Disposable Superhero Maker, and in general making it Power At a Price. Be careful to avoid Reed Richards Is Useless if you can.
 * Example: In Prince of Persia the Sands of Time, the time rewinding dagger only works with the Sands of Time, and getting it is very difficult, requiring going underground in the city of Alamut.

General Internal Limitations
Aside from these specific topics, there are a lot of general Internal limits a hero or villain can self impose. Something they voluntarily choose not to do, or do in a certain way. This can work remarkably well both as a tool for characterization and a plot complication. However, you should take care not to make the restriction come out of the blue or be ridiculous. It's one thing for a hero to refuse to kill out of regret for having accidentally killed a friend in anger, it's another entirely for them to give some half baked excuse not to off the Omnicidal Maniac who's Made of Evil 'just because'.

But what happens when the Anti-Hero or Card-Carrying Villain show up? These types do not play by the rules... except they do. Their own rules, that is. As The Unfettered, both may refuse to bow to the same constraints as normal people do, but that does not mean they are without some guiding intelligence and under some consideration. Be they an Ubermensch, stylish villain or gritty loner, they are by no means exempt from Internal constraints.

Here are a few common ways for heroes and villains limit themselves.

Moral and Emotional

 * Heroes: May choose to be The Fettered and live to a strict moral code, with all the attendant Flaw Exploitation that will result in. Thou Shalt Not Kill, If You Kill Him You Will Be Just Like Him, and other considerations likely stay his hand from outright killing a villain. However, smaller things like not stealing, hurting innocents, fighting dirty or destroying things needlessly may also seriously complicate their efforts.
 * Heroes who are prone to this: Knight in Shining Armor, The Cape
 * Example: Superman, for all his unstoppable power, can fail to foil a crime because he will not ever use lethal force due to his respect for life and a latent fear of abusing his powers.
 * Villains: They may practice Even Evil Has Standards and pick and choose a handful of moral lines they will not cross. Killing can be one of these, interestingly enough. Or they may have (had) a relationship with the hero that makes hurting them a very difficult proposition; Noble Demons will be loathe to shoot the hero, and may even dream of having them join their evil cause.
 * Characters who may do this: Affably Evil, Anti-Villain, Big Bad Friend, Harmless Villain, Noble Demon, Well-Intentioned Extremist.
 * Example: Hannibal Lecter from The Silence of the Lambs had such a powerful obsession (love?) with agent Starling that he couldn't bear to harm her, resorting to cutting off his own hand to escape capture rather than hers.

Personality and Character

 * Heroes: Even antiheroes who are fine with killing probably require some kind of prompt to do so, like a villain crossing the Moral Event Horizon or a personal threshold. A villain who is wise to these may well skirt "over" the heroes radar to avoid this treatment, or manipulate the hero into facing enemies he will not willingly harm. Providing said heroes with a Morality Pet (and the hero with a reason to listen to their pet) applies here as well.
 * Heroes who are prone to this: Hitman with a Heart, Jerk with a Heart of Gold.
 * Example: Father Abel Nightroad is a vampire eater, and could easily mop the floor with most anyone. However, he enjoys being treated like a human and limiting collateral damage, so he usually accomplishes missions from behind a veil of Obfuscating Stupidity.
 * Villains: If the villain is an Omnicidal Maniac with a bad sense of humor, or even a Serial Killer, their actions will be informed by their manias. Maybe they subscribe to Evil Is Stylish and refuse to do evil acts without flair or 'just because', or their mental disorder (sometimes both are one and the same) mandates they can only kill people whose name ends with S on Tuesday, not Wednesday. Then again, a Lawful Evil villain may not want to compromise their standards ("morals" is a bit too strong a word here).
 * Villain who are prone to this: Noble Demon.
 * Example: The Riddler is obsessed with leaving clues at his crimes, first as a boast and then as a mental disorder. He literally couldn't avoid leaving a clue. he also couldn't reveal the identity of the Batman after he learned it, because a riddle that everyone knew the answer to is useless.

Physical and Mental

 * Mental: Heroes or villains may be further constrained from taking an action by, put bluntly, not thinking of it. They might not be that bright, or their personality (see above) isn't an observant or creative one. Or if they are book smart, they aren't clever or deductive, so they put the clues together or come up with a foolproof plan. Then again, a clever, fly-by-the-seat-of-my-pants type might be too much of The Ditz to use their short term genius to problems that aren't immediate, or a meticulous Chessmaster can't predict the unpredictable. Other sure fire ways of doing this are to give them a distraction: a Distressed Damsel who keeps them occupied intentionally or not, or a villain manipulating them into a MacGuffin Delivery Service, so they don't think to question if they're doing the right thing.
 * Example: The Absorbing Man can turn his body into anything he wants, but his low IQ and limited imagination means he rarely does anything more than turn into a hard substance to bash the heroes.
 * Physical: Giving a character an injury can be a great way to not just keep them housebound, but start the plot itself. Other physical limits include ankle bracelets (Disturbia) or the more exotic Power Limiter.
 * Example: In The Dead Zone Johnny has psychometry from a post car-crash coma, but also has a constant limp that requires him to use a cane. Considering how often he has to outrun danger, this is a serious problem for him.

General External Limitations
External limitations are those the setting or environment place on the characters and their actions. These can take a wide variety of forms, for example a character could be prevented from shooting an enemy by having a gas leak make it suicidal. Or the setting itself may be designed to keep a character from doing something, either by punishing the action or inhibiting it. For example, a hero who has access to awesome future technology can't use it without breaking the Masquerade, or a villain with the power to kill enemies with voodoo dolls risks attracting the attention of killer flying time monkeys. As this last one shows, you do have to be careful to keep it believable.

Physical Environment
The geographical area the hero is in can be used to make their choices a lot more limited. The section How to keep a character from leaving already details how to use it to cut them off from escape and help, but the environment can also be used to make things like fighting, thinking, or even talking hard if not impossible. All you have to do is arrange it so that what you don't want them doing is naturally impossible. For example: two if the hero could normally beat up or catch their enemy, having the hero run into the bad guy in a night club full of strobe lighting, lots of Innocent Bystanders, and impossibly loud music makes it a lot harder for the hero. To that end, consider engineering the story or scene to take place somewhere that is hard to see, hear, or think in (the aforementioned club would be a poor place for any hero in his cups to make an important decision).
 * Example: In Star Trek II the Wrath of Khan, Khan would have easily blown up the damaged Enterprise in a fair fight, but the crew moved the fight into a place where neither had the advantage.

Social
Peer pressure, social responsibility and family duty all serve as ways to force a character to do (or not do) something. A sufficiently honor bound character would follow the lead of the community and its laws, but a rebel can be hemmed in by the Obstructive Bureaucrat, the distrust of All of the Other Reindeer, and fight against a populace that is Dying Like Animals. Outside enforcement like police, bosses, criminals or the army can dissuade certain actions as a way of threatening heroes into complying.
 * Example: In Neverwhere, the heroes and Those Two Bad Guys run into each other in a marketplace. Normally, they would have fought to the death, but the market truce meant the bad guys had to be civil or face death by mob.

Setting / World
Beyond making the immediate area force or stop an action, the setting itself can be engineered to keep the characters in line. This can be done by altering the "default" settings from Real Life to make the plot work, characters can be made to act differently than they would in the real world. For example, if the fictional city the characters inhabit doesn't accept recordings from wiretaps as valid evidence, then it justifies their trouble with bringing down a crime boss. This manipulation can be used not just on legal or social laws, but also physical ones. In a setting with Magic and Powers, making it so the Phlebotinum that gives the heroine and Big Bad powers only works in the Dark World, so neither can attack each other in the Muggles world with a decisive edge. With this kind of limitation, remember to be consistent and to state the limitation early enough that it doesn't become an Ass Pull.
 * Example: In XxxHolic, Yuko is a very, very powerful mage, but due to a complicated system of Equivalent Exchange, she can't help Watanuki with his problems without massively indebting him to her.

Multiple media

 * One of your characters has awesome magic powers? Knock 'em out. Worked in Buffy the Vampire Slayer and Gargoyles. Alternatively, someone sticks a Restraining Bolt on them, or they lose their powers for a bit (recurring fun in Inuyasha).

Anime and Manga

 * Inuyasha's Miroku has what is basically a miniature black hole in his hand which can suck in and destroy even ridiculously powerful beings. For no reason besides the fact that he's not the main character, he is poisoned if he sucks in venomous insects or toxic gas. It is also established that if he uses this too much, it will eventually swallow him whole. Immediately after he joins the main cast the villain calls up a swarm of giant wasps that protect basically everything that has to do with the main plot.
 * Lina Inverse from The Slayers can perform the Giga Slave, a spell which is literally capable of destroying ANYTHING, including gods. The reason she doesn't perform it more often? Because destroying anything is just a small subset of what the spell is truly capable of doing, which is destroying everything. This is generally handled fairly well in the story, with the spell and Linas ability to cast it introduced surprisingly early on, and it's use is a central plot element to the first three seasons.

Comic Books

 * Superman: Why else is kryptonite everywhere?
 * Dr. Manhattan: It just so happens that the one almost completely omnipotent character in the story is also almost completely apathetic, so he spends his time looking at elemental particles and doing whatever the government tells him instead of, say, secretly defusing all nuclear weapons in the world to avert the threatening apocalypse that fuels the plot. Also, the only things that are mentioned as actually beyond his powers to do are to stop all Soviet nuclear missiles if they were fired at the USA at once, and to see and reveal the conclusion of the plot clearly.

Fan Fics

 * In Yudkowsky's Harry Potter and The Methods of Rationality, there is an excellent example of an external geographic limitation: it is explicitly stated that the direction of time cannot be changed inside Azkaban. This prevents any Fridge Logic concerning why Harry doesn't just use his Time-Turner to get out of a bad situation, as he had already demonstrated a willingness to do on numerous previous occasions.
 * And before that, the Time-Turners themselves. In canon, we were never given any rules about their limits. Here, any individual Time-Turner can only be used six times a day, and no combination of Time-Turners can take anyone or anything back more than six hours. Not to mention that it always turns into a Stable Time Loop.

Literature

 * Eragon cannot use magic to kill his wizard opponents because just before they die, they might kill him too; he has to first control their minds. If he is fighting soldiers they are usually protected by one of the aforementioned wizards.
 * The Dresden Files generally takes pains to have Harry explain why he can't use certain spells or abilities or resources. One of the more common limitations is when Harry is dealing with either humans or monsters who've taken human shields, as the First law of Magic is that you cannot kill a mortal with magic directly. Other Laws of Magic deal with other particularly nasty uses of magic, such as transforming bodies, mental magic, or binding living creatures to one's will. Other times, Harry specifies that while he would ordinarily use a type of magic or call someone for backup or information, but he can't for a particular reason.

Live Action TV

 * 24, Season 1 uses constant surveillance on Jack Bauer to make sure he doesn't disobey the terrorists' orders (his family is at stake and they will die instantly if he disobeys.)
 * In Firefly, River Tam possesses phenomenal physical combat abilities and Psychic Powers. She has both internal and external reasons to not use these to solve everything, because she is both insane and the majority of her combat abilities are buried beneath her insanity until they are triggered by subliminal messaging.

Video Games

 * In The Reconstruction, is stripped of his  powers by  accidentally. If not, he probably could have simply

Web Comics

 * Last Res0rt has Jigsaw Forte, who can read minds and transform into a Super-Powered Evil Side which can handle most of her problems... except for that pesky "being under constant surveillance on a Reality Show" thing, and if she actually reveals she's a vampire, she'll end up hunted down.
 * Also, she's only just turned into a vampire, so she's still learning how to control most of her powers—right now, she can't turn off her mind reading, which means that if everyone starts thinking at once (or one person's mind starts going a mile a minute), she's susceptible to overload.