You don’t have to look very hard to find movies about the aged fighting against their own mortality, and a large subset of that genre deals with aging performers playing versions of themselves for metatextual appeal. The Hero is one of these legacy celebrations—or self-aggrandizements, depending on your point of view—and I’m pleased to report that it mostly hits all the right beats for giving Sam Elliott a late-career showcase for his talents as we might not otherwise have remembered him. And while I’m not convinced that The Hero is going to be a film that Elliott is remembered for, it will certainly demonstrate that he has a much greater dramatic range than most give the cowboy credit for.

Lee Hayden (Elliott) is an old actor struggling to find respectable work, managing only to do commercial voiceovers and reminiscing over his one great celebrated role. That is, until he is diagnosed with pancreatic cancer, and the prospect of imminent demise puts his whole life in perspective. His only friend is his weed dealer (Nick Offerman, decidedly as comically far removed from Ron Swanson as possible), and he seeks comfort in dating a significantly younger woman (Laura Prepon). Meanwhile, he struggles to reconnect with his ex-wife (Katharine Ross) and estranged daughter (Krysten Ritter), not admitting his diagnosis even to them.

What’s remarkably refreshing about The Hero is that even as we watch Lee struggle with his depression and self-perceived lack of legacy, writer-director Brett Haley is not afraid to inject uproarious humor into the proceedings, often in the form of outlandish performances that aren’t so absurd that they become unfixed from the film’s reality, but are rather the kinds of stunts people pull as inside jokes on an unwitting public. And this in no way detracts from the heavier moments of the film, which really do allow every member of the cast to stretch some dramatic muscles that you may not even have suspected they had. For such a varied cast of character actors from a plethora of backgrounds, they all are up to the task and keep up with a clearly determined Sam Elliott to create a fantastic supporting ensemble.

The film starts to falter, though, when it gets a little full of itself, particularly in dream sequences in which Lee’s glorious Western past begins to intersect with his horrifying present. These dreams are indeed surreal, but whether for a lack of budget or creativity they come across as uninteresting due to how obvious they are in the points they represent. It also doesn’t help that Prepon’s character, for all of her charms, is a bit of a pixie dream girl archetype, so the film’s ending is a fairly foregone conclusion once the shape of their relationship begins to develop.

Still, The Hero is about as good as these stories get without someone masterfully inventive behind the camera, and The Hero doesn’t aim much higher than merely being effective. It’s selling you a late-career Sam Elliott movie in a mold that many an aging actor likes to fill, but it at least delivers on that promise with a solid script and a remarkably engaging supporting cast. If nothing else, you’ll rethink just how good of an actor Elliott can be if given the right material. And maybe in achieving that goal we’re not quite done seeing what Sam Elliott can achieve in the future.