12-08-2024
Task System
An overview of the task system and how it drives villager behavior in Highland Hearth.
A village simulation is only as good as the villagers that inhabit it.
For Highland Hearth, I didn't want villagers to simply stand around waiting for player input. I wanted them to feel like active members of a growing settlement, capable of gathering resources, constructing buildings, transporting goods, and contributing to the success of the clan.
Creating the task system was one of the first major steps towards making the world feel alive.
From Player Commands to Villager Actions
At first glance, chopping down a tree seems like a simple action.
The player clicks a tree and a villager walks over to cut it down.
In reality, even a basic task involves multiple steps.
The villager needs to find a valid route, walk to the tree, perform the chopping animation, collect the resulting resources, locate an appropriate storage location, carry the materials there, and finally return to looking for new work.
Breaking larger jobs into smaller actions became the foundation of the task system.
Tasks and Commands
Rather than building individual logic for every possible activity, I designed the system around tasks and commands.
A task represents a goal, such as chopping a tree, gathering berries, hauling resources, or constructing a building.
Each task is then broken into a sequence of smaller commands that the villager performs one at a time.
For example, a simple tree-chopping task might involve walking to the tree, chopping it down, collecting the logs, carrying them to storage, and finally depositing them before moving on to the next job.
Once all commands are completed, the task is considered finished.
This approach keeps the system flexible and makes it easier to create new types of work without rewriting large amounts of code.
Early Resource Gathering
The first tasks I implemented were focused on resource collection.
Villagers could gather grass, harvest bushes, chop down trees, and transport the resulting materials back to storage.
Although simple, these tasks represented a major milestone for the project.
For the first time, villagers could meaningfully interact with the world rather than simply moving around it.
Creating a Living Settlement
What makes village simulations interesting is the chain reaction that emerges from simple actions.
A tree is chopped down. The logs are transported to storage. Those logs can later be used to construct a building. That building allows the settlement to grow.
Each individual task may be simple, but together they form the foundation of the entire simulation.
The task system became the link connecting villagers, resources, construction, and progression.
Pathfinding and Navigation
Of course, none of this works if villagers cannot find their way around the world.
Every task relies on reliable navigation, whether a villager is travelling to a forest, delivering resources to a stockpile, or helping construct a building on the opposite side of the settlement.
As the game grew, the navigation system evolved alongside the task system, ensuring villagers could efficiently move around increasingly complex settlements.
This became especially important once larger maps, buildings, fences, and other obstacles were introduced.
Scaling Up
One of the biggest advantages of the task-based approach is scalability.
Once the foundation was in place, adding new activities became significantly easier.
The same system that handles chopping trees can also be used for farming, fishing, mining, construction, crafting, hauling, and many other jobs planned for Highland Hearth.
Rather than building dozens of completely separate systems, villagers can use the same underlying framework to perform a wide variety of work.
Looking Back
The task system was one of the moments where Highland Hearth began to feel less like a collection of individual features and more like a living simulation.
Watching villagers gather resources, transport goods, and contribute to the settlement gave the world a sense of purpose that wasn't present before.
Many parts of the system have changed since these early versions, and it continues to evolve as development progresses. However, the core idea remains the same:
Give villagers meaningful work to do, and let their actions tell the story of the settlement.