
Hi everyone,
Last week, I was able to implement some changes to the soldiers’ behaviour which I want to discuss today.
Before I go into what changed, let me explain what I tried to address - and where that originated: When the player raises a larger army (let’s say about 40 soldiers) and moves this army to attack a large pirate fortress, the outcome tends to be a little chaotic. As soon as the first of the soldiers see the first of the pirates, both sides start running closer to each other. This often means that the last of the soldiers haven't even gotten into range yet when the first are already starting to fight. As both sides are streaming into the fight, units become broken up, and directing the fight (e.g. telling one unit to flank to attack some ranged opponents) becomes very difficult.
The reason for this is probably that there are multiple types of behaviour I have been trying to catch with the same soldier behaviour script. Pirates that are close to a jungle, for example, should behave like they are “guarding” their area. If they see or hear an opponent, they should go after them until the opponent has been out of sight for too long or they are engaging them. If a soldier has been tasked with running across the island to a new location, or has been left to guard a specific spot, they should behave similarly aggressively, defending themselves from any opponent they can perceive. However, this behaviour stands out in a battle closely observed by the commander. When units act independently and aggressively, they become unmanageable and the fight devolves into a brawl, rather than reflecting a more militarily organised battle.
Having seen this as a problem, I have been wondering about solutions for a while. Two new behaviours I have implemented are the “non-attack” move - if a commander double clicks with soldiers selected, they will now ignore all opponents until they have reached this location (the waypoint also turns yellowish/green to indicate this, as seen in today’s image). This can help in particularly tense battles, when the commander really wants some units to flank some ranged opponents, as the soldiers will now be completely single minded until they are right next to their target.
The other new behaviour is the “defence only” mode for soldiers. In this mode, ranged soldiers with ammo will only engage opponents when they are within their 60 metre shooting range (but they will report on enemies they see up to 100 metres), while ranged soldiers with no ammo and melee soldiers will only engage opponents when they get within 5 metres. This mode can help keep a reign especially on ranged units, and using both of these together already feels like you are controlling a much more disciplined army.
There are two remaining questions at this point which I need to figure out next week. The first is whether to let the player set the range at which melee units engage their opponents (e.g. 60 metres so they don't simply idle while being shot at by ranged opponents), and the second being whether to let players choose between attack and defence modes freely, or whether to link them, e.g. to proximity from the player (so the units behave aggressively halfway across the map, but are more controllable closer to the player).
Until next week!
