This is The Mechanic, where Alex Wiltshire invites a developer to help him put their game up on blocks and take a wrench to hack out its best feature, just to see how it works. It’s about the sweat, grease and genius behind the little things that make games special.

Here’s a question: How do you solve a problem like Geralt? There he is, stern and stalwart, everyone’s favourite low fantasy drifter. A man of rank bogs, blasted no man’s lands and rugged islands. A man who isn’t much of a laugh, or awfully fun to have a drink with.

But what if you want to extend his world, and expose him to new adventures? That’s what last October’s expansion to The Witcher 3 [official site], Hearts of Stone, aimed to achieve, but it had to get Geralt doing things he’d never normally do. So how did CD Projekt manage to get him drunk and dancing at a wedding, robbing a bank, and appraising fine art? Their solution was deft.

(Warning: what follows has some spoilers for Hearts of Stone, but nothing critical. If you’re worried, go play it first – it’s great – but I promise there’s still everything to discover if you do read this now.)

OK, so a deal with the devil isn’t strictly a mechanic. It’s more of a narrative feint. But it’s an interesting design solution all the same, one that grapples with The Witcher 3’s distinctive take on the modern RPG, in which it ditches character development in return for giving you a very fully-drawn character to play as.

So the conceit behind Geralt is that Witchers like him have gone through all manner of awful physical and mental trials, having been fed poisons since childhood that make them superhuman. These experiences has caused popular opinion to drift toward a view of them as emotionless, but while Geralt’s pretty inexpressive, he’s not emotionless. His emotions run deep; his convictions are serious and strong and expressed through deliberate action and a good line in sarcasm.

It makes him a fine companion. He doesn’t say much, doesn’t do stupid things. He’s a badass, and a measured one. He’s Clint fucking Eastwood. But that also means he isn’t the kind of person you’d go to a party with. He doesn’t let his hair down, doesn’t like to share his feelings. Doesn’t get drunk, doesn’t put innocents in peril or steal from them. He hates formality and wealth: his home is the road. This attitude very much informs the nature of what he does in The Witcher 3.

And that made it very hard for CD Projekt to find a solid narrative foundation for Hearts of Stone. “We wanted to tell a story that put the players in different situations to the main game, wanted it to be very different,” lead quest designer Mateusz Tomaszkiewicz tells me. But with it came the struggle to justify why Geralt would participate in these different kinds of quests as the team began planning Hearts of Stone, three months before the launch of The Witcher 3.

The answer lay in Pan Twardowski, a Polish folk story. It’s about a sorcerer who signs a pact with the devil but then wriggles out of it by including a clause that prevents the devil from completing his side of it. CD Projekt had written a quest inspired by the story, which became a chain of quests, which then mutated into the spine of Hearts of Stone: with Geralt having made a deal that he can’t back out of, he’s forced to do things he’d never normally do.

The trick to CD Projekt’s ruse is the simple way you find someone as badass as Geralt getting into matters way over his head. Geralt comes across a job to slay a monster – a toad – lurking in the sewers beneath Oxenfurt, but when he kills it, he discovers it’s actually a cursed human. A prince, in fact (a neat little fairytale turnabout), and in killing him Geralt attracts the ire of the prince’s people, who take Geralt prisoner and sentence him to death. Enter Gaunter O’Dimm, who says he’ll save Geralt in return for an open promise of repayment and branding a curled pattern across the side of his face.

This introduces another trick. The brand serves to make the quest feel urgent. “It reminds you’re somehow in debt,” says Tomaszkiewicz. He was concerned that Hearts of Stone’s quests needed to both capture players, giving them a strong incentive to play it, and also ensure it felt grounded in the main narrative. The brand is always visible, no matter how distracted you get in other things.

Still another trick enters: Hearts of Stone’s roots are, in fact, embedded in The Witcher 3’s main story. We met Gaunter O’Dimm (otherwise known as Master of Mirrors, Master Mirror and Man of Glass), in the pub in White Orchard right at its start. He reveals in conversation that he knows who both Geralt and Yennifer are, and having said, “Perhaps one day I’ll be in trouble and you’ll be nearby to help,” he disappears from the storyline. You probably forgot him, but it feels fitting to look back and realise he was bound to turn up again. And as as it happens, he is a constant yet subtle presence, noticeable if you’re observant enough.

Hearts of Stone’s final trick is to obfuscate the whole deal with the devil thing, or at least make it unclear who has made what deal with whom. So the person who posted the job to kill the beast-prince was Olgierd von Everec, the oddly aristocratic leader of a group of bandits. So Geralt wants paying for that. When O’Dimm saves Geralt from the executioner, his price is Geralt performing three wishes for Olgierd. Because – I hope you’re following this – Olgierd has also entered into pact with O’Dimm, a pact on which O’Dimm now wants to collect. His trouble is that Olgierd cunningly inserted a Twardowskian clause into it: O’Dimm can only collect if he can get a proxy to perform three wishes first.

The stage is therefore set for Geralt to take on those three tasks, and you’re wondering exactly who is playing who. And Olgierd has made his wishes seemingly impossible. Geralt has to give Olgierd’s brother the night of his life, to bring him some guy’s house, and also the violet rose he had given his wife the last time he saw her. Trouble is, his brother’s dead, the house is somehow locked in an almost unassailable vault, and the violet has long rotted into dust.

We’re invited to feel a fair deal of motivating enmity for Olgierd. He’s knowingly had Geralt kill a cursed prince he could have cured, an action that nearly caused Geralt’s execution, and O’Dimm sells him as a “degenerate monster in human flesh who feeds on the pain and suffering of others”. “We thought it’d be a good idea if you would have some personal grudge against the quest giver, Olgierd,” says Tomaszkiewicz. But he’s simply too interesting and charismatic for that to fully work. “I think it wasn’t as much of a motivation for people as we hoped,” Tomaszkiewicz says, having taken in the opinions in reviews and comments.

So you’re maybe not as driven as you could be as you begin Geralt’s labours, but their colour, verve and unpredictability soon makes up for it. There’s a heist, complete with the need to recruit the team, there’s bidding at an auction, and there’s a wedding, which comprises, as Tomaszkiewicz says, “A lot of dialogue, activities that are mostly about building the feeling of the reception rather than smuggling in action sequences.”

It’s achieved by having Geralt possessed by a boozy and highly sexed ghost, which makes it a lot of fun, but the wedding is also tender and rather sad under all the weirdly sparse videogamey revelry and the bizarre grin Geralt wears while possessed. The union is awkward, between families of different classes, and there are already fault-lines between the bride and groom. We hear the two fathers drunkenly discuss their finances and shames, and even as they toast their new relationship you can see it all going up in smoke. Meanwhile, sterile and forever wandering Geralt is at the wedding with Shani, an old beau from the first Witcher game. You can romance her into a bonk at a lakeside, but they both know they can never be together. The sequence also pokes fun at Geralt’s taciturn nature, and this exercise in removing him from the story actually ends up expanding your awareness of how other characters see him.

The heart of the expansion is the quest Scenes From A Marriage, which peels back Olgierd’s past. It does that with a series of puzzles, which are pretty rare in The Witcher 3. “One of the design principles for The Witcher 3 in general was that if we’re doing something like this, it can’t just be a pretext to pull a few levers,” Tomaszkiewicz says. “It has to be embedded in the story, has to be consistent with the story, to tell you something.” The puzzles aren’t hard, but the truths they illuminate are, offering new layers to your understanding of this triangle of pacts you’re entangled within, and preparing you for making a final choice at its climax.

So how do you solve a problem like Geralt? Hearts of Stone’s answer is to make him an offer he can’t resist and a price he can’t afford. The result is quite different to anything you play in the main game, and yet the same rich and humanistic heart still beats under it all, and at its end, the world and Geralt himself seem even more vivid.