How Warhammer 40k Space Marine 2 Rewards Aggression, and Punishes Heresy
One must give their all in service of the emperor!
AI and Games is made possible thanks to our paying supporters on Substack . Support the show to have your name in video credits, contribute to future episode topics, watch content in early access, and receive exclusive supporters-only content on Substack.
If you'd like to work with us on your own games projects, please check out our consulting services provided at AI and Games. To sponsor our content, please visit our dedicated sponsorship page.
Welcome once again to
as we enter the 42nd millennium! In this case study we learn how the enemy AI of Warhammer 40,000 Space Marine 2 is designed both to enable the power fantasy of playing as a member of the Ultramarines, and how heresy is punished by ensuring those that do not commit their all to the Indomitus Crusade, will most assuredly be wiped out.Follow AI and Games on: BlueSky | YouTube | LinkedIn | TikTok | Twitter | Threads
About the Game
Developed by Saber Interactive and released in 2024, Warhammer 40,000: Space Marine II sees the return of Demetrius Titus, after a century of imprisonment, torture, and later self-imposed penance as a member of the Deathwatch. Returning to active duty as a member of the Ultramarines 2nd company, Titus acts to stop the Recidious System from being lost in the broader battlefield of the 4th Tyrannic War.
As Titus or as other members of the company in either the Campaign or Operations in single or multi-player, you fight against the enemies of the imperium across various battlegrounds. Your initial deployment takes you to the jungle planet of Kadaku, where seemingly endless hordes of Tyranids wash over the landscape. What may seem unstoppable, as they lay waste to all that stands before them, merely waits to be crushed under your armoured heel. Space Marine 2 revels in the chaos of having players face off against vast number of enemy characters at once, with a variety of smaller enemies taking up the bulk of the invasion fleet, while larger and more aggressive enemies will beat down on the player in both ranged and hand-to-hand combat.
Saber’s latest entry in the series builds on the core gameplay established by the previous entry developed by Relic Entertainment and released back in 2011. Gameplay is balanced across both close-quarters combat, with light and heavy attacks, dodging, parrying and more, alongside the ranged combat of using a variety of weapons to eliminate enemies from afar.
As detailed by Vladislav Ianstevich in an AI post-mortem of the game, it was explained that for the development team, the driving philosophy was to achieve what was referred to as Power-Through Combat. It's a design philosophy, that aims to have players want to push towards the enemy. To dive head first into the fray, hold their ground, and survive each encounter. By allowing the player to restore armour through use of finishing moves, but use of parries to dictate the flow of combat, it reinforces not just the power fantasy of being a super soldier on the battlefield, but it also adds what Saber refer to as the competence fantasy. In that the better you are at the game, and the more deftly you can fight off even the most elite enemies, it reinforces the experience as players become seemingly unstoppable on even higher difficulties. This is a design philosophy we've seen in other games, notably here on AI and Games with the likes of the 2016 reboot of DOOM, where the ‘push forward combat’ philosophy is built to encourage players to get in close, and rip and tear as much as possible.
To do this the design team worked on a design framework, where they sought for enemies to be able to influence how and when the player switches from ranged to melee and back in the heat of the moment. Specific enemy archetypes should force the player to switch playstyle, and make interesting decisions emerge throughout play so every encounter keeps you on your toes. But, when building a system like this there's a delicate balance needed to ensuring this feels entertaining without it becoming overwhelming, or overtly scripted. So let's take a look at how it all comes together.
Enemy AI Architecture
The underlying architecture of Space Marine 2's AI systems is built on many a tool we've seen before on AI and Games, but it builds on existing ideas in ways that are quite interesting. So first I'll give a brief overview of the tools employed, and where we have seen them before, and then we dig into some of the more technical aspects of it all.
First things first, the core decision making system of the enemies in Space Marine 2 is Behaviour Trees. A common means through which to design and build behaviours for action games, and we've seen it explored on this channel in everything from Halo 2 to Alien: Isolation, The Division and many more. The Behaviour Tree how enemies act, and the system will trigger specific behaviours in certain contexts, which I'll explain in a second.
Secondly, the game uses a Utility AI system. As discussed in our AI 101 on the topic, Utility is a process whereby we determine the viability or importance of some aspect of the AI's decision making. This could be a single action, an entire behaviour, a goal it tries to accomplish, or even objects in the world. We've seen Utility adopted in various ways on this channel over the years: F.E.A.R. scores the value of a goal using utility, meanwhile the multiplayer bots in Halo: Infinite assess the importance of a behaviour with utility.
To handle the attacks of multiple xenos at once, the game relies on an ‘Attack Token’ system: a process where you manage which enemies can attack, and at what time, by having enemy AI request to attack the player. We've seen this in several games on the channel over the years, though two prime examples are the 2016 reboot of DOOM where demons frequently steal tokens from one another when the larger archetypes seek to attack, as well as Marvel's Spider-Man by Insomniac, where it has to balance between on and off-screen attacks by both melee and ranged enemy types.
And then on top of the underlying attack system, the game has an Engagement Sub-System that watches all player activity and then decides which marines should be the active targets. This is derived from the idea of a Director AI first seen in Left 4 Dead, in which enemies prioritise specific characters based on whether they are respecting the designers underlying intent.
So these are the four key pillars of the AI systems in Space Marine 2. But each is doing something a little different from what we've seen before. Now let's dig into the details and find out what exactly is going on.
Reactions & Opportunities
The enemies in Space Marine 2 are deliberately designed to avoid being overtly-strategic. Enemies don't plan on long-term strategy to push the player into specific scenarios. As was discussed in Ianstevich's talk, this would make little sense when you consider how anarchic a lot of the combat is throughout the game. So instead the enemies are built to have two key behaviour types:
Reactive Behaviour: Which as the name implies means they simply respond to what's happening in the moment.
Opportunistic Behaviour: Where an enemy will try and use a basic behaviour with the specific aim to force a specific reaction out of the player.
To pull this off, the AI team developed a modified form of Behaviour Tree, a Reactive Behaviour Tree. In which the idea is to allow for characters to always be able to quickly react to what's happening in the game at any point in time. One of the big innovations was the use of Active Selector nodes in the tree. A regular selector selects one of the several children it has to activate. To do that, it checks whether each child action can activate from left to right, and if one of them can be executed, and it succeeds, then the selector has ultimately achieved its job.
But this doesn't allow for enemies to react to change in the game quickly, given the selector is just trying to find any action in that part of the tree it can complete. Long-term viewers of the channel will recall that one of the big innovations when Bungie designed Behaviour Trees in Halo 2, was the use of what were referred to as 'stimulus behaviours' This would force an override in the behaviour tree and make it restart execution from the root if something had changed - a notable example being when an elite is killed in front of the grunts under its command.
Space Marine 2's Active Selector nodes are an alternative approach to enabling for fast reactions. Instead of the Selector only considering each action in turn and then evaluating whether it's possible, when it's executing a particular branch it's still evaluating every behaviour to the left of it. Actions are structured in each selector so that the right-most behaviours are basic attacks that could prove opportunistic, while the actions to the left are all reactive. This means that whenever any AI is attempting more opportunistic attacks or actions, it can attempt to override it using a reaction (because it's always evaluating every branch to the left of the current one in the selector. How does it evaluate them? Well with utility equations of course.
The actual behaviour architecture of all enemies is broken down into four layers, each handling a specific part of their behaviour:
Combat/Idle: the highest level of behaviour. Figuring out whether to initiate combat or simple run one of the ideal behaviours.
Reaction/Combat Loop: Where the active selectors handle the reactive and some opportunistic behaviour when in the thick of it.
Attacks/Movement: Handling more opportunistic behaviour, and moving into position to enable for direct confrontation with the player.
Approach/Standby: Where the fight is underway, but the encounter system won't let them engage with the player at this time (no doubt because they have plenty going on as it is).
And so speaking of the encounter system, let's take a look at that too.
Imperial Aggro
When building action combat games, it's important that the gameplay feel somewhat balanced. If it's too overwhelming, then that's just not any fun. As mentioned earlier, the key to Space Marine 2 is fulfils the power fantasy of being an ultramarine, alongside the competence fantasy of being highly skilled and overcoming that which descends upon you. But on the other end, if it's not intense enough, then the game will feel empty, lifeless, and far less engaging. So we need to maintain systems that will ensure not only that players feel the heat when required, but also that when they're in combat, it still feels like a fair fight.
Combat encounters in Space Marine 2 rely on the underlying Engagement Sub-System to decide a number of key elements:
Identifying which xenos should be passive - evaluating which marine to attack - as well as reactive, where they will target a specific character based on the current context of the game.
Handling the distribution of smaller xenos that swarm players.
Re-calculating the accuracy of ranged attacks based on what's happening in the moment.
And critically, it supports the Power-Through Combat philosophy by making enemies less effective if the player is more aggressive, but also make them all the more punishing if the player is not engaging in combat.
This is handled for a variety of different circumstances, but critically it has to balance between the combat in the campaign and the enemy waves that hit players during the encounter missions. The campaign encounters are all crafted manually, while the skirmishes in the encounter missions are procedurally generated. So the system has to handle for both sets of scenarios.
To decide on which ultramarine should be attacked, the engagement system operates much like Left 4 Dead, where it's assessing each ultramarine to determine which one should be attacked and who is the current priority. The game monitors how many xenos are attacking each marine, and tries to distribute them somewhat evenly, though it will bias towards human players where necessary. But this is just the passive enemy selection, it is also reacting to what players are doing, and it does this in two key ways:
The first is by maintaining a short-term memory of events that occur on the battlefield. This helps when multiple players are attacking the same larger enemy. If for example one of them is trying to flee or taking damage, while the other is damaging the xeno, then it will reprioritise and shift targets.
The second, is that the game also pays attention to whether or not a player is actively in combat. So if you're being a coward, and letting your NPC allies take all the heat, then the you're more likely to have a swarm of xenos turn to target you, but also you're more likely to have a dangerous attack trigger from off-screen, which will require either a parry, or a dodge.
Speaking of attacks, as mentioned the game relies on a token system like we've seen in DOOM, where a limited number of tokens are available for a given encounter. Each token is given to an NPC to attack the player, and is relinquished once the attack is complete, or if another condition results in the enemy losing the token - like being killed, or more importantly, if it's stolen by a larger, high priority enemy. This happens a lot with special enemy archetypes, as well as bosses. There are also unique distribution rules for tokens that vary depending on the game mode, but also based on the current state of the game.
This is what makes this attack system stand out from these other systems. Much like Spider-Man, attack distribution is reduced if the player is in the thick of it. By attacking enemies, parrying attacks, perfectly dodging dangerous attacks, or executing an enemy, it forces the game to slow down the rate of attack selection. This circles back to the Power-Through Combat idea, meaning that players are rewarded for sticking it out, and giving their all in the name of the emperor.
But also, the distribution rules change in other circumstances. For one, anytime the player is knocked back by a big attack from one of the larger xenos, or they trigger a gunshot, this forces a cooldown and delay. A deliberate response to give you a second to breathe either because you're getting your ass kicked, or you are kicking ass. But the game also has unique rulesets for when it observes the player appears highly skilled, frequently parrying or dodging attacks, as well as when players are distributing large amounts of image. It will then crank things up to suit.
The one part of this system that stands out as unique is the separate token system used by the smaller enemies. As you'll have seen throughout this video, attacks are often triggered by literal waves of smaller xenos attempting to overwhelm the player. The attack system has a set of custom rules just for these smaller enemies, and critically it pays attention to whether the player is prioritising them or not. Should you ignore them and prioritise the larger enemies, then over time their attack rate will increase. Forcing you deal with them. Their attack rate will slowly ramp up in the encounter, but knocking them back, or of course, just killing them, slows the rate of increase.
Closing
Warhammer 40,000 Space Marine 2 is a great example of how to build upon core design pillars to enable for a frenetic combat experience, all the while ensuring its balanced sufficiently to enable players to still progress. The game is no cake walk by any stretch, with even the lower difficulties proving a real challenge for aspiring ultramarines. But for those who give their all in service of the emperor, they'll find their groove and overcome everything that comes their way. After all, the game is literally built to make that fantasy a reality.
Thanks for reading this case study on
all about Warhammer 40,000: Space Marine 2. I was excited to bring this topic to you for a couple of reasons. I mean of course, Space Marine 2 was one of the most beloved games of 2024; being nominated for several game of the year awards in the process, and it's arguably the definitive rendition of everyone's favourite British space fascists in gaming. But more importantly for us, it marks the very first time we’re basing an article on a talk delivered at our very own AI and Games Conference.In November of 2024 we hosted our first ever event dedicated to bringing together the game AI community, and this was in fact where Vladislav Ianstevich delivered the AI post-mortem. Sadly he couldn't be with us in London to deliver the talk personally, but it was very well received by our attendees. When you consider that AI and Games started out by re-purposing talks and development materials from across the games industry to make them more palatable to a general audience, the fact we've now gone full circle, and made an episode from an event that we hosted and organised. Well, that's something pretty special right there.
If you'd like to see the talk yourself, check it out above, or head on over to the AI and Games Conference YouTube channel at the link on-screen and in the description. It goes into even more detail than this video - so consider this episode an onboarding to Vladislav's full presentation. The AI and Games Conference YouTube channel is the home of all recordings from talks hosted at our event. Be sure to subscribe as we continue to roll out new content throughout 2025 and beyond!
References
Space Marine 2: The AI Post-Mortem, Vladislav Ianstevich, AI and Games Conference 2024