As a takeoff on the mismatched buddy-cop genre—happily passe in its original form nowadays—Adam McKay’s “The Other Guys” is certainly an improvement on Kevin Smith’s atrocious “Cop Out.” But it’s still too bizarre, repetitive and chaotic to make the grade. The scattershot approach yields some very amusing moments, but as a whole it goes downhill pretty fast.

Fastidious paper-pusher Allen Gamble (Will Ferrell) and hotheaded Terry Hoitz (Mark Wahlberg), transferred to desk duty from the streets because of an unfortunate incident at Yankee Stadium, are incompatible partners in the precinct run by long-suffering Captain Mauch (Michael Keaton). The stars of the office are wild guys Highsmith (Samuel L. Jackson) and Danson (Dwayne Johnson), who are clearly modeled after the “Lethal Weapon” duo of Gibson and Glover, though in this case both are reckless mad dogs. Gamble and Hoitz not only labor in their shadow, but are the butt of constant jokes by another pair of detectives (Rob Riggle and Damon Wayans, Jr.).

But when Highsmith and Danson take one risk too many in trying to arrest a band of high-flying crooks who’ve used a wrecking ball to rob a bank, Hoitz insists that he and prissy Gamble attempt to take their place as department stars. Gamble reluctantly goes along, and eventually grows even more intent on solving a labyrinthine case centered on shady investment mogul David Ershon (Steve Coogan).

Most of the plot complications involving Ershon, frankly, aren’t terribly interesting, although Coogan tosses off some hilarious one-liners and carries off a couple of clever bits (like a digression having to do with his efforts to bribe the boys). And the action set-pieces are staged decently enough, but they don’t generate the intended laughs, except for the close of Highsmith and Danson’s biggest stunt.

That’s characteristic of the whole movie, which is a hit-and-miss proposition. The scene in which Hoitz accosts the girlfriend who dumped him at a ballet school, for example, is funny, but the stuff centered on Gamble’s home life with his sultry, unaccountably accommodating wife Sheila (Eva Mendes) falls flat. Keaton has some great moments, especially in a pep talk he gives to his workers in his second, off-duty job, but all the material dealing with the villains after Ershon is dreary. And as the picture goes on, the ratio goes further into negative territory. A repeated bit about homeless guys using Gamble’s car for sex orgies is tasteless. An episode featuring Gamble’s ex-girlfriend (Natalie Zea) and her prissy husband (Brett Gelman) is a bust. None of the stuff featuring Riggle and Wayans works. A musical montage showing the guys during their inevitable separation seems less like a spoof than a cliché. And when Ershon’s mark to cover his staggering financial losses is revealed, it turns out to be somebody whose identity has been so insistently telegraphed that you have to wonder whether McKay simply doubts the intelligence of his audience.

All comedies have slow spots, of course, and “The Other Guys” compensates more than many do with ones that work. And Ferrell is less offensive than he usually is, his goofy naivete resembling “Elf” more than “Anchorman.” (Mercifully, he also dispenses with his usual stripping-down scene.) Wahlberg, moreover, is a game straight man, although his hot-headed outbursts get tired fairly quickly. Coogan and Keaton certainly earn their share of chuckles. And Jackson and Johnson obviously relish going overboard as the publicity-seeking duo. But Riggle, Wayans and Mendes are pretty much wasted in material that doesn’t tax their talents, and nobody else makes much of an impression. Technically the picture is solid, with clean widescreen cinematography by Oliver Wood and visual effects that are more than adequate.

So McKay’s picture is definitely funnier than other spoofs of the buddy-cop genre, but it’s still a very mixed bag.