The pub crawlers in The World's End.

Director Edgar Wright teams with Simon Pegg and Nick Frost for the raucous conclusion to their “Cornetto” trilogy with The World’s End, a twisted homage to male bonding, beer crawls and John Carpenter sci-fi. This movie works because of the sense that anything can, and will, happen.

Pegg plays Gary King, a somewhat troubled but good-natured man who is determined to get his old crew back together to complete a pub crawl in his hometown—20 years after the gang failed to make it to the last pub on their infamous crawl, an incident providing King with a nagging sense of unfinished business.

A good chunk of the film is actually a warmhearted, funny and well-written gathering of old friends, told in straightforward fashion. Some of the men from the old gang are fairly happy to see King, while others, like Andy (Nick Frost), would prefer he piss off. Still, even the apprehensive Andy joins the crew for what looks to be a taxing crawl of 12 pubs.

If The World’s End had just been a story about arrested adolescence, the dangers of going “back,” and the perils of drinking too much, it would have been a great movie. Pegg and Frost display solid dramatic chops to go with their comedic instincts. But thankfully, Wright and Pegg (who co-wrote the screenplay) have more—much more—in mind. The film takes a crazy turn in a manner akin to the big twist in From Dusk Till Dawn, and it suddenly becomes an alien-invasion movie. (This is prominently mentioned in the film’s ad campaign; I hope I didn’t ruin your day.)

Their hometown has become overrun with blue-blooded robots from another world—robots who are determined to replicate earthlings and dispose of their bodies (featuring shades of Invasion of the Body Snatchers and The Thing). This sets the stage for some awesome man-on-robot fight scenes. The choreography is hilarious and nasty.

On top of everything, the film works as a scathing satire of the infiltration of technology in our society, and how those damned iPads and smartphones are taking over. (I love my gadgets, even if they are swallowing my soul. They’re just so damned cool to play with!)

The cast also includes Rosamund Pike as Sam, who does a fine job of kicking ass and looking flabbergasted. Martin Freeman (Bilbo Baggins!) reminds us that he is a master comedic actor; he plays an uptight real estate agent who never, ever removes his earphone, even when he’s pub-crawling. Eddie Marsan breaks hearts as Peter, a once-bullied man who is actually distraught when his former bully (Darren Boyd) fails to recognize him.

In terms of the Cornetto trilogy (named for a brand of ice cream that appears in all three films), this one is just a notch below Shaun of the Dead, yet a little better than Hot Fuzz. All three are solid, funny, smart films that make me wish they were part of a 10-movie series.

Many of the summer blockbusters have been big, bloated messes that delivered messy action with little to no thrills. Well, The World’s End makes up for a lot of the summer garbage with its big heart, numerous laughs and eye-popping visuals. Wright and Pegg are sick in the head—and we moviegoers all benefit from their particular brand of insanity.

The World’s End is playing at theaters across the valley.