
Hi everyone,
I continued to try to make the navigation work the way I wanted to last week but have not managed to find a proper solution – so I will use the alternative I mentioned last week and have moved on to improving combat calculations.
Combat calculations are currently being run per soldier and every soldier assesses the threat posed by all enemies around him every second. This works fairly well when a single pirate fights against the player, or when a single soldier fights a single pirate – but it starts to run into processing issues when 40 pirates are fighting against 40 soldiers, having to execute 3200 threat calculations each second.
Especially seeing that assessment of threat doesn’t merely look up a value, but assesses whether the soldiers can see each other, hear each other, know of each other’s types, etc., it is easy to see how this can quickly add up to slowing computers down.
At the moment, there are a couple of approaches I am pursuing to improve on this. One of them is to have certain assessments stored for each soldier – so while each soldier has to update their variables (noise, location, etc), they will also be able to tell others whether their situation has changed since the last second. If they have not moved and not made any new noise, other soldiers can simply keep their threat assessment from the last second.
Another possible approach is to collapse processing to the “squad” level. Considering each Barracks can hire up to 8 soldiers who “generally” stay together, a lot of the calculations can be run at the squad level – since everyone is roughly in the same location, if one soldier can hear a pirate, all others should be able to hear them as well. The same of course applies to the larger pirate camps – attacking a pirate camp will rarely result in a single pirate chasing an enemy without the rest of the camp noticing (and honestly, the pirate would probably shout to their friends anyway), so many calculations could be run at the camp level.
There are some tradeoffs to consider here, since this would mean that there might be a little less accuracy in how units respond to certain niche scenarios (e.g. a newly hired soldier walking across the island to get to their unit that is guarding the front lines), but this is meant to be an RTS and not a FP stealth game, I think that erring on the side of larger battles will be safer, and we can assess how players feel about it.
Until next week!
