One little seed changes the whole game in Marvel's Black Panther.
Deus Ex Machina has a way of finding itself in our manuscripts. As we're writing, new ideas come up along the way--in either your outline or your manuscript. This is especially true for when we get deeper into our stories. How many times have we had that brilliant idea late in the process? It's kind of like when we get ideas right as we hit the sheets for the night. Deus Ex Machina is (usually) a great idea that pops up serendipitously, and while it might make sense in your own head, you'll have to connect the dots for your reader. This also means you'll have to create those dots first.
Deus Ex Machina gets a bad rep, and for good reason. No one likes a random person to come save the day for our hero. Instead, our readers want to see the hero figure it out on their own, to show their true character. The thing is, Deus Ex Machina (we're just going to call it Machina from here on) has potential, but it just seems off because, intrinsically, it's a half-baked idea.
An example of Machina that could have been is the Heart-Shaped Herb in Marvel's Black Panther. If we don't introduce that element early on, and make more than one reference to it, it's arrival in the end is going to feel cheap and lazy. It shows that you haven't thought deeply enough about how this resolution to a problem is connected to your story, both plot-wise and thematically.
The idea of the herb on its own is cool. But how is it woven into the story?
Things shouldn't come out of nowhere in your plot.
Let's actually take a look at the Heart-Shaped Herb and its backstory. According to the Marvel Wikia, "The Heart-Shaped Herb is a plant that only grows in the nation of Wakanda. In legend it was said to have been a gift from the Panther God, the local deity they worshiped, but in reality the plant had been mutated by a giant meteorite of Vibranium crashing into the earth." Further, the Wikia explains that if one wants to become the Black Panther of Wakanda, "they must complete several other tasks to prove their worthiness. If they are successful and gain the role of leadership they have the juices of the Heart-Shaped Herb applied to their body. It is said that anyone not worthy or of noble blood would not survive the process."
The Wikia goes on even more, detailing a rich backstory of the herb itself. What details lie in the thing or the person that impacts the major plot point(s) in your story? What would you write on its wiki?
What Killmonger does with the Heart-Shaped Herb in his attempt to become king of Wakanda and then what he does with the garden seriously impacts not only the rest of the film's arc, but beyond the story itself. The future of Wakanda is changed entirely as a result of one little action. Pardon the pun, but the herb is deeply rooted in Black Panther's mythology, just as your Machina ultimately needs to be. But ideas need to grow, and their roots need to get deeper into the dirt.
I see a lot of writers make the Machina mistake in their first drafts. They start introducing ideas for the sake of moving the story forward. By doing so, they give themselves an out, and can move on to the next chapter. I'm not going to lie, I've done this quite a few times in my own work. We all have done it. I still do it. This is why revisions and re-writes are so important.
When you've got an idea that presents itself later in the manuscript and plays a role in moving the plot forward, ask yourself two questions:
What does it have to do with the story's internal logic?
Has this has been referenced before?
I recommend referencing this idea more than once so that your readers will know that this thing might be important. How it's important is the mystery, and when it finally clicks, it feels like your reader has had a hand in completing the puzzle. By reading and paying attention, they picked up on something, and along with the hero, they figured it out. By dropping hints and clues and creating the dots for your readers to connect, you're rewarding them. It's almost like you're making the reader feel responsible for resolving the conflict. They were mutually on the same page as the hero.
And your writing should be a rewarding experience, right?