Job System - IsaacMulcahy/RPG-AI-SYSTEM-WIKI Wiki


The Job System is an adaptable system which allows for visual scripting of AI behavior tailored towards presenting real world day-to-day tasks simply.

How to Create

Creation is done using the Flowchart Editor which is a visual node based system of creating the data required. This can then be imported in by using the Manager.



The overall name of the occupation the NPC can do. It contains the start and end time of the Job as well as whether the NPC character uses the global pool


A high-level concept of what a Job requires the NPC to do made up of Tasks


A goal oriented part of a Duty which is used to define more complex behavior


A way of achieving a goal, having more than one of these allow for different ways of achieving the same results. This level allows for added robustness in the system.


A predefined explicit set of functions that make the NPC perform actions in the scene (e.g., find something, go somewhere, pick up Item etc)

How these are applied

The Job is applied on creation of the NPC and this does not change.

Then a Duty which requirements are met (each is checked from 0 up) is then set. After that the same approach is used for setting the Task, Method and Action. When an Action is successful then the Action Requirement is applied (wait time and animation). After the Action Requirement is done the next Action is selected and this continues like so until all are completed and then the next Task is started (Method is skipped as each Method for a Task should fulfill the same goal) with the action to perform being reset to 0 . The same takes place with Duties. If all Duties are done then the process starts again from 0.

However on a Action failing this will cause the Method to fail too. When this happens the next Method will be attempted and the NPC will keep trying until either a Method is successful or all Methods fail. When all Methods then the remaining Tasks for this Duty will be skipped and the next Duty will be attempted.

When are Requirements Applied

Requirements for the middle three layers (Duty, Task and Method) are only applied on entering of that node. This means if a Duty can only be performed before '1700' and the Duty was started before that time but still has Tasks left after that time then the remaining Tasks will be completed.

With Action the Requirements are performed after the Action has been successful and holds the return to the Work Controller off from being successful until it has been completed.

Predefined Actions


Predefined actions also refereed to as actions are functions which define how the interaction takes place within the Scene. They return a nullable boolean value to show the three possible states they can be in; successfully completed, still taking place and failed. This is then used by the Work Controller to select the next behavior.

List of Predefined Actions

  • IDLE

Locating logic

The location logic is mostly the same for all three functions but has some differences. The main method in which they work is they try to find Item's within '25' (default, can be changed in Actions, if owned it only uses the list of the workplaces and doesn't care about distance) of the NPC location of the specific type. The list is then used to figure out which one the NPC should head to dependent on the function, if it is not specified in the name then it'll be the closest that is used. With Zones it is the closest to the AI which is within the Zone.

Pick Up & Drop Off

This allows for the NPC to pick up, carry objects objects around and place down elsewhere. This works by looking for the closest not InUse item which is within '5' (can be changed in actions). It is then made a child of the GameObject which is either the object which has been assigned to the right or left hand (Set in the AI Databoard) and gravity is turned off. The small distance means it is recommend to use a 'LOCATE' action before doing calling the 'PICK UP'. On 'Drop off' the item parent is set to null and gravity is turned on.

Mount Actions

The mount actions allow for the NPC's to be able to use different means of transportation. It works by using the generic Mount class which defines where the NPC's use the Mount from. The first one added is the one in charge of controlling the Mount. It also contains how many are using it currently and the maximum amount.

Mount works by checking if the NPC is within '5' and if so it'll make sure the Mount is not full. If it isn't full then the NPC is teleported to an unused control point. The Mount boolean for being controlled is set to true and a reference is added to the mount for the current NPC

Waiting works by not completing the Action until the mount return true from the 'IsFull' check

Dismount works by cleaning up the Mount (remove the user reference) and cleaning the NPC databoard up by setting back the local settings mounted and inControlOfMount

What happens on failures

Images are included to try improve readability, green are successful or newly started, red are failed nodes.


If an action fails then the rest of the actions belonging to the method will be skipped and the method will automatically be failed.


Action fails resulting in the Method failing Example of Action Movement

Action successful and more are left Example of Next Action tried


If a method fails (caused by an action within it failing) and there is another method belonging to the current task then the next method will be tried until successful or all methods have failed.


Method fails so the next Method is started Example of first Method failing

All Methods fail Example of all Methods failing


A task will only fail when all children methods of this task fails. This results in the duty failing


A Method is successful so all others are skipped and the next task is started Example of a Task completing


If a duty fails then the system will move onto the next duty, when all duties are done the process is started again from the start.