No cartoon had ever quite done what Batman: The Animated Series did when it premiered in 1992. Over 85 episodes, it told dark, sometimes-ugly stories about conflicted heroes and complex villains. While aimed at children, it treated its audience like adults. It featured now-iconic performances from Kevin Conroy and Mark Hamill as Batman and the Joker. And it gave us the gift of Harley Quinn, the Joker’s playful, deranged, effervescent accomplice, created for the show by writer Paul Dini and artist Bruce Timm.

For Dini, a job writing stories in which the Caped Crusader brought justice to Gotham City was a lifelong dream fulfilled. He’d spent a lonely, troubled childhood watching cartoons, idolizing Batman, and creating characters of his own. By his late twenties, he’d won an Emmy, an Eisner, and a Harvey award for his work on Batman in television and in comic books.

But this is a story about something else.

This is a story about a dark night in Hollywood at the height of Dini’s career when the bad guys won and Batman wasn’t around to stop them. Two anonymous men cornered Dini on a dark street, beat him, shattered his bones, and threatened to kill him. The police barely cared. The muggers were never caught. Dini’s face was bashed in and broken.

How does a man who writes superheroes for a living go on telling stories where the good guys win after a night like that?

“In every story I’ve written with Batman, there’s an element of justice—you never want to have the story end on a defeatist or a cynical note,” says Dini over the phone from his home in Los Angeles. “I’ve always felt in my own small, little way that if I could just write a story where it works out well, where the scales of justice are balanced, then that’s something that I do really love to see in the world.

“And then it happened in real life and the scales felt wildly off-balance to me,” he says. “There was no Batman who was gonna come swinging down and save me. There was nothing in the aftermath other than crawling home and healing. There was very little police follow-up. There was no call-in to look at anybody in a lineup. There was nobody else in my neighborhood who got attacked, so it just sort of ended there.”

Dark Night, Dini’s new graphic novel from DC Comics’ Vertigo imprint, vividly recounts the trauma of that night and the isolation and disillusion that came after. But more importantly, it tells a story about recovery, self-love, and the surprising strength that comes from imagination—in Dini’s case, from the familiar voices inside his head.

Villains like Two-Face, Riddler, Penguin, and the Joker insert themselves into scenes from the aftermath, alternately tempting Dini back into wallowing self-pity and insisting he got what he deserved. Heroes like Batgirl and Batman are equally harsh, trash-talking Dini into taking back control and moving on with his life. Batgirl sees the broken bones of his face and shrugs: “I’ve had worse.” (She really has.) Batman berates and barks at Dini to “rise above it” and continue writing.

But it’s Poison Ivy, the temptress, who forces Dini to confront the source of his self-loathing, which had dragged him down to a dangerous point long before the attack.

In a harrowing scene brought to life with vivid red hues and stark lines by the book’s artist Eduardo Risso, Dini stands in front of a mirror the night after winning his first Emmy. He should be elated, but instead he’s distraught that a pretty young actress whom he’d invited as his date never showed. In what he looks back on as a “stupid, melodramatic, pathetic, painful” act, Dini uses the sharp pointed wings of his new gold statuette to slice shallow cuts into his neck and chest.

“You’re crying now over a beat-down by two crooks, yet a year ago you willfully cut yourself to ribbons,” Ivy chides him in his hospital room, days after the mugging.

“When I did go into the hospital, all the glamorous women that I had dated [weren’t there],” Dini remembers more than 20 years later. “I went into a bare hospital room and nobody called. There were no flowers. Nobody was waiting to help me through it. And so Ivy in that situation is pretty harsh. She spares the guy nothing.”

Dini says he hesitated over whether to include the self-harm scene but, on the advice of Warner Bros. and DC Comics producer Alan Burnett, decided it was necessary to illuminate an important aspect of his recovery. “It was the start of self-examination and figuring out where I wanted to go,” he says. “It wasn’t until a year after [the Emmy incident] when I met two guys who really wanted to hurt me that I realized that I had to value myself and see myself as more than a victim.”

Dark Night, Dini says, is meant for the people who see themselves as victims like that—people whom justice has failed.

“It’s for people who feel like there is no justice and want to give up,” he says. “It’s like, no, don’t do that. It really sucks what happened to you and I feel for you. But when it’s only you that you can rely on, you’re surprised at the resilience you have.”

Weeks of self-torture eventually gave way to recovering confidence, especially when Dini returned to doing what he loved: writing stories. Dini threw himself into his work at Warner Bros. with a renewed sense of purpose. (In addition to Batman, he also wrote for Tiny Toon Adventures and would go on to pen episodes of Superman: The Animated Series, Batman Beyond, and Justice League, among others.)

His traumatic experience did color his work, he says, shading it with “more intensity.” It showed in scripts like the one for Mad Love, a one-shot Harley Quinn origin story comic book that was later adapted for the TV show. Harley suffers her own tragedy—the loss of her sanity—but comes to embrace it and, in her own twisted way, find strength in it independent of the Joker.

Simply being alive after an attack, Dini says, had become a “tremendous creative jolt.” Mad Love won him the first of three Eisner awards (along with a Harvey), and he earned four Emmys for his TV work in the years since the attack. “I really was granted a second chance, so I poured myself into things like that,” he says. “After that moment, I just never lost the spark for writing stories.”

Dini still writes superheroes for TV. After 20 years of writing exclusively DC Comics characters, he even crossed the Big Two divide to pen scripts for the Marvel animated series’ Ultimate Spider-Man and Hulk and the Agents of S.M.A.S.H.

And while he won’t be creatively involved, there’s another DC Comics project on the horizon he’s currently thrilled about: Suicide Squad, the big-screen debut of the now-iconic character he helped create, Harley Quinn. Margot Robbie, who’ll be playing the lady prankster in the supervillain team-up, has seemingly already fallen for the charms that make Harley the best-selling female character in comics (she’s already planning a spinoff movie).

Dini has said he loves what he’s seen of Robbie’s performance in the trailers, though the character’s runaway popularity, he confesses, can be a surreal thing to behold.

“I’ll go to conventions and then I’ll see over the heads of the crowd all these cartoony mallets,” he laughs, “and I’ll go, ‘Oh, there’s a Harley underneath all of those.’ That’s kind of cool. At the same time, it’s a bit overpowering and I kind of duck out.”

The joy his creation brings people is a pleasure he seems to prefer in smaller settings: at home in the dozens of Harley figurines overtaking his shelves and his desk, or in the darkness of a movie theater where he’s still getting used to seeing her onscreen.

“I’m just happy to see her up there. I went to see another movie last week and the trailer for Suicide Squad came on and I was sitting there grinning through it like, ‘That is so cool. There she is!’

“To one degree, I almost feel like I’ve had one big joke on the world,” he laughs. “Like, hee hee hee, I put her out there, now she’s up there. I don’t know why. But every time she shows up, I’m happy to see her.”