Think back to the first moments of Witcher 3, just after the tutorial section in the witcher keep. Geralt and Vesemir, talking naturally together on the road to Vizima, subtly lay out the backstory, reiterate the mission to find Yennefer and indulge in some playful repartee - the writing feels seamless and uncomplicated, as though it arrived fully formed onto the pages of a performance capture script. According to lead writer Jakub Szamalek, however, it did not.

"I actually checked how many times I edited the dialogue in that scene," he recalls during our interview at Spanish sci-fi festival Celsius232. "I think it was over 120. Sometimes these were minor edits, changing one sentence, but sometimes it was rewriting the whole thing. We did a lot of that: writing something, playing it, tweaking it, scrapping everything then re-doing it. It is just inherent to the process. There are so many moving parts when you're working on a video game, it's unavoidable." It turns out, constructing the narrative behind Witcher 3 - one of the most ambitious and enormous open-world games ever made - was not easy.

Jakub Szamalek. Image credit Celsius232.

Szamalek joined the writing team at CD Projekt Red in May 2012, a few months after pre-production on Witcher 3 had begun. At this point writers Sebastian Stępień, Marcin Blacha and Arkadiusz Borowik had already started to create a master document, a 60-page manual which contained a story synopsis, descriptions of the parts of the Witcher world the story was set to explore as well as background information on the key characters and concepts. The next step was transforming the treatment into a game script. This involved dividing it into smaller parts focusing on the three main hubs - Novigrad, No Man's Land and Skelligeand - then subdividing into quests, writing the dialogue and detail, and linking to other quest and character documents. "It was like a set of Russian nesting dolls," jokes Szamalek.

Although the team used Google Docs for cutscene scenarios and Excel spreadsheets for localisation production needs, most of the writing was done in a proprietary editor, written specifically for the game. "The upside was that we could mold it relatively easily for our needs - at least in the early days, when the programmers weren't flooded with other tasks," says Szamalek. "The downside was the tool was rather unstable for most of the development, so we had to endure veeeery long loading times and it crashed every once in a while, so you needed to save your work every five minutes."

:: The 20 best Nintendo Switch games you can play right now

Another major technical challenge was the fact Witcher 3 was CD Projekt Red's first truly open-world title so, according to Szamalek, a lot of the development tools were being written alongside the production process. "We were working on the game and on the engine at the same time, which meant the editor was hugely unstable and new features were coming in all the time - it was a pretty rocky road to release."

This content is hosted on an external platform, which will only display it if you accept targeting cookies. Please enable cookies to view. Manage cookie settings

Look at the classic moments - the folk horror of the Whispering Hillock mission, the family tragedy of the Bloody Baron, the reunion on the Isle of Mists - they're filled with subtle emotion, with little gestures, with intense human qualities. But for most of the development period, the team didn't have the finished character models, environmental visuals or voice-over recordings to work with. While planning and testing narrative scenes, everything had to be fudged together with placeholder graphics, text and performances. For example, Szamalek recalls when he was working on a sequence where Geralt and Yennifer go hunting for a werewolf on Skellige. "This was an early iteration of the quest so we didn't have many assets," he explains. "Skellige was just this blob of land with grass textures, Geralt was being played by a Skellige Fisherman 02 model - and so was Yennifer. So we were basically using the same model of a bald guy for both of them, and it wasn't textured or animated, so it was two motionless grey characters, with no voice-overs, which meant early testers had to read the text at the bottom of the screen. And the camera was acting up - sometimes it would end up inside the character models or in the ground.

"So now we have this scene between two lovers where they rib each other a little bit and it's warm but there's a mean quality to it: Geralt has some distance from Yennifer, even though they still have a connection. There's a lot going on emotionally! But what staff reviewing the game are seeing is two bald Skellige fisherman. In these circumstances, it's very hard to assess if it's funny or not - you have no control over the delivery or pacing. It was extremely hard."

But it was also important. The Geralt of the novels is gruff and monosyllabic when his job demands it, particularly when negotiating with paymasters or enemies, but when he's with friends he's warm and sardonic. The writing team wanted to capture this lighter side to his character, but as Szamalek discovered, "telling jokes in a video game is very stressful. It's very hard to assess if they are going to work or not."

Comedy is not the only challenging factor to implement within an interactive space. In movies and TV shows, we're used to those quiet scenes where characters are seen just relaxing and bonding - these are crucial in revealing the relationships to the viewer while bringing variety to the narrative flow, and the Witcher 3 team wanted to provide similar moments - but they're tough in games, and Szamalek found the team had to find innovative ways to make the player feel and experience camaraderie. "There's the quest where the witchers reunite at Kaer Morhen," he says. At this stage, the player has completed a huge chunk of the story and has a decisive battle looming ahead of her. We felt she deserved a moment of respite, of fun - and meeting with old friends seemed like an ideal opportunity.

"The problem is, games are better at dynamic sequences - fighting, chasing, etc. - and have problems with quieter, more intimate moments. We wanted the player to sit down and drink with Geralt's old buddies - but where's gameplay in that? How do you engage the player, make her feel she's there, rather than just watching an interactive movie? In the end, we came up with simple tasks, based on already existing mechanics, to draw the player in - play a drinking game, go fetch something to eat, find a friend who was drunk and lost his way, pull a prank on sorceresses by dressing up in their clothes. The end result was pretty good - players loved this part - but it took lots of trial and error."

As production ramped up, another common factor of game development came into play: the question of artistic vision. Video game development studios are made up of separate teams - game design, narrative, programming, art - and all have their own vision of what the game is and how it will work. These differing perspectives are not always complementary, and in an interactive medium, it's usually the writers who have to remodel their vision: sometimes brilliant narrative concepts don't work when you factor in the agency and preferences of the player.

"When we began working on Witcher 3 we had this war-ravaged No Man's Land area - hell on earth basically," says Szamalek. "The residents were close to starvation trying to make ends meet, reverting to black magic, holding rituals to ensure their survival and so on. We had a really clear mental image of what this should be like. So we wrote our documents and handed them to the art team. Later, when we played the game, we entered the village and immediately we saw this old woman plucking geese - she'd pull out the feathers, put it aside and pluck another one - and if you stood there long enough she'd have this pile of 20 geese. Then we went into another house and there were all these sausages hanging up from the ceiling, and we're like, 'wait a minute, this is not what we imagined!' The environment artist said, 'yes, but if we remove all the food the place looks boring! The people have nothing to do! If everyone is hungry and destitute, they just sit around looking sad - it's not visually interesting for the player!' So we had to work out a compromise."

That wasn't the end of it though. "When the gameplay systems were implemented we went back to this war-ravaged land and talked to an innkeeper, and he says 'do you want to trade?' Then he opens up his inventory and he has swords and plate armour and thousands of crowns. And we say to the designers, 'guys, this is supposed to be a war ravaged village! These people are poor - they can't afford any of this stuff.' So the designers say, 'yeah, but think about the player - they have all this loot they've picked up on the way, they want to buy stuff.' I understand their aims and needs so we have to find the least bad solution that works for each of the teams involved."

There were also challenges in staying true to the novels, especially recreating some of Sapkowski's most memorable set-pieces. There's one sequence in the books where Ciri takes part in a battle on a frozen lake and puts on skates to give herself an advantage. "We really wanted to put that in the game, and it worked in the beta version," says Szamalek. "But then it turned out that getting motion capture footage of people skating and fighting at the same time was... difficult. We tried putting our actors on roller skates but then our motion capture studio is quite small so before they could gain any speed they'd be crashing into the walls. Sadly after trying several different approaches we decided to drop it."

Interestingly, as the graphical detail of the world came together, the visual fidelity of the Witcher 3 engine brought in new challenges for the writing team. As Szamalek recalls: "I remember one day, a lead environment artist came over to my desk and said, 'we are working on the fortifications for Novigrad - what kind of stone are the walls made of?' I said, 'I have no idea. Is there any information in the novel?' They said no. So I said, 'let's look at the level together and study the geology - if we look at that river, I don't think there would be any hard stone, so let's look where the river goes, it heads toward those mountains, so they could have hewn the stone there and brought it down via boats.'

"It's worth putting in that effort, even if players don't notice it consciously. I don't think they'll point to the fortifications and say, 'it's interesting they used this type of stone because, geologically, it makes sense,' but perhaps they register it. That's a part of what makes it all come together."

A key element of writing for an open world game is the need to provide scenarios and dialogue for cutscenes that are not tied to the main story, which can be used anywhere in the game, to add some context, intrigue or diversion for the player. And this being Witcher 3, these scenes weren't always about fighting or talking.

"At one point, a producer came in to the writring room and said, 'we need 12 cutscenes with sex - who wants to write them?' Nobody wanted to do it. If I remember correctly, I wrote them all. It was a pretty awkward process for everyone involved. First I had to come up with the scenario, and describe it - and writing it down for other people to comment on was awkward, and then the animation staff had to figure out how to show it and then they have to direct the mo-cap actors, which is awkward, and then the actors have to perform it and deliver the lines, which is also awkward. But sex is awkward anyway so it all works out fine in the end.

"For us, the point is, a sex scene should not be just be about showing some bodies. People don't play games to see sex scenes - there are more efficient ways of seeing that, so we always try to infuse the scene with additional reasons - to add some humour, or tell us more about the characters."

This content is hosted on an external platform, which will only display it if you accept targeting cookies. Please enable cookies to view. Manage cookie settings

In the later stages of development, one of the most challenging aspects was the writing team had to deliver all the dialogue three months before alpha because the voice performances all needed to be localised into 10 different languages. But until Witcher 3 went into beta, there was no game to speak of. It was in pieces. "At that point, we were unable to play the game from the beginning to the end," says Szamalek. "We could launch a particular quest, but playing the whole game and opening quests as we went and seeing how they meshed together was not possible. It did not run smoothly."

For an open world game in which players are able to explore and attempt quests in a myriad of different ways, this presented a huge logistical problem. It meant the writing team had to map out the whole game, and all its branching possibilities on paper. "We had a lot of tables and trees and diagrams and post-it notes to try and build the whole picture but it was extremely difficult," says Szamalek. "We were actually very worried that we didn't have enough content. We were seriously concerned there weren't enough quests, enough dialogue sequences, there wasn't enough to keep the player busy. Obviously we were hugely mistaken because the density of the experience is definitely not lacking - but it was so hard to assess it when the game was still being made."

Witcher 3 was a gigantic project, its small writing team charged with creating characters, scenes and an emotional throughline that made sense in a world players were free to explore - and all this was while the studio learned the technical dynamics of constructing explorable environments. Here in this test case, we see the challenges facing all developers of vast open narrative games. It's easy to criticise the day one patch culture of the modern industry, but when you glimpse the process, it becomes more understandable.

"What people outside of the industry don't always appreciate is a game is constructed from so many pieces and you don't see the final product until the very end so it's hard to plan for unforeseen problems," says Szamalek. "When you're working on a play in the theatre, you might not have the costumes or the set, but you can see the actors interpreting the lines, you can imagine what it will look like - in games that's extremely hard. Even if you do have a clear goal and direction, you might end up in a different place because a certain part of the game gets cut or a new mechanic is introduced and this requires you to change the storyline, or it turns out that a tester says the game is lacking this or that."

What Witcher 3 also shows however, is having a pure, simple vision at the heart of the story is a huge help. The process of creating this astonishing game was messy, complicated and terrifying, but beyond the spreadsheets, post-it notes and Google docs, there was something important there.

As Szamalek puts it, "although the story went through many iterations throughout development, the core remained the same: you play as Geralt of Rivia, searching for Ciri, who is running from the Wild Hunt..."