The year 1999 was a curiously historic one for movies, spawning an array of films that are still lovingly remembered. These were the eclectic 12 months that produced The Matrix, Fight Club, The Blair Witch Project, American Beauty and The Sixth Sense. For many, their story is one of pieces slotting together in the right place at the right time. This, however, is the tale of one film for which things didn’t go so smoothly.

At the time, with a constantly replenished budget that ended up totaling $170 million, Wild Wild West was one of the most expensive movies ever made. And though it made back its investment at the box office, it was loathed by critics and has gone down in history as a bizarre flop, a blip in the otherwise outstanding careers of Will Smith and Kevin Kline. Now used as a punchline by Smith, the film is an example of how big-budget comedies can spin out of control. The best thing about it was, famously, the star’s tie-in title track, from a time when tie-in title tracks were a thing.

Though many of the millions of people who have watched the film have no idea, Wild Wild West was based on the mid-1960s American TV show The Wild Wild West, a Western whose original pitch had been “James Bond in the West.” While Barry Sonnenfeld was directing Men in Black, Smith’s business partner James Lassiter told the director about a prospective film adaptation written by Shane Black, which had stalled after director Richard Donner had pursued Maverick, another comedy Western film based on a TV show. Sonnenfeld, it turns out, had grown up watching The Wild Wild West. “I embrace all things cowboys,” he tells me from his living room in Colorado. “I direct from a saddle.”

Read Next in Oral History:

The story, set in 1868, is that of Secret Service agents Jim West (Smith) and Artemus Gordon (Kline). In a scene in which, for no apparent reason, Kline also plays the president, the pair are tasked by the commander-in-chief with tracking down some missing scientists. They set off by train and find legless ex-Confederate scientist Arliss Loveless (Kenneth Branagh with a Southern accent and a steam-powered wheelchair), who wants to overthrow the government and apportion it to an alliance of slave owners. At the end of the film, our heroes confront Loveless in the 80-foot mechanical spider he has built for himself, and he falls to his death from a cliff.

Because the show fused the Western with elements of science fiction, Wild Wild West’s aesthetic was steampunk: watch chains, waistcoats and top hats abound. Among the costumes designed by Deborah Lynn Scott were a number of intensely busty corsets (one of which is worn by Kline); a pair of tiny oval sunglasses for Smith; and a buttless set of pajamas for Salma Hayek. The sets, designed by Cheryl Carasik, were also eye-catching: They feature a train with a pool table that flips over; an enormous exploding Abraham Lincoln, out of whose head Branagh emerges; and buildings decorated with grandiose black webbing, to foreshadow the giant mechanical spider (on which more later).

Smith, whose star was wholly in the ascendant at this point on the back of Independence Day and Bad Boys, was on board from an early stage. His counterpart was originally going to be George Clooney, with whom Sonnenfeld had a close relationship. The two met at Sonnenfeld’s house and Clooney was attached subject to a second draft. After it came in, Clooney called the director on the day before Thanksgiving in 1997 to pull out. He felt that Smith got all the funny lines, and he didn’t want to be the straight man.

Keeping track of who wrote which draft of which version of which script is difficult but Brent Maddock and Steven Wilson came aboard in 1997, hired by Warner Bros. to do a rewrite. “Our story ends before much of the chaos begins,” Wilson says. The studio didn’t want Maddock and Wilson to read the previous versions of the script, and issued a couple of caveats. One was that the film should feature no nuclear bombs.

The pair had various meetings with studio representatives and two with Jon Peters, who was producing the film with Sonnenfeld. Peters, who used to be Barbra Streisand’s hairdresser, had executive-produced films like Caddyshack, Batman Returns and A Star Is Born (the 1976 version as well as the 2018 remake). Maddock, speaking to me with two broken feet from his house in California, says that he went alone to the Bel Air Hotel, where Peters was living while he was remodeling his house. He met him by the pool, as Peters sat with his “retinue of young Hollywood studs.” Maddock told Peters the story of the film. When he explained there would be a scene in which Jim West rides on horseback through the night in order to meet the president, Peters stopped him. “Horse?” he said. “Horses are boring.”

There was a long pause. Maddock said, “Well, we’re setting this in 1868; this is a Western.” Peters said, “You know what’s cool? Motorcycles.” Maddock told him there weren’t any motorcycles in 1868. “Yeah, you could have motorcycles,” Peters responded.

At one point, Peters said to Maddock, “You see the pool there? I was in the middle of that pool one day and swimming up behind me comes Steven Seagal. He gets me in a headlock. And you know, he’s such a pussy…” Peters then proceeded to claim that he asked Seagal, “Wanna take me down? Wanna take me down?,” got out of the pool and had a martial arts battle with him, which Peters won. “All of the four, five young men executives who worked for Jon Peters are sitting around,” says Maddock, “and the only thing I’m thinking is, How are these guys keeping a straight face?”

Around this time, Peters was coming off a string of failures with Warner Bros. (Rosewood, My Fellow Americans and With Honors); still, Sonnenfeld says that he wasn’t someone to mess with: “He yells.”

Read Next in Oral History:

“I really shouldn’t talk out-of-school, but Jon wasn’t a hugely active producer,” Doug Harlocker, who made the majority of the props for Wild Wild West, tells me. “He was somehow attached to Wild Wild West, and I’m still to this day not quite sure why. I thought he was sort of an odd choice: he’s a Beverly Hills guy that had multiple estates and 25 full-time gardeners working on his property every single day.” (Peters, who recently married and apparently split from Pamela Anderson over the course of 12 days, and his representatives did not reply to my interview requests.)

One of Maddock and Wilson’s story ideas was that there should be that aforementioned giant mechanical spider at the end of the film. Peters’ office rejected it, however, suggesting a stealth bomber instead. The writers thought that this was inconceivable for 1868, and a 100-foot-long armor-plated “flying machine” with gun turrets was the compromise. But luckily, when they visited Peters and his representatives at the producer’s enormous Tudor mansion — a house so vast that Wilson mistook the garage for the house itself — Sonnenfeld said he didn’t like the flying machine idea. Wilson piped up and said that they’d written a spider in a previous draft. Sonnenfeld responded, “Oh, I’d like to see that.” An executive stood up and shouted: “I really support that, Mr. Sonnenfeld!” The spider was back.

Curiously, a colossal mechanical spider seems to be a Peters trope. Kevin Smith has claimed that when a fifth Superman film was in development Peters wanted Superman to fight an enormous spider; similarly, Neil Gaiman said that Peters wanted a massive mechanical spider at the end of a film of The Sandman. He, in fact, told Gaiman that the spider “would make any film a hit.”

Not only was this absolutely not the case, Sonnenfeld identifies it as one of the many factors that ruined the film. “Once that mechanical spider shows up,” he says, “it changes the scale, scope and tone of the film.” (He adds that it might have been all right if it were half as big.) Either way, after Wilson and Maddock re-inserted the spider and turned in their second draft, they never heard from anyone on the film again.

With the film’s leads already cast, attention turned to the minor roles. Frederique van der Wal, who had done modeling and some small film roles, didn’t have to audition for her role as one of Loveless’ buxom blonde assistants, Amazonia. She wasn’t necessarily looking to make a career of acting, but was simply intrigued by the project. “I just saw it as a ride I took,” she tells me. Sofia Eng auditioned in New York for a German character named Cassandra, for which she’d stopped a German woman in a department store in order to listen to her accent. She got a callback, during which Sonnenfeld fell off his chair laughing, she says. Eng, however, ended up playing a different part — another of Loveless’ assistants, a lip-reader called Miss Lippenrieder — while Cassandra became Miss East, a seductress played by Bai Ling. Ling had just starred in Red Corner with Richard Gere. “At that time, I was in demand and a lot of people wanted to cast me,” she says.

Once the cast was assembled, a read-through took place on a horse ranch in Burbank. When Branagh arrived, he’d shaved his beard in the style of his character. He proceeded to dazzle the room with a committed Southern accent. He was “amazing,” says Sonnenfeld. He was so convincing, in fact, that Warner Bros. executive Lorenzo di Bonaventura asked Sonnenfeld if they should fire Branagh and cast whoever this guy was. Sonnenfeld told him that guy was Kenneth Branagh.

It had always been Sonnenfeld’s intention that Kline be the straight man to Smith’s funny man. This was a formula that had worked well for Men in Black. “I never felt that the chemistry between Will and Kevin Kline was similar to the energy and personal chemistry between Will and Tommy Lee Jones,” he says. “I couldn’t convince Kevin, hard as I tried, to be the straight man. He wanted to be funny.” With two actors trying to out-funny each other, the film was on wobbly ground from the start. (Or, as Honest Trailers puts it, “Meet Jim West and Artemus Gordon, the serious straight-shooter and the wacky sidekick, but they never settle on which one is which.”)

In between scenes, because his character painted, Kline would spend time painting. He asked to paint Eng. “He became almost like a little bit of a mentor, talking about his past,” she says. She thought that he might be stressed: “All of a sudden there were other, younger men coming in and getting his parts.” He may have felt threatened, she says, and worried that he was no longer leading man material. Van der Wal says that she picked up on a rivalry between him and Branagh, which Sonnenfeld would fuel by asking, for example, whether Kline had performed in a play in which he knew Branagh had starred. “Kevin definitely was at times not the happiest person,” she says. “He didn’t like to be not loved. Most actors want to be adored at all times. He was a little pouty, even. Will is a bigger star; Barry loves Will.”

If Smith was unhappy with how the film was looking, he didn’t show it. “Will was the person that was always sort of the jokester,” says Eng. “He was always laughing, joking, running up to you, hugging you, flirting — but not flirting, obviously, he was super in love with his wife, so he wasn’t flirting like that — but he was always, like, the charming guy.” Van der Wal played chess with him during breaks in shooting. “As an experience, it was wonderful,” she says. Ling adds, “He’s very open, he’s very joyful, he’s very free. He’s like a big child.”

Wild Wild West was the third film Pierce Austin, Smith’s hairstylist for 26 years, had done with the action star. He says that the studio has data on how a movie performs based on its lead actor’s appearance. As such, Smith’s look was the subject of much focus. “Many different parties had their own opinion of what his character should look like, so it changed throughout the movie,” Austin says. “If you look at the beginning of the movie, he had a longer beard; then it went to a shorter, more groomed, 1990s-style beard.”

One scene of Smith’s in particular became a sticking point for Sonnenfeld. When Loveless threatens to destroy the country unless the president divides it between Loveless, Great Britain, Mexico, France and Spain, Smith’s character Jim West turns up disguised as a belly dancer. The villain is transfixed by this exotic woman and becomes so distracted that West is able to release Loveless’ captives, including Artemus Gordon. “I never wanted to see Will in drag,” says Sonnenfeld. “I thought it was prurient, unnecessary, silly and in there only because Peters loved it and refused to let us take it out.”

“We really lose the audience from there till the end of the movie because of the stupidity of that weird harem dance,” he continues. “I cringe every time I think about it.” Until the dance, he says, it’s a good scene. Loveless is scary, and the audience believes that he’s going to take over America. “But then it’s like, ‘Oh wait a minute, I’m gonna forget all that because there’s a harem girl who I didn’t invite — I’ve no idea how she got here — but boy she’s sexy, and who wants to take over America when there’s a girl in a green harem outfit next to me?’ It. Made. No. Sense.” (Sonnenfeld, who wasn’t powerful enough to stand up to Peters at the time, says that if the same thing happened today, he’d simply walk off the movie.)

When test audiences saw the film, their feedback was that Smith wasn’t funny enough and that it was too PG. Eng says that they wanted more romance and innuendo. And so, an introductory scene in which Smith is bathing with a woman in a water tank wasn’t only re-shot to include more touching, but the actress was also re-cast without her knowledge. Rather than admitting that they’d requested there be no touching in the original scene, the studio told the actress that she had no chemistry with Smith, Eng claims. Meanwhile, the actress had sent postcards to “every casting director in L.A.” telling them she was in the film.

Eng thinks that Warner Bros. spent an additional $20 to $40 million in response to the audience feedback. They cut lots of funny characters from an early saloon sequence, and she says, believe it or not, they actually toned Loveless down. They brought in script doctors. “They completely cut it into pieces when they freaked out,” she says. “That’s why the movie was destroyed, in my eyes.” Harlocker says that it’s “a huge mistake” to tinker with a film as you go. “It’s why people like Spielberg don’t change course,” he explains.

Sonnenfeld seems to have found the innuendo extremely tiresome. At one point, a Loveless assistant looks through a periscope and spots West and Gordon. She tells Loveless, “I have them in my sights, sir.” The villain, staring at her buttocks, replies: “As do I, Munitia.” Looking back, Sonnenfeld says of his own film, “Oh, Jesus Christ, what is this movie?” When he had edited it and watched it with Warner Bros., Sonnenfeld thought, I don’t know if I can fix this. He knew it wasn’t good. “It was neither here nor there,” he says. “Tonally it was confused. I think there’s a better movie there than we released, but not a very good movie.”

Promoting the film, Smith committed totally, wearing different cowboy outfits in the various countries on the press tour. Sonnenfeld tells me that Warner Bros. paid for three corporate gulf stream jets for the film: one contained Smith, his family and his entourage; the other was for Sonnenfeld and his people; and the third was empty in case at any point Peters decided to join the tour.

The premiere on June 29th was a lavish affair, says Steve Wilson. There was a procession that stretched across the street and a party in a parking lot. People had confetti shot over them. But the fanfare could do nothing to hide how bad the film was. Wilson was sitting at the very back of the theater, next to Brent Maddock and the producers who had originally hired them. “I had to sit there with my hands over my face, in horror, watching this awful, pointless, stupid movie,” Maddock says. He compares it to watching one’s child get tattooed. Every one of their ideas apart from the spider had been dumped. “It would have been nice to get a phone call: ‘Let’s call the writers who spent two years writing this movie and say, “I apologize for not shooting what you wrote.”’”

When I ask Sonnenfeld about this, he says he can’t really talk about Maddock and Wilson because he doesn’t remember them or their scripts, though they’re the most prominent writers credited — something they’re still staggered by. To this day, Wild Wild West made them more money than any other project, but Maddock says that he’d give it all back if the studio would make the film they’d written.

The cast members I speak to as well think very little of the film. “This could have been such a breakthrough for my career,” says Eng. “It could have changed my life. There was talk about making us Barbie dolls. There was so much talk about what we were gonna become.” Van der Wal, who thinks the film is ridiculous, says, “In America, funny isn’t always so funny to me.”

Ling is the only exception. “Don’t even think it’s not successful,” she tells me. “Of course it’s super-successful. In history, when money doesn’t matter anymore, this film is one of the best.” She doesn’t care how the public or the industry judged it. “It’s a beautiful production in its own way,” she says. When she watched it in China, her mother asked her why she exposed most of her ass in the scene in which she seduces Smith. “In the mood of seducing, I didn’t care what part they showed because that’s not my concern,” she says. When she saw the film on the big screen, she said, “Wow, my ass looks so beautiful and sexy, I’m so proud it’s captured on screen.”

Wild Wild West was released on Fourth of July (a holiday weekend Smith owned at the time) and promptly savaged by the press. “The elaborate special effects are like watching money burn on the screen,” wrote Roger Ebert, the most biting and representative of the bunch.

Famously, Smith turned down the role of Neo in The Matrix in order to play Jim West, a decision that, with the gift of hindsight, looks inexplicable. As his most famous failure, the film has since hounded him, and recently he’s adopted a self-deprecating tone about it, apologizing for its mediocrity. Last February, he said, “I’m not proud of it.” Meanwhile, promoting Aladdin in May, he said, “This movie is spectacular. And I know what you’re thinking: You’re like, ‘Boy, you said that about Wild Wild West.’”

Unfortunately for Maddock and Wilson, the fact that their names were so prominent in the credits did hurt their careers. “In the long run, it would have been better if we hadn’t gone near that production because you go down with the ship,” says Maddock. “You look over there and the captain’s in the lifeboat. It’s like, ‘No, dude, you’re supposed to go down with the ship, too.’” Yet the director and cast seemed to emerge unscathed, Smith being nominated for an Oscar for Ali in 2001 and Sonnenfeld directing the popular Men in Black II the year after that.

Still, it wasn’t totally for naught. After all, as Maddock says, “You learn nothing from watching a great movie because a great movie lures you in and you lose yourself. It would be wonderful and very instructive to do a course in failed movies.” He’s right: When the pain is visible and the effort palpable, we see how easily things can go wrong. And in that gap between genius and mediocrity, we glimpse what might have been.