In the days and weeks following the gruelling rescue of 12 boys and their football coach from the Tham Luong caves in 2018, the Thai government took control of the story. Or, more accurately, took control of the boys and the rights to their story.

“The Ministry of Culture were the custodians of the children’s rights,” says Tom Waller, the director of a new film about the rescue, The Cave. “They were protecting the boys’ interests for the first six months [after] they got out.”

Like tens of millions of people around the world, Waller had watched from afar as one of the worst fears the human psyche can conjure was being played out in real time: that of being trapped in the dark, in a cave, with no way to escape.

'It reminds me of miracles': fascination endures one year after Thai cave rescue Read more

Waller, whose mother is Thai, joined the scramble to tell the story of near impossible odds. But the main protagonists, the children, were taken out of the frame when the government signed a deal with Netflix and a US production company to film a miniseries. “All we were told was that we weren’t allowed access to any of the children, or their relatives.”

In Ireland, where his Irish father lives, Waller met Jim Warny, one of the rescue divers. And so Wallers’ retelling of the rescue shifted focus to the divers themselves, and the other “unsung heroes”. The influx of people who dropped everything and drove for many miles to go to the mountain to help, and were “turned away because they didn’t have the right badge or a permit”, Waller says. “The farmers closest to the site whose crops were flooded and destroyed, and [who] refused to accept the compensation money the government offered them. The man who drove his water pumps 900km from Chang Mai. Nobody really knows about them.”

The Cave features four of the divers playing themselves – Warny, Erik Brown from Canada, Mikko Paasi from Finland, and Tan Xiaolong from China – giving the scripted drama a documentary feel as they re-enact the rescue. (The British and Australian divers had been approached for other projects.) It is not frightening, not excessive, not filled with dramatic, emotion-milking trickery; instead it is an account of an extraordinary 18 days, in which acts of courage, kindness and humanity are performed almost matter of factly.

Facebook Twitter Pinterest Rescue divers Erik Brown and Jim Warny, who play themselves, behind the scenes of The Cave. Photograph: De Warrenne Pictures Co Ltd

But it didn’t come easy for Waller. In the first months of shooting, the government was still protecting its assets. “It was very difficult, almost impossible to get official permission to do anything. It made it difficult to legitimise the project,” he says. Eventually the ministry would approve the film with no cuts and a general audience rating, but until then “we sort of made it under the radar, really”.

Initially denied permission to shoot at the Tham Luong caves, Waller had to find other ways to tell the story.

“We mapped out the skeleton of the movie on a large whiteboard, much like the rescuers had plotted out the caves on a board with a marker pen, marked up from chamber one to nine, and all the little passages in between,” he says. They shot in other caves, in other parts of Thailand – and got inventive too. “We built a cave complex on top of an Olympic-sized pool, which was abandoned and in a secret location.” (After months of lobbying, the ministry finally allowed them access to Chang Rai for some final shots.)

The film takes the viewer through the caves with the divers and boys almost voyeuristically, recording what they said to each other; witnessing their exhaustion. While he shied away from making it claustrophobic, Waller wanted to show the part of the story that had been unseen by the public: the journey through the caves.

Warny, who plays himself, remembers those July days vividly. He had heard about the boys, and texted his friends from the British Cave Rescue Council one afternoon after work, saying: “I am here if you need me.”

There was a great amount of danger, and a great amount of luck Rescue diver Jim Warny, who plays himself in The Cave

“Five minutes later I get a text back saying ‘how soon can you be ready?’,” he says. “And the following morning I flew out to Thailand.” He arrived on the first day of the recoveries. “Since Saman [Gunan, former Thai SEAL who ran out of oxygen] had passed away, the Thai authorities had removed the army from cave diving. They realised it is an experts’ job.”

Warny knew that the operation was high risk, that it was highly likely they would lose some of the boys on the way out. The Australian rescuer, Richard Harris, had put their chances at “zero”.

But, says Warny, “by the time we got given the go-ahead, there were no other solutions”.

The boys and their young coach were to be given Xanax and then ketamine shots to keep them unconscious as they travelled through the 2.6km of the caves, much of which were underwater. Too small a dose and the boy might wake up, panic and endanger everyone; too big a dose and he might not wake up at all.

“We were not at all confident,” Warny admits. “Usually cave diving rescue is body recovery. We were operating completely outside procedures. Rendering the kids unconscious inside the cave and then bringing them diving had never been done before. So all these things were way out of anybody’s practise or experience … There was a great amount of danger, and a great amount of luck involved in everything working.”

The film shows the coach Ekapol Chanthawong, 25 (played by Ekawat Niratworapanya), waking up and opening his eyes as they slogged through the caves, and Warny – terrified – having to hastily inject more ketamine to knock him out again, fumbling with the needles in the muddy water.

“You don’t ignore your emotions and fears, but you use them to your advantage. You go into a state of constantly calculating your survival chances, and what your next step is going to be,” Warny says now. “The big emotional baggage [was] that responsibility for a young person’s life. That was the harder one to suppress and to manage.”

• The Cave is playing at Busan film festival on 10 October, BFI London film festival on 11-13 October, and QCinema in Manila on 17 and 20 October. It closes the Byron Bay film festival on 26 October