Colonists are fickle creatures. You must take good care of them or they’ll starve to death. Or join a cult and start murdering for Quag’garoth (as one typically does when left without supervision).
What I’m getting at is that we’ve got quite a challenge in making colonists act like little virtual people. Part of how colonists end up acting is up to how the player manages then, as it should be in this business of interactive media. But the larger part of the iceberg (to our perspective) is making this possible to say nothing of engaging in the first place, and that’s up to how we hook up the pipes behind the scenes to enable colonists to express varied, interesting behaviour based on stimuli which can be observed and often manipulated by the player.
A sprawling example I’ve been dealing with lately is how to make colonists respond to danger. Fight or flight, easy, right? Well …
If the answer is “fight”, how long do you fight before flight starts looking like a good idea? We don’t want everyone to fight to the death like a classical RTS meatgrinder. We do expect trained soldiers to fight more diligently than militia, and we expect very little from civilians, though one with the proper personality should indeed fight back if threatened and, in extreme cases, certain traits and emotions may cause a particular colonist to make a last stand.
In the latest update we switched away from a system in which a melee attacker would, in code, essentially turn off the attack target’s brain and run attack/counterattack queries through the attacker. Now we’ve switched to a system in which it’s up the the target of the attack whether to, at any time, make a melee attack. It’s good not to turn off people’s brains, and this avoids a lot of messy scripting errors, but the whole melee attack/counter-attack system needs to be rebalanced. We can’t just say “50% chance of counterattack” now; instead, we have to ask “what variables would make this character fight back? What traits, what state of mind, what level of injury lie between the decision to fight and to flee?
And then, if a colonist chooses flight, where do they flee to? If they flee entirely randomly, then they may well run right back into the attacker (this used to happen). If they only flee directly away from the attack, then we have colonists running off into the woods being chased by fishpeople, away from any hope of assistance and to inevitable death (this happens now). So, clearly, we need to introduce a little more sophistication here.
(Tangent: I will note for the record that the fact that everything else works well enough that we’re tackling the details of how people run away from enemies is a good thing. Once systems start to work fairly smoothly, we can focus on cleaning up unwanted outlier or aberrant behaviours.)
To provide an example of the gameplay logic going on here, I’ll break down what makes civilian colonists choose to fight back against an enemy in melee combat.
Melee counterattack absolutely requires:
- a target enemy within one tile
- not being a soldier or militia (they have a unique job definition with values balanced for the military).
Given those conditions, the subjective importance of engaging in a melee counterattack is affected by:
- how many afflictions (permanent injuries with particular effects) do I have?
- how healthy am I?
- what’s my morale level? (a stat derived from a characters levels of Shock, Fear, and Sadness)
- how mad am I? (In the sense of insanity; this is working with the assumption that CE’s concept of madness is associated with lack of interest in self-preservation)
- how angry am I? (An especially angry person is more likely to fight)
- is the enemy running away? (Currently this makes melee attacking more likely, though I may reverse this – why fight an enemy that’s running? A vengeful or brutal person might attack a fleeing enemy, and that is covered by traits.)
- do I have various traits, including: “Foolishly Brave”, “Of Criminal Element” (assumed to be more interested in brawling), “Brutish”, “Military Training” (it’s possible to have military training but not be an active soldier)
If the above values exceed the value of running away, then our colonist will fight in melee combat. Most civilians will choose to run rather than fight, though we’re encountering cases where colonists are chased across the map and killed by ‘a thousand feeble fishperson punches’ when said colonist could probably very well take out the fishperson if they turned around and fought back, so this will likely see some re-adjustment.
(Edit: I just realized I should increase the utility of counterattack if a person is holding a tool with the tag “makeshift_melee_weapon”. Neat! And now done.)
As discussed, running directly away from an enemy is better than running in a completely random direction, but could be better still because we’re seeing colonist behaviour that’s frustrating players. So we talked a bit on the question of different types of running away, different goals that may be sought, and what might affect these. So how about we use these:
- Flee to civilization (Aka the “center of town” where, one hopes, safety can be found. This is often not the case but it would be a good idea to at least try to head toward town if you’re a colonist out in the middle of the woods and have run into trouble.)
- Flee toward a soldier (Presumably for protection; may want to make sure the soldier isn’t fleeing as well. Or maybe it’s still valid?)
- If you’re a soldier, flee to rally point, if any (That’s sort of what it’s for, right? To rally! To expand on this point it’d probably be worthwhile to make some morale-boosting effect when near an officer and rally point so that these would function as actual rally points.)
- Just run away from danger! (Our current job, and a good fallback behaviour. Perhaps being really upset/injured will override the specific fleeing goals outlined above.)
- Fight to the death! (Not really fleeing, but it’s a valid subset of these choices. Certain personality traits could cause a character to conclude that fleeing isn’t desirable and they ought to just fight it out. Edit: And Daniel has pointed out to me that this choice is just the natural conclusion of the utility for “fight” always being greater than “flee”, so it doesn’t have to be a discrete subsection of fleeing. … the system works!)
Over to you: Can you think of any more types of running away?
(I know a certain clever modder who keeps doing a great job of rebalancing our combat system for us made a “Flee Indoors” job, but I don’t want to mess with that until we give enemies some kind of ability to break down doors.)
… And that’s just one subset of character behaviour. Similar thought needs to go into just about everything that people can get to. Herding colonists, I tell you.