Originally published at: Exoplanet
Hey friends!
Today we would like to explore another complex topic that significantly enriches the world of Exoplanet — NPC daily routines.
We were inspired to give characters daily activities by Gothic, one of the first games to create a world where many characters have minor daily tasks. These tasks correspond to the roles of NPCs on The Edge — guards secure their locations, patrols monitor the territory, and traders scavenge for scraps. At first glance, it may seem simple, but in reality, there are many nuances in designing daily activities that we will discuss further.
Before realizing the need to develop a separate subsystem to handle NPC daily routines, we used quest logic. However, this approach led to many problems — we had to manually consider whether a character is alive or not, whether they are in combat, or if they have moved to another location to participate in a more important quest.
To avoid numerous errors and unnecessary actions, it was decided to develop daily routines within the framework of our artificial intelligence system — the NPC behavior tree. It is a part of the AI responsible for decision-making. Its logic runs several times per second, constantly determining which branch of actions to execute for the NPCs. Based on the results of the evaluation, requests are generated for them, which are handled by another part of the AI.
What does the use of the behavior tree provide?
- A convenient environment for developing daily routines:
To avoid numerous errors and unnecessary actions, we decided to develop daily routines within our game engine’s editor called «Sahara Engine.» This way, it could have access to all game data, simplifying the control of NPC daily routines. Now, we can quickly, easily, and conveniently set time intervals for specific actions, define their priorities, and determine the rules for execution. Thus, the game checks the in-game time first and then the character starts performing the assigned action accordingly. For example, in the morning, abori can scavenge for scrap, talk during the day, and sleep at night.
- Simplification of NPC state checks:
By having a unified system, checking the state of characters became much easier, and the number of overlooked situations and bugs in the game significantly decreased. It also became much easier to handle situations where NPC activities were interrupted for various reasons — thanks to the new system, the character simply resumes their task from the beginning. Moreover, the performed task is not a repetitive chain of actions — there are specific branches for each time of day. Therefore, even if the routine is interrupted, the immersion in the game remains intact as the character’s behavior always corresponds to the time of day.
- Automatic prioritization:
Regular tasks are automatically assigned the lowest priority. The system first checks various aspects, such as whether the character is alive, engaged in a quest, or involved in a conversation with Jack, and only then sends them to perform the task.
By the way, assigning daily tasks also has its own rules and system. Each character is planned to have 2-4 different actions based on their occupation and habits, corresponding to their profession. Some characters have hobbies — for example, growing plants. The behavior of other characters may hint at their dark past. For instance, the Hermit trembles in sleep, haunted by nightmares of the past.
What types of tasks exist in the game?
Behavior of significant characters:
We wanted to create several distinct characters with complex, diverse, and interesting tasks. Their selection was based on their backstory, characteristics, and the timing of their encounter with Jack. Here are a few interesting examples:
Rusty Nails is the first NPC Jack encounters, marking the beginning of his interaction with the Abori race. Therefore, we added as many details to this character as possible. Rusty scavenges for valuables in the trash, attempts to break open a safe, claiming its mechanism is too complex to crack, and goes to sleep at night.
Garry is the owner of an abandoned mine and a broken hoverbike. He roams around Lucky Hole town, converses with the trader Vaga, and occasionally indulges in drinking and causing a ruckus. Sometimes you need to search around the town to find him. By the way, in the daily routine logic, it is taken into account whether Jack completed the quest «Fixing Garry’s Old Hoverbike». In that case, Garry’s garage will be open, and he will periodically go inside to tinker with the mechanisms.
Mad Miner is one of the most mysterious characters. By his actions you can see, for example, how he threatens old posters of bounty hunters with his fist. A funny fact — to our surprise, the crazy Abori recently started undertaking tasks that nobody assigned to him! He switched from targeting wanted posters to a group of renegade Abori, initially getting himself killed in an attempt to provoke them and then learning to escape. Recently, he started to annoy a nearby grazing cabarog too! We have not yet found the reason for this change, considering it another mystery of K’Tharsis.
Behavior of ordinary NPCs:
Ordinary inhabitants of the world receive simple tasks that correspond to their occupation. However, this guard not only guards the gate but also takes care of watermelons. I wonder what will happen if Jack dares to touch his harvest.
Stranger always performs the same action. After appearing in the game, he can be found sitting near a cliff edge. However, he has a specific goal — why else would he invite Jack to sit with him?
Behavior of animals:
Currently, animals simply wander around their spawn points, but in the future we plan to add more routines to them.
We still have a lot of work ahead of us in assigning routine tasks to characters, and as always, your feedback is crucial. Please share your thoughts on character routines in the comments, and be sure to join our Discord to ask questions, share your impressions, or find out about upcoming updates from the devblog!