Nicol Williamson really knows how to get into a part. As the ghost of the legendary actor John Barrymore in the new Broadway comedy “I Hate Hamlet,” he’s perfectly cast: he’s a brilliant actor, he’s mercurial and he once had a reputation as a world-class carouser, Now, a month after opening night, Williamson is staying right in character-and embroidering his own colorful legend.

Playing Barrymore, he comes back from the dead to coach a slick Los Angeles TV star who’s going to play Hamlet (Barrymore’s most famous role) in a summer production in New York’s Central Park. Actually, he doesn’t coach so much as goad. So no one in the audience was surprised one night, a fortnight ago, to hear Barrymore suddenly bark at his protege, “Put some life into it! Use your head!” And later in the same act, when the ghost engaged the inept TV star in a sword fight, no one thought anything was amiss when Barrymore whacked the young actor on the rear. Until, that is, the young actor (Evan Handler) playing the young actor stalked offstage. “Well, should I sing?” asked Williamson, standing there in tights and tunic, deserted on stage until the curtain came down. Handler’s understudy had to finish the evening’s performance.

This unscripted little drama (including Williamson’s command to “put some life into it!”) is more exciting than anything else about “I Hate Hamlet.” And it has given the show the kind of word-of-mouth it never could have managed otherwise. Handler swears he was “purposefully and maliciously struck”; he says he still had a bruise a week later. He’d complained he felt in danger in the fight scene: “Nicol would be extremely uncoordinated and unsteady on his feet and have slurred speech,” he says. Of course, the Barrymore character, who keeps drinking from a champagne bottle, is played as a drunk.

Producer James Freydberg thinks the missed parries and final blow of the fateful sword fight were “perfectly innocent.” Though he told Handler to walk off if he ever felt in danger, Freydberg thinks the injury was to Handler’s pride. Others involved in the show talk about the “complicated” Scottish star and tensions that go back to the early days of previews. Says Adam Arkin, who was nominated for a Tony award for his role as a crass TV producer, “At our worst, we were a pretty dysfunctional little family.”

Williamson is hailed as inspiring by Arkin and other cast members, but his behavior has hardly been endearing. In an interview in The New York Times, he complained that the play could have been much better if only the producers had listened to him. He also decided he didn’t like being onstage, as directed, when Barrymore has no lines. So he simply exits. Petulant habits die hard. Years ago he used to stop dialogue while latecomers were seated and he once slapped a chorus boy who made a remark while Williamson was taking a bow. On the infamous night of “I Hate Hamlet,” he berated Handler for leaving the stage by telling the audience it was “an unprofessional thing to do.” He neglected to mention that he once stormed off a stage during an opening night in Boston in 1969. What play was he starring in? “Hamlet.”

But no matter what antics this aging bad boy comes up with, the producers understandably adore him. Because without Nicol Williamson, “I Hate Hamlet” would evaporate like the ghost of Barrymore. It’s a flimsy farce that predictably skewers the shallowness of popular culture. There are some very funny lines, many of them from Arkin as the Hollywood producer trying to persuade the TV star to take a series and not do Hamlet. Performing in Central Park, where the audience munches on nuts and raisins, isn’t even dinner theater, he says: “It’s snack theater.” But it’s Williamson as the marvelously hammy ghost, telling his young charge how important it is to play Hamlet in tights-in order to attract women-who anchors the show. Barrymore and the TV star ought to have the right chemistry; if bad blood spills over from offstage, it could be fatal.

Handler, who had gotten some poor reviews, was planning to leave the show in June. But for understudy Andrew Mutnick, this is the big break that bad showbiz movies are made of. Mutnick says, “Nicol has been really quite incredible and supportive and encouraging.” Two days after Handler walked, Williamson gave an impromptu speech to the audience: “You’ve heard we’ve been through difficult times and Andrew’s done wonders.” A few nights later, in the sword-fighting scene, Mutnick stabbed Williamson in the leg. Accidentally. That’s show business.