Skip to main content

How Company of Heroes made a destructible battlefield

This game blew up

This is The Mechanic, where Alex Wiltshire invites developers to discuss the inner workings of their games. This time, Company of Heroes [official site].

The Tiger tanks come rolling in, the artillery comes thundering down. Walls are blown wide open, buildings collapse on themselves. In Company of Heroes, the battlefield is ever-changing, munitions cutting into the map new opportunities for flanking and to be flanked. Confident pushes turn to disaster as the enemy punches through rear guards, and last-ditch defences are saved as the cavalry smashes through barricades. Company of Heroes is a deeply dynamic RTS, something that’s all down to:

THE MECHANIC: Destructible environments

Most of the features on a Company of Heroes map can be destroyed: fences, walls, buildings, the ground itself. Destruction provides a great deal of its real-time strategy and also the game’s whole identity, which evokes the WWII we know from the photographs, films and stories that memorialise the fierce fighting that swept through northern France, leaving hedgerows and fields, farms and towns in ruins.

And let’s be honest, it’s also a thrill to see your actions written into the world. Shellholes and breaches are a record of the skirmishes and pitched battles you’ve fought. Though Company of Heroes was released 11 years ago, it’s still a novelty to see a game world respond so expansively to your decisions.

It all comes from a simple idea: giving soldiers cover. “We were looking at the original vision and source material and cover was obviously critical to the experience of soldiers on the frontline,” Quinn Duffy, who was senior designer on the game, tells me. The first prototypes featured basic all-around cover, and Relic noted the way it encouraged players to preserve their troops. And then the team switched from using the old engine it had used to make Impossible Creatures to a new one, called Essence, and with it came cover that was directional.

“That was the big defining change in terms of environments in the game,” says Duffy. Now units would only be covered from one side, creating opportunities for them to be flanked or approached from the rear. Relic then wanted the cover to be destructible, with weapons impacting on it: machine guns tearing through fences, grenades blowing walls down.

The result was a relationship that defined the ambitions Duffy and his team had for their game. “We wanted to create movement and fluidity and adaptability in the world. To force troops to move and for players to move them around, seeking better cover.”

But in making an actual game out of this relationship, Relic encountered all manner of knock-on effects which ended up pulling in the creative skills of the entire studio to solve them. “We had to be really aware that by deciding to destroy the environment we were signing up for emergent gameplay in every system, not just a few,” senior artist Alun Bjorksten tells me.

Some effects were practical. If guns are firing on cover, then the player needed to see the bullets impact on it to understand what’s happening. So Relic had to create little visual features to support that, including extra effects, such as the machine gun tracking its bullets across ground and up to the cover to give players awareness, as well as a sense of drama.

And say you’ve got a squad of riflemen behind a fence that’s under fire from a machine gun. When the fence falls apart, the riflemen needed to be able to automatically shift to find the next cover so they had a sense of life, so a kind of self-preservation system had to be built to manage that.

And then there’s pathfinding. In the first Company of Heroes, soldiers can’t cross fences and walls, so once vehicles and explosions start breaking them up, troops’ access to different parts of the map completely change.

“It made the map design interesting,” says Duffy. “If you put a fence in you needed to know the pathfinding distance it would add, and you needed to ensure it wasn’t going to block troops.” Map design was an exercise in breaking the game into phases for when during the battle certain weapons and vehicles with the power to destroy objects would appear, and accounting in the environment for their effects on changing the pathfinding.

Sometimes destruction would remove access to areas, such as when buildings are reduced to impassible rubble. Bjorksten remembers when the team made it possible to destroy bridges, but before it was possible to repair them. “We were like, we’re going to destroy the bridge! And then you realised you couldn’t progress any more. So we needed to repair as well as destroy, and then to destroy the repair. You could easily invalidate the gameplay.”

Philosophical decisions had to be made, too. If a wall falls down and the AI isn’t there to see it, does it know about it? Relic decided it had to.

This creative choice is what’s behind those times when you see AI begin magically pouring through a new gap in defences. “There’s a desire to make them only aware of what they can see, but it’s not always realistic in terms of the knock-on behaviours,” says Duffy. Without this supernatural awareness, the AI could get stuck because it doesn’t have long-range knowledge about the world to be able to find its way to where it wants to go.

Players can also put down barriers, like barbed wire and sandbags, further tweaking the way units can access different areas of the maps. And in these being destructible came another issue, as Duffy explains: “You put a nice sandbag emplacement overlooking a road and set your machine gun up, all super cool and tactical, and then your first vehicle comes and drives right through the middle of it.”

“The Tiger tank has this ability called ‘heavy crush’, which can crush objects that other vehicles can’t,” says Bjorksten. “Once it’s on the map then all bets are off because this thing could go through all kinds of things you’d set up neatly as chokepoints.”

Destroying your own defences is a long-standing frustration in Company of Heroes, but like the prescient AI, it’s a result of accounting for wider problems. First, Relic needed to avoid players being able to accidentally block in their own vehicles with their defences. Relic also knew the appeal of that same vehicle crushing the enemy’s defences. And then there was the way pathfinding works. The game has a grid of the world that records in every location what objects units can pass through it. When somewhere is marked passable to a heavy crush vehicle, as far it’s concerned it’s just open ground, blind to what’s actually there. Unfortunately that means it’s also blind to your own defences.

“I think game design and development is months and years of constant little compromises and weighing pros and cons, and that’s the daily occurrence,” says Duffy. “There was a lot of debate about this and how much we tried to preserve elements of the maps so the early infantry cover combat was maintained while also being able to have vehicles rampage around and not get stuck on objects or do slow turns around things and get killed. When the maps were really populated with crushable stuff, vehicles became tough to use because they had slow turn rates and they’d expose their weak armour. Those frustrations aren’t worth the trade-offs.”

Not all the ramifications of making things destructible were problems. They also led to design opportunities. For instance, if you have cover, you can start to design weapons that are effective against it, like the grenade. And if you have buildings, soldiers should be able to go inside. And if they’re inside, they should be able to shoot out of it. “So they should poke holes in buildings and use them,” says Duffy. “Alun spent like a year making buildings work.”

Every asset needed a set of destruction states and physics objects attached to them to represent damage. They also needed to have rules attached to them to represent whether they’d block pathfinding or provide cover or other things. “We probably tripled the cost of making the game because of this!” says Bjorksten. But buildings were a special case. Relic wanted them to look like the ones you see in period photos, where every window is different, where rooflines don’t meet up and nothing’s symmetrical, and where damage varies enormously.

“We knew we couldn’t just create a set of pre-damaged buildings, because you’d see the repeats of the same building over and over again, so out of this was born an epic system for designing these systems in what we called panels.” Every building was divided into 10ft by 10ft pieces, and then written into the rendering code were ways to punch holes or collapse them. Two people worked on this system for two years, almost full-time, creating the art and figuring how the the texture memory available to PCs at the time could hold it all.

“There are 230 different damaged states that you can put a building into,” Bjorksten says. That’s 1,073,741,824. “It’s quite the system.”

And along with their appearance, buildings had an impact on the game itself. Weapons had different effects on them, including the number of panels they’d damage and its extent. They’d have sight-blocking and shot-blocking properties, too. (The team had to also account for stats and random values occasionally leading to cases such as V1 rockets impacting on a building and doing no damage.)

“I don’t know if many teams have attempted that. Probably with good reason,” says Duffy.

I wonder if Relic ever found the scale of what Company of Heroes became daunting, but Duffy shrugs. “No more daunting than just building a big-ass game is daunting.” Perhaps that’s just with the benefit of knowing how well it turned out to work.

If you’re in the mood for more COH history, check Fraser’s excellent making of feature from last year.

Read this next