
Hi everyone,
My work last week was mostly spent on combat calculation optimisation, but while a lot of that was technical, there are still quite a few things to talk about.
Let me start as I have a few times before, but mentioning that when we started to make this game, we essentially wanted to make an RTS game that was controlled from the ground - thoughts on the FP view side of things were very limited. In early versions of the game, the commander could neither shoot nor cut down trees - and it took us a little while until we realised that in order to have the first person view be a satisfying experience, we needed to give the commander options that any player would expect from a FP game.
With that in mind, a lot of what we do needs to be balanced between making the game a satisfying RTS game, and making the game a satisfying FPS game. With combat in particular, this is not an easy line to draw. While the public version of the game still has only the very simply musketeers, the internal version of the game has had more complex AI for a while. Pirates and Soldiers weren’t directly aware of enemies that were close-by in the jungle, for example. There are noise and stealth variables, consideration of distance and obstacles between the units, and when a Pirate finally noticed a noise, he would go to investigate whether it was a soldier, villager, or if it must have been the wind - acting differently according to what he did or did not find.
It was easy to get carried away building this system when I was primarily testing its feel by running into the jungle to see how pirates would react to me - and whenever something didn't quite make sense to simply add another more complex behaviour to make up for it. But this behaviour was of course more fitting for a first person RPG or a stealth game than it may have been for ours - and came with a heavy processing cost. While having it may have been enjoyable when playing as a sole commander exploring the jungle, it did not even give much benefit to bringing soldiers along (who are terrible at stealth to begin with), or when going into big battles - leading to hundreds of thousands of calculations about each enemy soldier’s stealth and noise level when battling them in open sight on a plain.
As a result, my optimisation efforts made me revisit what we actually wanted from the soldier behaviour. It was never the plan for a commander to sneak around the island on their own - a good commander should bring an adequate escort - and if a commander did end up investigating something by themselves, a single pirate or two should pose a challenge.
What we did want, however, was to create straightforward and predictable combat between large-ish armies, where a commander would be able to redirect a squad in the middle of battle in order to flank an opponent or to retreat with fewer losses. Something that requires an easy understanding of how soldiers will see and engage opponents.
With all of that in mind, I massively simplified the system with which soldiers now engage their enemies. Rather than assessing each opponent’s threat level and attacking the highest one, soldiers now simply engage the closest opponent they can see. If they can’t see a closeby opponent, they end up searching for the closest one they can hear. This is much easier to understand in the heat of battle than wondering why one of your soldiers has decided to run behind a rock to pursue one particular opponent (who he was particularly worried about), rather than engaging a clearly visible opponent slightly further away.
I only just finished rewriting this system, and while the performance has already improved (a 40 against 40 fight won't have a constant 3200 assessments per second, but will ideally only go through 80 assessments most seconds), I haven’t been able to test too extensively yet - so more on this next week.
Until next week!
