That skunky smell emanating from “Your Highness” ain’t pot; it’s the stink of miscalculation that surrounds an inside joke gone awry. David Gordon Green and longtime film-school buddy Danny McBride burn through their biggest budget yet on a witless medieval stoner comedy, larding it up with the sort of juvenile titillation — boobies, double entendres and schoolyard homophobia — they no doubt found lacking in the ’80s fantasy fare of their youth. Boasting good-sport support from before-they-were-Oscar-nominated James Franco and Natalie Portman, pic best serves potheads or underage guys far more likely to hit it on homevid.

When he isn’t blowing smoke or sowing his oats, spoiled prince Thadeous (McBride) can’t help but feel inferior to Harlequin-handsome older brother Fabious (Franco), who repeatedly puts Thadeous to shame with his valiant quests. Returning from his latest feat, Fabious surprises the kingdom by presenting beautiful virgin Belladonna (Zooey Deschanel) as his bride-to-be. While Thadeous sulks, a pervy wizard named Leezar (Justin Theroux) interrupts the wedding and kidnaps Belladonna for his own nefarious ends, plotting to rape Belladonna during the once-a-century alignment of the otherwise Earth-like planet’s two moons.

Royally peeved, King Tallious (Charles Dance) insists that his good-for-nothing son and loyal manservant Courtney (Rasmus Hardiker) join Fabious on what promises to be a challenging mission. From its irreverent opening credits, presented in the form of a graffiti-despoiled storybook, “Your Highness” offers a raunchy, R-rated twist on the already self-aware “Princess Bride” fairy-tale formula, conjuring swarms of topless Amazons, a randy minotaur and so on. But the pic tries to have it both ways, building up to one of those feel-good finales that demands precisely the sincerity McBride and co-writer Ben Best seem to be rejecting at every step.

While the be-mulleted McBride fits the boorish Thadeous to a T, the more flatteringly coiffed Franco may well be too good a thesp for his part, actively having to strip back his acting instincts for a role that seems better suited to one of his hunky “General Hospital” castmates. The siblings meet their match in Isabel (Portman), a skilled female warrior whose bathing attire will surely rekindle fanboys’ Princess Leia slave-girl fantasies — objectification masquerading as empowerment.

Those who discovered Green in the days of “George Washington” and “All the Real Girls” will find nothing of those films’ clear-eyed sensitivity here (though this Universal-backed effort, like “Girls,” does feature McBride and Deschanel). Rather, “Your Highness” feels like an unwieldy extension of “Pineapple Express'” genre-bending antics, with Green struggling under the weight of all the elaborate locations, sets and visual effects that a knight’s tale calls for.

Whereas “Pineapple Express” found Green operating under Judd Apatow’s wing with the benefit of a solid comedy script, “Your Highness” has a reckless, half-baked feel, like something hatched by teenagers during a cannabis-clouded slumber party: Obviously, the title came first, followed by lame one-liners (“Do you feel that tiny prick in your back?” Thadeous asks, holding Isabel at knifepoint) and other immature ideas.

One gets the distinct sense that these guys feel as if they’re getting away with something, and are rushing to cash in on their freedom before the grown-ups take away their toys. In the meantime, Green and McBride seem determined to defy the very system that’s accommodating them: At one point, the film’s heroes face off against Marteetee (John Fricker), a diaper-clad adversary who uses his hand to control a five-headed Hydra. As Isabel lops off his fingers one at a time until only the middle one is left, it’s hard not to see that gesture as being directed at the industry itself.

There’s a place for such subversion, but Green isn’t slick enough to pull it off. However impressive the results of his earlier work, indie drama can be less demanding than the brand of action or comedy that “Your Highness” calls for. The humor, simultaneously homophobic and genital-obsessed, aims low and misses most of its targets, while the fight scenes are a noisy blur of mismatched shots set to an overkill score by Steve Jablonsky (“Transformers”). After being pushed back from an October 2010 release, pic seems to be offering its sub-SyFy Channel effects in the spirit of satire.