DevBlog #33: NPC Action Chains

July 20th, 2017

Acting NPC

Alex

Survival and sandbox games normally use reactive AI for autonome npcs, so they can just be placed anywhere in the world and adapt to changes if needed and make decisions based on their situation and desire. In RPGs on the other side their behavior is highly scripted, they follow the instructions the game designer gave them to create specific scenarios and tell a story. In this case the npcs are very restricted in thier decision making.

Valnir Rok combines both genres, so the AI should support both approches. For the survival aspect I decided to use a scored-based AI which scores all available actions for their usebility in a specific situation and picks the one with the highest score. This system works great for wildlife npcs and can be easily extended and tweaked if needed, but only on an abstract level. In some cases we need a scripted behavior, just like during quest to make them walk to a specific location and play some animations for example. In order to bridge the gap I’ve implemented so called ‘action-chains’, which are basically series of actions the npc will execute in a given order. The Ai handles a action-chain just like a normal action and scores its usability which is high if the npc has nothing else to do and is low if the npc is in danger for example. The acions inside the chains can be for example simple movement to waypoints and playing animations to create a routine for human characters just like picking up a hammer at a workbench, forge a sword and go to a tavern for some mead afterwards.